[Support] Fork Unraid API-RE


Recommended Posts

Overview: Support for Docker image unraid-api-re in the bokker/unraid-api-re repo (fork of the original).

Docker Hub: https://hub.docker.com/repository/docker/bokker/unraidapi-re

Github/ Docs: https://github.com/BoKKeR/UnraidAPI-RE

If you feel like supporting my work: just say thanks!

 

This is a fork of https://github.com/ElectricBrainUK/UnraidAPI

 

I managed to fork and make the original project work on github ci. I will try to keep this project alive with newer unraid releases, its an exact dropin for the original https://github.com/ElectricBrainUK/UnraidAPI just replace the image

electricbrainuk/unraidapi

with

bokker/unraidapi-re

 

I will create a tag for each minor release as in:

bokker/unraidapi-re:6.12

which will cover 6.12.0 <-> 6.12.2

 

I mostly test the functions related to reporting status, if you have special needs as removing/editing containers, vms, switch gpus please tell if the container malfunctions for you.

 

I cant stress enough that this is not a proper solution, this container scrapes the unraid UI. Every minor update will possibly break functionality. I would love to setup automated tests, but to be able to do that I need a way to spin up the unraid os (or frontend) in a test environment. Happy to hear what ideas people can come up with. 

 

Until then please call up your local Unraid congressman and tell them how much you care about a publicly available API.

Edited by BoKKeR
  • Like 2
  • Thanks 4
  • Upvote 5
Link to comment

Ive been awaiting somekind of a fix and was glad to see you fork it. So thank you for commiting your time to it.

 

Ive replaced it now and i have problems with not beeing able to control anything.

Im using lastest Unraid and latest Homeassistant. Also tried resetting Unraid-Api after fork change.

 

When installing your fork i get back my old issues with VM not beeing controllable. Thats fine as it was that way before unraid update and i dont need to control VM(could be nice thou).

Get VM Details for ip: ip:port Failed
Cannot read properties of undefined (reading '0')
Get VM Details for ip: ip:port Failed
Cannot read properties of undefined (reading '0')

 

But i get error controlling Unraid, stopping/starting array from HA for example (something i could do with vanilla unraid-api).

I get in unraid-api log:

Received MQTT Topic: homeassistant/unraid/array and Message: Stopped assigning ID: MQTT-R-lk2e6ayi

But nothing happens.

 

When i try and start/stop a container from HA i get:

Received MQTT Topic: homeassistant/unraid/organizr/dockerState and Message: stopped assigning ID: MQTT-R-lk2elcf8
Part of MQTT-R-lk2elcf8 failed.

And nothing happens

 

When i do the same from Unraid API webui i first get a popup:

Please Enter Your Password For ip:port

And if i fill that in manually (even thou it should be taken from my serversetup i unraid-ui which is correct)

I get nothing in unraid-api logs and nothing happens to the container.

 

 Home Assistant can read the container state. So when i turn on a container within unraid manually, the sensor in HA gets turned on aswell.

 

It seem there is something with the auth/write but Im not sure what you need more specified so just ask and i will try my best to give logs and so on.

Edited by ABEIDO
  • Like 1
Link to comment

Thanks for the great detailed feedback! I have setup an extra machine with a trial key for testing (will need to find a better solution). 

 

There was a problem with extracting the CSRF token from the new UI, and other problems with getting VM details. (legacyUSB devices still wont show up, not sure what they are)

 

Please pull the latest and give it a try. Both VM-s and dockers should work now on 6.12

 

I would also like to add better logs and a screen for better overview, maybe if I find more time.

  • Thanks 1
Link to comment
4 minutes ago, syper said:

Hello, 

The information goes back to "Home Assistant" but the actions do not work.
I can't turn on or off a docker container.
 

I have no error message 🥲

thank you for your work.

Which version of unraid and which tag of the image? 

Link to comment

Hi! great Idea I also need an API (mainly for waking up the drives).

 

But beeing a newby with this api stuff (never used the original one before), I have some problems with the basic setup already.

 

It asks me for "Server IP", but my unraid is running on a different port. I've entered <ip>:<port> as usual and it seems to work a bit

but I am getting constant errors like

Jul 19 06:33:09 F nginx: 2023/07/19 06:33:09 [error] 13914#13914: *235440 limiting requests, excess: 20.753 by zone "authlimit", client: 172.17.0.5, server: , request: "GET /login HTTP/1.1", host: "192.168.0.4:800"
Jul 19 06:33:14 F webGUI: Unsuccessful login user root from 172.17.0.5
Jul 19 06:33:14 F nginx: 2023/07/19 06:33:14 [error] 13914#13914: *235463 limiting requests, excess: 20.229 by zone "authlimit", client: 172.17.0.5, server: , request: "GET /login HTTP/1.1", host: "192.168.0.4:800"
Jul 19 06:33:14 F nginx: 2023/07/19 06:33:14 [error] 13914#13914: *235464 limiting requests, excess: 20.229 by zone "authlimit", client: 172.17.0.5, server: , request: "GET /login HTTP/1.1", host: "192.168.0.4:800"

 

Username and password are correct, so I assume, it needs some other settings in unraid. or should i use somebody else (not root) ?

 

 

Link to comment

@BoKKeR 

I deleted everything and started again and I saw this error at the beginning:

 

Quote

