[Support] Electric Brain Unraid API


Recommended Posts

6 hours ago, ElectricBrainUK said:

@BudgetAudiophile there is a guide on the GitHub but let me know if more detail is needed. https://github.com/ElectricBrainUK/UnraidAPI/wiki the variables are under docker installation and on unraid you just edit the template and click add variable at the bottom.

If more detail could be provided it would be much appreciated. I'm still quite new to a lot of this and I'm pretty dense...I'm sure the info is there I'm just not sure I'm putting the pieces together to figure out what I actually need to edit. 


Am I needing to edit the Glances docker container in Unraid to connect them? 

Link to comment
On 11/4/2020 at 1:49 PM, Jokerigno said:

@ElectricBrainUK no. MQTT is running inside my unraid as a docker container (as yours). No other middle man.

 

Regarding the message what should I search? For example I searched for the unraid server name using MQTT Explorer but I didn't find anything.

Okay sorry to hear that, so is the docker image running in home assistant and not on unraid itself? I have heard some users have issues with that and I'm looking into it but I'm not sure what the cause is. If that is the case I'd say try running the unraid api docker on unraid itself and see if that works 

Link to comment
  • 2 weeks later...

Hello, sorry to dig up this old post but I'm having difficulty recieving unraid stats into HA. I have Unraid-API installed and MQTT on HA and both are talking. I can't figure out why I'm not recieving stats such as unraid CPU, HDD space, docker info, VM info. Pictured are what I am actually getting. Can anyone suggest where I may be going wrong or any extra steps I need to take.

 

Thanks, Craig

 

Available stats..

2020-11-19_16h09_42.png

 

MQTT..

2020-11-19_16h09_12.png

 

Unraid-API Log..

2020-11-19_00h12_11.png

 

Thanks.

 

Link to comment
  • 2 weeks later...
On 11/6/2020 at 12:49 AM, ElectricBrainUK said:

Okay sorry to hear that, so is the docker image running in home assistant and not on unraid itself? I have heard some users have issues with that and I'm looking into it but I'm not sure what the cause is. If that is the case I'd say try running the unraid api docker on unraid itself and see if that works 

No it's the opposite. Sorry for the ambiguity. Docker is running on Unraid Server but HA tooks some time to see the status of the containers, vm etc.

Link to comment
  • 3 weeks later...

I'm using the latest version of Unraid API and I used to have a binary_sensor for each of my VM's. Since moving to 6.90RC1 these seem have vanished. They appear as entities with status as "restored". I now only have a sensor for each VM (this shows VM as "started" rather than "On" for example). It's not a big issue but also unexpected. Is there any way to get these back?

 

I'm a little HomeAssistant so if I've missed something obvious then apologies in advance.

Link to comment
  • 4 weeks later...
On 5/10/2020 at 3:47 PM, skank said:

I would still love to see a possibility to:

- see if there are updates for dockers/plugins/unraid OS

- able to shut down the server

- correct info disk usage

- parity check

- reboot server

 

But an unraid api addon in HA would be even better 😛

 

@ElectricBrainUK

any update for this?

 

 

@ElectricBrainUK Is there a update to skanks question? Would be also interessed having the reboot server option.

Link to comment
2 hours ago, ph0b0s101 said:

@ElectricBrainUK Is there a update to skanks question? Would be also interessed having the reboot server option.

Sure:

 

- see if there are updates for dockers/plugins/unraid OS - WIP

- able to shut down the server - Available via mqtt command /basetopic/servername/poweroff

- correct info disk usage - Done

- parity check  - Available via mqtt command /basetopic/servername/check (also move for mover)

- reboot server - Available via mqtt command /basetopic/servername/reboot

 

But an unraid api addon in HA would be even better - There is an alpha version available on the github page but there are problems with it communicating over mqtt

  • Like 1
Link to comment

I have the exact same problem as NeepNinja (a few posts up from this one).  MQTT Mosquitto Broker is set up and working in HA with multiple Tasmota devices.  I installed the UnRaid-API making sure to fill in my HA MQTT Mosquitto IP, user and password in the Docker Template.  I also added the MQTTRefreshRate and MQTTCacheTime variables to the UnRaid API Docker Template. 

 

Upon first start, I launched the WebUI of UnRaid API and configured my server.  After doing so, I got on new device added to my HQ MQTT for my UnRaid Server, but none of the entities are working. 

 

In the UnRaid API WebUI my UnRaid shows up, but "On" is false and none of the VM, Dockers or Utils populate.  In the UnRaid API Log I'm getting "Request failed with status code 503". 

 

Can anybody help me figure out what I'm missing?  Does MQTT have to be installed on both the UnRaid as a Docker and in HA?

 

Thanks,
Dave

