[Support] Electric Brain Unraid API


Recommended Posts

That depends, it could be the unraid API docker crashing, it could be the mqtt broker crashing. Or if the HA restarts while the API is still running it will take up to an hour by default to refresh all the states.

 

There could also be a few other reasons, if you could give me some more information that would be helpful. Like does it happen at a certain time or when you do a certain thing, does it come back after a certain amount of time etc. 

 

Cheers

Link to comment

Can anyone help with this error i'm getting in the logs

 

at Object.openSync (fs.js:447:3)
at Proxy.readFileSync (fs.js:349:35)
at updateMQTT (/app/mqtt/index.js:218:30)
at Timeout._onTimeout (/app/mqtt/index.js:450:5)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7) {
errno: -2,
syscall: 'open',
code: 'ENOENT',
path: 'config/mqttKeys'
}
The secure keys for mqtt may have not been generated, you need to make 1 authenticated request via the API first for this to work
Error: ENOENT: no such file or directory, open 'config/mqttKeys'

Link to comment
On 1/10/2020 at 5:34 PM, meep said:

OK, have it working. Many thanks!

 

One thing I missed after updating the server details was that I needed to login via the docker UI. I'd stopped and started unraid-API a few times as I wasn't getting the response to the MQTT request. Once I logged in, I was golden.

 

I'll have a play over the weekend to see what I can do with this.

I'm having same issues, cant seem to get it work

 

2 things

 

- for the ipadress, i just fill in the ip or with "http://" in front of it?

- what did u do to fix?

Youo say you logged in, that fixed it? log in , in the api ?

Link to comment
15 hours ago, skank said:

I'm having same issues, cant seem to get it work

 

2 things

 

- for the ipadress, i just fill in the ip or with "http://" in front of it?

- what did u do to fix?

Youo say you logged in, that fixed it? log in , in the api ?

The IP shouldn't matter if you have http or not

When you logged in what comes up? Does it display server details or controls? 

Link to comment

ok so yesterday it suddenly worked after i launched it and logged in (it says fill in username and paswword 2 times)
i now have entities like switches for dockers and a sensor..
 i do have other questions though.

- al those entitities are in ha saying they are unavailable, is that normal?
- if i shutdown the broker on the unraid machine, will the attributes of the machine still be visible in the broker for the raspberry pi(ha) to read from?
- i have the broker now on the unraid machine, and ha on my raspberry pi, since i shutdown my unraid (and not the pi) shouldnt it be wiser to set up the broker on the pi?
 - you have these sensors, how do i get them? they arent made by the discovery
```
                    - key: binary_sensor.unraid_server.cpu                      
                    - key: binary_sensor.unraid_server.memory
                    - key: binary_sensor.unraid_server.motherboard
                    - key: binary_sensor.unraid_server.arrayStatus
                    - key: binary_sensor.unraid_server.diskSpace
                    - key: binary_sensor.unraid_server.arrayProtection  
```
Thx for your support here!

Link to comment
1 hour ago, skank said:

ok so yesterday it suddenly worked after i launched it and logged in (it says fill in username and paswword 2 times)
i now have entities like switches for dockers and a sensor..
 i do have other questions though.

- al those entitities are in ha saying they are unavailable, is that normal?
- if i shutdown the broker on the unraid machine, will the attributes of the machine still be visible in the broker for the raspberry pi(ha) to read from?
- i have the broker now on the unraid machine, and ha on my raspberry pi, since i shutdown my unraid (and not the pi) shouldnt it be wiser to set up the broker on the pi?
 - you have these sensors, how do i get them? they arent made by the discovery
```
                    - key: binary_sensor.unraid_server.cpu                      
                    - key: binary_sensor.unraid_server.memory
                    - key: binary_sensor.unraid_server.motherboard
                    - key: binary_sensor.unraid_server.arrayStatus
                    - key: binary_sensor.unraid_server.diskSpace
                    - key: binary_sensor.unraid_server.arrayProtection  
```
Thx for your support here!

I wasn't able to figure that out so I came across this card that pulls those attributes

https://github.com/custom-cards/secondaryinfo-entity-row

 

 

Link to comment
15 hours ago, skank said:

According to the github page, that shouldnt be necessary