Error: ENOENT: no such file or directory, open 'config/mqttKeys'
    at Object.openSync (node:fs:590:3)
    at Object.readFileSync (node:fs:458:35)
    at updateMQTT (/app/mqtt/index.js:382:19)
    at Timeout._onTimeout (/app/mqtt/index.js:439:7)
    at listOnTimeout (node:internal/timers:559:17)
    at processTimers (node:internal/timers:502: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

 

Then it loops over:

 

Quote

Connected to mqtt broker
Connected to mqtt broker
Connected to mqtt broker
Connected to mqtt broker
Connected to mqtt broker
Connected to mqtt broker
Connected to mqtt broker
Connected to mqtt broker
Connected to mqtt broker
Connected to mqtt broker
Connected to mqtt broker
Connected to mqtt broker
Connected to mqtt broker

 

Thank you

Link to comment
3 hours ago, MAM59 said:

Hi! great Idea I also need an API (mainly for waking up the drives).

 

But beeing a newby with this api stuff (never used the original one before), I have some problems with the basic setup already.

 

It asks me for "Server IP", but my unraid is running on a different port. I've entered <ip>:<port> as usual and it seems to work a bit

but I am getting constant errors like

Jul 19 06:33:09 F nginx: 2023/07/19 06:33:09 [error] 13914#13914: *235440 limiting requests, excess: 20.753 by zone "authlimit", client: 172.17.0.5, server: , request: "GET /login HTTP/1.1", host: "192.168.0.4:800"
Jul 19 06:33:14 F webGUI: Unsuccessful login user root from 172.17.0.5
Jul 19 06:33:14 F nginx: 2023/07/19 06:33:14 [error] 13914#13914: *235463 limiting requests, excess: 20.229 by zone "authlimit", client: 172.17.0.5, server: , request: "GET /login HTTP/1.1", host: "192.168.0.4:800"
Jul 19 06:33:14 F nginx: 2023/07/19 06:33:14 [error] 13914#13914: *235464 limiting requests, excess: 20.229 by zone "authlimit", client: 172.17.0.5, server: , request: "GET /login HTTP/1.1", host: "192.168.0.4:800"

 

Username and password are correct, so I assume, it needs some other settings in unraid. or should i use somebody else (not root) ?

 

 

Im not sure this helps, but a while back (on vanilla unraidapi)i had rate limit issues aswell. with similar errors like you. Unraid has authlimit on UI . So it its not just Upnraid API that can affect it.

 

https://github.com/ElectricBrainUK/UnraidAPI/issues/23

https://forums.unraid.net/search/?&q=authlimit&search_and_or=or

 

I tried som of those commands in first link but some other issues occured (so make sure u dont lock your self out as my unraid gui got stuck and i needed to ssh and reset ui via cli)

 

But what solved it for me in the end as i remember was to disable unraid api and wait 24 hours  (to clear the auth) and try again, b

Link to comment

@Bokker

Some nice to haves, just if its possble. Im really glad that you fixed it as it is so everything else is icing on the cake.

 

Restart fix

If i restart HA the unraid api devices will go unknown and i need to restart urnaid api docker to get it up and running again. Old problem and  not a major issue. Is there something that can be done from Unraid APIs side?

 

Sorting

The dockers and vms is own devices under HA MQTT plugin, is it possible to group them under UNRAID mqtt device. I use HASS Agent for windows machines and that adds all sensors and switches under the machine. So my machine called Server gets for examble plex on and off buttons under itself, would be nice to get all dockers switches/sensors under Unraid. Its just less cluttered and is easier to find stuff.

Capture.JPG.bf98ac4a56956a1a557bc130db9f1b9c.JPGCapture2.jpg.28ab22efc42fe933bbb0ce31a7c87915.jpg

Link to comment
51 minutes ago, ABEIDO said:

and wait 24 hours  (to clear the auth) and try again

Tnx for the suggestion, but that only clears the symptom, not the cause.

I've seen this already before, those days it was ip6 confusing unraid (disabling it for the gui solved the issue).

It has something to do with a "lost security token".

Some App logs (successfully) in, gets a token/cookie and forgets to save it. Next call will again reforce a login and this loops over and over again.

 

I guess something alike happens with this plugin, no clue why.

Link to comment

Same on 6.12.3. Also agree with putting the whole server under the same MQTT device, now it completely floods things to the point it's hard to find the other MQTT devices other than unraid.

Also the WebUI becomes pretty much unusably slow when the container is running, seeing 200+ MQTT messages per second it seems it might be refreshing continuously, probably want to make that configurable so it can be set to refresh only every 10 seconds or a minute.

 

Edited by Kilrah
Link to comment

I am looking into the option of grouping the mqtt devices into a single device. Currently only found this https://community.home-assistant.io/t/how-to-group-entities-into-a-device/262600 without luck of it working. Only a single device shows up.

 

Also looking at fixing the missing/broken properties, like cpu/motherboard/ram. I will need to change the way we extract the data from html dom, currently the project just uses string.substring() manipulation. I am looking into a way using xpath.

image.thumb.png.48d46e93187efbd9a45f7408fa48197c.png

 

There might be better frameworks for selectors in nodejs/xml that I am not aware of. 

 

Preferably the selectors should be editable from the UI (loadable from a config file). In case there is a new version, users should be able to fix the broken properties themselves just by replacing the selectors. 

 

Has anyone managed to find a way of running the webGui https://github.com/unraid/webgui without the underlying unraid OS? 

Edited by BoKKeR
Link to comment

I updated the master and the 6.12 branch, currently this is the info I get on my test device. The grouping seems to work also on my device, but I havent done any changes there, maybe the other changes fixed the HA groups

 

image.png.8a29cbef742f89c2fede9a02c89c9ee6.png

Edited by BoKKeR
  • Like 1
Link to comment

No I had them all removed, there was no unraid-related device in HA until I started the new version

 

Also scratch the unraid UI being smooth, that only lasted a few minutes. Seems it goes from being smooth to slow and back to normal repeatedly...

Edited by Kilrah
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.