BoKKeR Posted July 12, 2023 Share Posted July 12, 2023 (edited) 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 July 12, 2023 by BoKKeR 2 6 5 Quote Link to comment
ABEIDO Posted July 14, 2023 Share Posted July 14, 2023 (edited) 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 July 14, 2023 by ABEIDO 1 Quote Link to comment
BoKKeR Posted July 16, 2023 Author Share Posted July 16, 2023 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. 1 Quote Link to comment
ABEIDO Posted July 17, 2023 Share Posted July 17, 2023 Its works nicely, and also with Unraid 6.12.3 that was just released. Great work man, BIG thumbs up. For me this is core feature as i use automations to control dockers and now i will also will start using VM controls for that. Quote Link to comment
syper Posted July 18, 2023 Share Posted July 18, 2023 (edited) 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. Edited July 18, 2023 by syper Quote Link to comment
BoKKeR Posted July 18, 2023 Author Share Posted July 18, 2023 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? Quote Link to comment
ABEIDO Posted July 18, 2023 Share Posted July 18, 2023 For me as it worked when i put bokker/unraidapi-re:6.12 in repository, as Bokker said to me. That is depending on if you run 6.12.x Quote Link to comment
syper Posted July 18, 2023 Share Posted July 18, 2023 2 hours ago, BoKKeR said: Quelle version d'unraid et quel tag de l'image ? Unraid : 6.12.2 Unraid api : bokker/unraidapi-re:6.12 Home Assistant 2023.7.2 Supervisor 2023.07.1 Operating System 10.3 Quote Link to comment
MAM59 Posted July 19, 2023 Share Posted July 19, 2023 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) ? Quote Link to comment
BoKKeR Posted July 19, 2023 Author Share Posted July 19, 2023 root will work fine, I am not sure about the errors, you are getting. Do you use a config folder? Quote Link to comment
MAM59 Posted July 19, 2023 Share Posted July 19, 2023 7 minutes ago, BoKKeR said: Do you use a config folder? not sure what you are asking for ?!?!? I've just installed the plugin, entered server, user and password. nothing else. Quote Link to comment
syper Posted July 19, 2023 Share Posted July 19, 2023 @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 Quote Link to comment
ABEIDO Posted July 19, 2023 Share Posted July 19, 2023 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 Quote Link to comment
ABEIDO Posted July 19, 2023 Share Posted July 19, 2023 @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. Quote Link to comment
MAM59 Posted July 19, 2023 Share Posted July 19, 2023 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. Quote Link to comment
Ak1rA Posted July 20, 2023 Share Posted July 20, 2023 Hello, I have a little problem, I pulled bokker/unraidapi-re:latest but some infos (like cpu, motherboard, memory) doesn't appear .... Quote Link to comment
Kilrah Posted July 20, 2023 Share Posted July 20, 2023 (edited) 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 July 20, 2023 by Kilrah Quote Link to comment
BoKKeR Posted July 22, 2023 Author Share Posted July 22, 2023 (edited) 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. 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 July 22, 2023 by BoKKeR Quote Link to comment
BoKKeR Posted July 23, 2023 Author Share Posted July 23, 2023 (edited) 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 Edited July 23, 2023 by BoKKeR 1 Quote Link to comment
Kilrah Posted July 23, 2023 Share Posted July 23, 2023 (edited) Parsing is better, unraid UI is smooth again, although "MoverRunning" is still always true and I still get 153 separate MQTT devices Edited July 23, 2023 by Kilrah Quote Link to comment
BoKKeR Posted July 23, 2023 Author Share Posted July 23, 2023 I think the old devices dont disappear but there should be a new device with grouped entities. Could you double check Quote Link to comment
Kilrah Posted July 23, 2023 Share Posted July 23, 2023 (edited) 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 July 23, 2023 by Kilrah Quote Link to comment
BoKKeR Posted July 23, 2023 Author Share Posted July 23, 2023 Has the grouping worked on the original project? Quote Link to comment
Kilrah Posted July 23, 2023 Share Posted July 23, 2023 I don't know, never used it until this week It may be having issues with the USB plugin that adds a page to the UI, I get all USB devices to each VM with broken parsing 1 Quote Link to comment
BoKKeR Posted July 23, 2023 Author Share Posted July 23, 2023 The usb device names get scraped wrong, will have to check on that, its unrelated to the usb plugin 1 Quote Link to comment
Recommended Posts
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.