So im awaiting answer from ElectricBrainUK firts

 

18 hours ago, skank said:

ok so yesterday it suddenly worked after i launched it and logged in (it says fill in username and paswword 2 times)
i now have entities like switches for dockers and a sensor..
 i do have other questions though.

- al those entitities are in ha saying they are unavailable, is that normal?
- if i shutdown the broker on the unraid machine, will the attributes of the machine still be visible in the broker for the raspberry pi(ha) to read from?
- i have the broker now on the unraid machine, and ha on my raspberry pi, since i shutdown my unraid (and not the pi) shouldnt it be wiser to set up the broker on the pi?
 - you have these sensors, how do i get them? they arent made by the discovery
```
                    - key: binary_sensor.unraid_server.cpu                      
                    - key: binary_sensor.unraid_server.memory
                    - key: binary_sensor.unraid_server.motherboard
                    - key: binary_sensor.unraid_server.arrayStatus
                    - key: binary_sensor.unraid_server.diskSpace
                    - key: binary_sensor.unraid_server.arrayProtection  
```
Thx for your support here!

Hey, first of all no problem for the support, then I'll answer your questions in the same order they were asked:

- sometimes entities are listed as unavailable for a short period of time (up to 1 hour by default) as entities are only updated on change but once an hour (env variable MQTTCacheTime can change this to any value in minutes) all states are refreshed. If they are not becoming available after that though let me know

- if you shutdown the broker those attributes will not be available. I have my broker on the pi however if the API is shutdown as well it also means those details will become unavailable so I'm working on getting it added to the HA add-on store as well

- for statistics like cpu usage I recommend glances as it already has a lot of great features but if you want the details there (which is actually CPU name etc.) You can create custom sensors based on the details already available (you can see a server entity should have those details as attributes) for examples check here: https://www.home-assistant.io/integrations/template and let me know if you get stuck 

 

Cheers

Edited by ElectricBrainUK
Link to comment

So , normal step is i install the broker on the pi

so you are setting a API HA addon? So stats will remain visible? Thats cool !

Cant wait

This will mean ,all stats will be visible even when unraid is shut down?

 

- for the last question about statistics, you misunderstand me

i meant the attributes  like wat kind of motherbord, what cpu, what mem

Link to comment
5 hours ago, skank said:

So , normal step is i install the broker on the pi

so you are setting a API HA addon? So stats will remain visible? Thats cool !

Cant wait

This will mean ,all stats will be visible even when unraid is shut down?

 

- for the last question about statistics, you misunderstand me

i meant the attributes  like wat kind of motherbord, what cpu, what mem

Yep! 

 

For the 2nd point you can do that using the home assistant link I sent, here is an example for motherboard though: (on mobile so excuse formatting)

 

sensor:

- platform: template sensors:

server_motherboard:

value_template: "{{ state_attr('binary_sensor.server', 'motherboard') }}"

Link to comment

I had the glances stuff working

so i added the new sensors for the attributes, and now all is gone...

is there something wrong with my page?