Edited by dbs179
Link to comment

Hey, seems I missed a few posts on this thread - sorry about that - I will answer them here: 

@Keith Ellis yes you can pause the dockers /basetopic/servername/dockername/paused should do the trick 

 

@paulmorabi I am working on a fix for the latest RC of unraid 

 

@dbs179 & @neepninja if you are getting 503 errors in the logs the problem is between the unraid API and the unraid server. Your mqtt setup within ha seems fine. The problem could be many things, if you're using the latest RC that could cause issues which I'm working on, or if the server uses https and the API hasn't been configured to connect over https, or if your UI uses non standard ports you need to list those in the URL field, could be a simple user/password mismatch as well. Finally if you're MQTTCacheTime or MQTTRefreshTime is too fast unraid can block the API for spamming it with requests. 

 

i hope this helps - let me know if there are further questions 

Edited by ElectricBrainUK
  • Like 1
Link to comment
8 minutes ago, dbs179 said:

@ElectricBrainUK Thank you.  My issue was a silly mistake, I had put the wrong password in the UnRaid API WebUI.  To be safe, I stopped the Docker, deleted the servers.json file, restarted the Docker and put in the correct credentials.  Once I did that everything came right up!

 

Thanks again, I appreciate it!

 

That's great, I'm glad it is working for you now! 

  • Like 1
Link to comment
  • 2 weeks later...

Today I have installed the unraid-api as an Home Assistant Addon. I have configured the Addon as follows:

 

MQTTBroker: <HA IP>
MQTTPort: 1883
MQTTUser: mqtt
MQTTPass: <password>
MQTTBaseTopic: unraid
MQTTSecure: false
MQTTSelfSigned: false
MQTTRefreshRate: 20
MQTTCacheTime: 60
KeyStorage: config

 

After I start the Addon i get the following error and I have no idea how i can do the first api call manually to generate the keys.

 