title: Server
icon: mdi:nas
path: server
theme: ios-dark-mode
cards:
  - type: vertical-stack
    cards:
      - type: custom:vertical-stack-in-card
        title: Unraid Server
        cards:  
          - type: horizontal-stack
            cards:  
              - type: custom:card-modder
                card:
                  type: picture 
                  image: /local/unraid.png
              - type: custom:entity-attributes-card
                title: Kenmerken
                filter:
                  include:
                    - key: sensor.server_motherboard
                    - key: sensor.server_cpu
                    - key: sensor.server_memory
                    - key: sensor.server_diskspace
                    - key: sensor.server_arraystatus
                    - key: sensor.server_arrayprotection
          - type: conditional
            conditions:
              - entity: sensor.glances_disk_used_percent
                state_not: "unavailable"
              - entity: sensor.glances_disk_used_percent
                state_not: "unknown"    
            card:
                type: custom:bar-card
                align: split
                show_icon: true
                padding: 4px
                columns: 2
                card_style: 
                  border-radius: 5px
                severity:
                - value: 50
                  color: '#3bb3ee'
                - value: 80
                  color: '#e7a24a'
                - value: 100
                  color: '#ff0000'                        
                entities:
                  - entity: sensor.glances_disk_used_percent
                    title: Disk
                    max: 100            
                  - entity: sensor.glances_cpu_used
                    title: CPU
                    max: 100             
          - type: conditional
            conditions:
              - entity: sensor.glances_disk_used_percent
                state_not: "unavailable"
              - entity: sensor.glances_disk_used_percent
                state_not: "unknown"    
            card:
                type: custom:bar-card
                align: split
                show_icon: true
                padding: 4px
                columns: 2
                card_style: 
                  border-radius: 5px
                severity:
                - value: 50
                  color: '#3bb3ee'
                - value: 80
                  color: '#e7a24a'
                - value: 100
                  color: '#ff0000'                        
                entities:
                  - entity: sensor.glances_swap_used_percent
                    title: SWAP             
                    max: 100
                  - entity: sensor.glances_ram_used_percent
                    title: RAM
                    max: 100
          - type: conditional
            conditions:
              - entity: sensor.glances_containers_active
                state_not: '0'
              - entity: sensor.glances_disk_used_percent
                state_not: "unavailable"
              - entity: sensor.glances_disk_used_percent
                state_not: "unknown"                
            card:
                type: custom:bar-card
                align: split
                show_icon: true
                padding: 4px
                columns: 2
                card_style: 
                  border-radius: 5px
                entities:
                  - entity: sensor.glances_containers_ram_used
                    title: Docker RAM 
                    max: 10000                
                  - entity: sensor.glances_containers_cpu_used
                    title: Docker CPU
                    max: 100                   
          - type: conditional
            conditions:
              - entity: sensor.glances_disk_used_percent
                state_not: "unavailable"
              - entity: sensor.glances_disk_used_percent
                state_not: "unknown"    
            card:
                type: custom:bar-card
                align: left
                title_position: left
                show_icon: true
                padding: 4px
                columns: 1
                card_style: 
                  border-radius: 5px
                severity:
                - value: 50
                  color: '#3bb3ee'
                - value: 80
                  color: '#e7a24a'
                - value: 100
                  color: '#ff0000'                        
                entities:
                  - entity: sensor.glances_containers_active 
                    title: Containers    
                    max: 40   

 

My sensors:

 



sensor:
  - platform: template 
    sensors:
      server_motherboard:
        value_template: "{{state_attr('binary_sensor.unraid_server', 'motherboard') }}"
      server_cpu:
        value_template: "{{state_attr('binary_sensor.unraid_server', 'cpu') }}"
      server_memory:
        value_template: "{{state_attr('binary_sensor.unraid_server', 'memory') }}"
      server_diskspace:
        value_template: "{{state_attr('binary_sensor.unraid_server', 'diskSpace') }}"      
      server_arraystatus:
        value_template: "{{state_attr('binary_sensor.unraid_server', 'arrayStatus') }}"
      server_arrayprotection:
        value_template: "{{state_attr('binary_sensor.unraid_server', 'arrayProtection') }}"

 

Edited by skank
Link to comment
9 minutes ago, ElectricBrainUK said:

Regarding time frame on the add-on I'm not sure but it certainly won't be as long as months! Maybe 1 but if I get an evening where I have a lot of time I'm sure I'll be able to do it. 

 

No that looks right to me, does the ha config check return anything unusual? 

config check says all is valid

Dunno why the glances info all are gone, as soon as i add the attributes...

If i delete the attributes cards, then its back visible

Edited by skank
Link to comment

no this is my config yaml

 


default_config:

homeassistant:
  customize: !include customize.yaml
  packages: !include_dir_named packages


frontend:
  themes: !include_dir_merge_named themes
  
# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
#   base_url: example.duckdns.org:8123

lovelace:
  mode: yaml

customizer:
  custom_ui: local
  
hacs:
  token: !secret hacs_token
  appdaemon: true
  
# Text to speech

tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

sensor:
  - platform: unifigateway
    host: !secret unifi_host
    site_id: !secret unifi_site
    username: !secret unifi_username  
    password: !secret unifi_password
    monitored_conditions:
      - www
      - lan
      - wan
      - wlan
      - vpn
      - alerts
      - firmware
      
remote:
  - platform: harmony
    name: Harmony Hub
    host: !secret harmony


  

Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.