Error: ENOENT: no such file or directory, open 'config/mqttKeys'
    at Object.openSync (node:fs:495:3)
    at Proxy.readFileSync (node:fs:396:35)
    at updateMQTT (/app/mqtt/index.js:268:30)
    at Timeout._onTimeout (/app/mqtt/index.js:300:5)
    at listOnTimeout (node:internal/timers:556:17)
    at processTimers (node:internal/timers:499: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

 

Any hints or tipps?

Link to comment
17 minutes ago, ph0b0s101 said:

Today I have installed the unraid-api as an Home Assistant Addon. I have configured the Addon as follows:

 


MQTTBroker: <HA IP>
MQTTPort: 1883
MQTTUser: mqtt
MQTTPass: <password>
MQTTBaseTopic: unraid
MQTTSecure: false
MQTTSelfSigned: false
MQTTRefreshRate: 20
MQTTCacheTime: 60
KeyStorage: config

 

After I start the Addon i get the following error and I have no idea how i can do the first api call manually to generate the keys.

 


Error: ENOENT: no such file or directory, open 'config/mqttKeys'
    at Object.openSync (node:fs:495:3)
    at Proxy.readFileSync (node:fs:396:35)
    at updateMQTT (/app/mqtt/index.js:268:30)
    at Timeout._onTimeout (/app/mqtt/index.js:300:5)
    at listOnTimeout (node:internal/timers:556:17)
    at processTimers (node:internal/timers:499: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

 

Any hints or tipps?

Hey,

You do that via the web interface, open the UI and configure your unraid server. However the Home Assistant add-on is still in alpha and has some problems. The docker for unraid is more reliable if you face issues.

Link to comment

Ok could establish an connection via the webui. But i will get still this error:

 

 ERROR  ENOENT: no such file or directory, open 'config/mqttKeys'
  at Object.openSync (node:fs:490:3)
  at Proxy.readFileSync (node:fs:391:35)
  at default (api/getServers.js:27:36)
  at call (node_modules/connect/index.js:239:7)
  at next (node_modules/connect/index.js:183:5)
  at next (node_modules/connect/index.js:161:14)
  at next (node_modules/connect/index.js:161:14)
  at SendStream.error (node_modules/serve-static/index.js:121:7)
  at SendStream.emit (node:events:379:20)
  at SendStream.EventEmitter.emit (node:domain:470:12)
 ERROR  ENOENT: no such file or directory, open 'config/mqttKeys'
  at Object.openSync (node:fs:490:3)
  at Proxy.readFileSync (node:fs:391:35)
  at default (api/getServers.js:27:36)
  at call (node_modules/connect/index.js:239:7)
  at next (node_modules/connect/index.js:183:5)
  at next (node_modules/connect/index.js:161:14)
  at next (node_modules/connect/index.js:161:14)
  at SendStream.error (node_modules/serve-static/index.js:121:7)
  at SendStream.emit (node:events:379:20)
  at SendStream.EventEmitter.emit (node:domain:470:12)
Error: ENOENT: no such file or directory, open 'config/mqttKeys'
    at Object.openSync (node:fs:490:3)
    at Proxy.readFileSync (node:fs:391:35)
    at updateMQTT (/app/mqtt/index.js:268:30)
    at Timeout._onTimeout (/app/mqtt/index.js:300:5)
    at listOnTimeout (node:internal/timers:556:17)
    at processTimers (node:internal/timers:499: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

 

There is also no folder with mqttKeys in the config folder. Is this one of the mentioned bugs?

RAJoin6LLk.png

Link to comment

Hi,

 

Newbie here. First post. Got Unraid up and running since a week. really happy with it. Combined with HA VM, and several dockers of which one of them is the Unraid-api container, for use with HA. Got it up and running, did all the config stuff, and the connection with MQTT broker is there. I see entities in HA. I did however notice significant CPU spikes (from 6% lower level to 35+% upper) on a steady interval time ( every 5 sec approx).

 

I tried to drill down to the culprit and noticed this is related to the Unraid- api container. When started it is there, when stopped it is gone. Unraid api log only shows " started"  and connected to broker. Is there any way o debug this more? Or any experiences around a similar issue you might have encountered? 

Edited by MobileDude
Link to comment
On 1/21/2021 at 10:25 PM, ph0b0s101 said:

Ok could establish an connection via the webui. But i will get still this error:

 


 ERROR  ENOENT: no such file or directory, open 'config/mqttKeys'
  at Object.openSync (node:fs:490:3)
  at Proxy.readFileSync (node:fs:391:35)
  at default (api/getServers.js:27:36)
  at call (node_modules/connect/index.js:239:7)
  at next (node_modules/connect/index.js:183:5)
  at next (node_modules/connect/index.js:161:14)
  at next (node_modules/connect/index.js:161:14)
  at SendStream.error (node_modules/serve-static/index.js:121:7)
  at SendStream.emit (node:events:379:20)
  at SendStream.EventEmitter.emit (node:domain:470:12)
 ERROR  ENOENT: no such file or directory, open 'config/mqttKeys'
  at Object.openSync (node:fs:490:3)
  at Proxy.readFileSync (node:fs:391:35)
  at default (api/getServers.js:27:36)
  at call (node_modules/connect/index.js:239:7)
  at next (node_modules/connect/index.js:183:5)
  at next (node_modules/connect/index.js:161:14)
  at next (node_modules/connect/index.js:161:14)
  at SendStream.error (node_modules/serve-static/index.js:121:7)
  at SendStream.emit (node:events:379:20)
  at SendStream.EventEmitter.emit (node:domain:470:12)
Error: ENOENT: no such file or directory, open 'config/mqttKeys'
    at Object.openSync (node:fs:490:3)
    at Proxy.readFileSync (node:fs:391:35)
    at updateMQTT (/app/mqtt/index.js:268:30)
    at Timeout._onTimeout (/app/mqtt/index.js:300:5)
    at listOnTimeout (node:internal/timers:556:17)
    at processTimers (node:internal/timers:499: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

 

There is also no folder with mqttKeys in the config folder. Is this one of the mentioned bugs?

RAJoin6LLk.png

Hey sorry I missed this, it does seem that way - I will look into it. If you would like the functionality in the meantime I recommend you use the unraid docker - sorry for the inconvenience

Link to comment
12 hours ago, MobileDude said:

Hi,

 

Newbie here. First post. Got Unraid up and running since a week. really happy with it. Combined with HA VM, and several dockers of which one of them is the Unraid-api container, for use with HA. Got it up and running, did all the config stuff, and the connection with MQTT broker is there. I see entities in HA. I did however notice significant CPU spikes (from 6% lower level to 35+% upper) on a steady interval time ( every 5 sec approx).

 

I tried to drill down to the culprit and noticed this is related to the Unraid- api container. When started it is there, when stopped it is gone. Unraid api log only shows " started"  and connected to broker. Is there any way o debug this more? Or any experiences around a similar issue you might have encountered? 

Hey - that is unusual however there are two variables MQTTCacheTime (default 20 which is in seconds) and MQTTRefreshRate (default 60 which is in minutes) increasing these values should reduce the strain on your system.

Link to comment
1 hour ago, ElectricBrainUK said:

Hey - that is unusual however there are two variables MQTTCacheTime (default 20 which is in seconds) and MQTTRefreshRate (default 60 which is in minutes) increasing these values should reduce the strain on your system.

Excellent! that seem to do the trick. Strangely enough I cannot find the "online Manual" I followed, but that stated, as default "5" and "1" values. No wonder it went nuts :-). Thanks!

Edited by MobileDude
  • Like 1
Link to comment

Hello. I have the following problem. I install the Unraid-API docker on UnRaid server and everything seems to work. Home Assistant receives data from the server.

As soon as I reboot the server, the Unraid-API docker does not start and even if I start it manually it stops by itself. What could be the problem? This is the log:

 

> [email protected] start /app
> cross-env NUXT_HOST=0.0.0.0 NODE_ENV=production node server/index.js


READY Server listening on http://0.0.0.0:80

Connected to mqtt broker
Error: ENOENT: no such file or directory, open 'config/mqttKeys'
at Object.openSync (fs.js:461:3)
at Proxy.readFileSync (fs.js:364:35)
at updateMQTT (/app/mqtt/index.js:268:30)
at MqttClient.<anonymous> (/app/mqtt/index.js:49:7)
at MqttClient.emit (events.js:327:22)
at MqttClient.EventEmitter.emit (domain.js:485:12)
at Readable.<anonymous> (/app/node_modules/mqtt/lib/client.js:1449:14)
at Readable.emit (events.js:315:20)
at Readable.EventEmitter.emit (domain.js:485:12)
at endReadableNT (/app/node_modules/mqtt/node_modules/readable-stream/lib/_stream_readable.js:1010:12) {
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'
at Object.openSync (fs.js:461:3)
at Proxy.readFileSync (fs.js:364:35)
at updateMQTT (/app/mqtt/index.js:268:30)
at Timeout._onTimeout (/app/mqtt/index.js:300:5)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492: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
Failed to retrieve config file, creating new.

ERROR ENOENT: no such file or directory, open 'config/mqttKeys'

at Object.openSync (fs.js:461:3)
at Proxy.readFileSync (fs.js:364:35)
at default (api/getServers.js:27:36)
at call (node_modules/connect/index.js:239:7)
at next (node_modules/connect/index.js:183:5)
at next (node_modules/connect/index.js:161:14)
at next (node_modules/connect/index.js:161:14)
at SendStream.error (node_modules/serve-static/index.js:121:7)
at SendStream.emit (events.js:315:20)
at SendStream.EventEmitter.emit (domain.js:485:12)

Error: ENOENT: no such file or directory, open 'config/mqttKeys'
at Object.openSync (fs.js:461:3)
at Proxy.readFileSync (fs.js:364:35)
at updateMQTT (/app/mqtt/index.js:268:30)
at Timeout._onTimeout (/app/mqtt/index.js:300:5)
at listOnTimeout (internal/timers.js:549:17)
at processTimers (internal/timers.js:492: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
Get Docker Details for ip: 192.168.1.3 Failed
Cannot read property 'forEach' of undefined
Get Dashboard Details for ip: 192.168.1.3 Failed with status code: undefined
connect ECONNREFUSED 192.168.1.3:80
Get VM Details for ip: 192.168.1.3 Failed
connect ECONNREFUSED 192.168.1.3:80
Get Docker Details for ip: 192.168.1.3 Failed
connect ECONNREFUSED 192.168.1.3:80
Get USB Details for ip: 192.168.1.3 Failed
connect ECONNREFUSED 192.168.1.3:80
Get Main Details for ip: 192.168.1.3 Failed
connect ECONNREFUSED 192.168.1.3:80
Get Dashboard Details for ip: 192.168.1.3 Failed with status code: undefined
connect ECONNREFUSED 192.168.1.3:80
Get VM Details for ip: 192.168.1.3 Failed
connect ECONNREFUSED 192.168.1.3:80
Get Docker Details for ip: 192.168.1.3 Failed
connect ECONNREFUSED 192.168.1.3:80
Get USB Details for ip: 192.168.1.3 Failed
connect ECONNREFUSED 192.168.1.3:80
Get Main Details for ip: 192.168.1.3 Failed
connect ECONNREFUSED 192.168.1.3:80

> [email protected] start /app
> cross-env NUXT_HOST=0.0.0.0 NODE_ENV=production node server/index.js

Connected to mqtt broker

READY Server listening on http://0.0.0.0:80

Get Docker Details for ip: 192.168.1.3 Failed
Cannot read property 'forEach' of undefined
/app/mqtt/index.js:547
let docker = server.docker.details.containers[dockerId];
^

TypeError: Cannot read property 'containers' of undefined
at ModuleContainer.getDockerDetails (/app/mqtt/index.js:547:38)
at listOnTimeout (internal/timers.js:551:17)
at processTimers (internal/timers.js:492:7)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `cross-env NUXT_HOST=0.0.0.0 NODE_ENV=production node server/index.js`
npm ERR! Exit status 1


npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-01-26T11_45_32_250Z-debug.log

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.