ElectricBrainUK Posted December 20, 2019 Share Posted December 20, 2019 (edited) Overview: Support for Docker image unraid-api in the electricbrain repo. Docker Hub: https://hub.docker.com/r/electricbrainuk/unraidapi Github/ Docs: https://github.com/ElectricBrainUK/UnraidAPI Discord: https://discord.gg/Qa3Bjr9 If you feel like supporting our work: https://www.paypal.me/electricbrain Thanks a lot guys, I hope this is useful! Edited December 23, 2019 by ElectricBrainUK 4 Quote Link to comment
nphil Posted December 20, 2019 Share Posted December 20, 2019 (edited) Yay, finally! If anyone else runs HomeAssistant and unRAID, this is basically a one-way MQTT bridge from unRAID to HA. You can control containers, VMs, USB hotplugging, etc. Please help with testing and feedback! Edited December 20, 2019 by nphil 3 Quote Link to comment
Karatekid Posted December 22, 2019 Share Posted December 22, 2019 (edited) Not working for all of my docker containers at my side. Log says: There was a problem retrieving a field for a docker image Cannot read property 'contents' of undefined Docker images will be build on my side over docker-compose and not over the app center. what do you need for analysis? Question by the way. Why did you not build a general unraid-mqtt-interface? I'm using iobroker and nodered and this has not the format of Home Assistant. I must no badly change this to my needs. So the idea could be a general unraid-mqtt-interface and adapter for every smarthome-system if needed. Edited December 22, 2019 by Karatekid Quote Link to comment
ElectricBrainUK Posted December 22, 2019 Author Share Posted December 22, 2019 Hey Karatekid, Sorry it's not working for you. Does the UI work and show and control the dockers as you'd expect? Or does it not work their either? Does it connect to your mqtt broker at all? Regarding why I chose the route I did for mqtt was just because I'd only integrated it with Homeassistant for my personal use and I liked posting a single topic per device and several topics for the switches and sensors. That doesn't mean I'm not open to adapting it to suit your needs better. Perhaps we should talk on discord though if there will be a lot of back and forth about that? Your call though Quote Link to comment
res2cou Posted December 22, 2019 Share Posted December 22, 2019 Well i'm not a Homeassistant guy, Openhab here (As i know at least one other Unraid user is). I was looking at doing some of this over ssh, but this works alot better from a home automation standpoint in general. Thanks for making it. As it is it works better for openHab, if your going to change it it might be worth giving the option ether way? I had a quick look and adding load values, cpu/memory usage would be nice (if its not in there and i didn't see it). Quote Link to comment
ElectricBrainUK Posted December 23, 2019 Author Share Posted December 23, 2019 No problem, it's been a pleasure! You don't have to worry about that, I certainly won't be breaking compatibility. As you say it'll either be an option (with current functionality being the default) or best case both working in harmony. I'll look at getting utilisation in there, shouldn't be too difficult. Will let you know when there's an update. Quote Link to comment
Karatekid Posted December 23, 2019 Share Posted December 23, 2019 6 hours ago, ElectricBrainUK said: Hey Karatekid, Sorry it's not working for you. Does the UI work and show and control the dockers as you'd expect? Or does it not work their either? Does it connect to your mqtt broker at all? Regarding why I chose the route I did for mqtt was just because I'd only integrated it with Homeassistant for my personal use and I liked posting a single topic per device and several topics for the switches and sensors. That doesn't mean I'm not open to adapting it to suit your needs better. Perhaps we should talk on discord though if there will be a lot of back and forth about that? Your call though Hey, sorry I also forget that you made awesome work!! I would like to have the ability to do something like it. The UI just shows some dockers and not all of them. MQTT is now working, was because of my network structure. I need to made that all containers are able to speak to each other and also to unraid. I thought on a structure like that, where all points have a single message. Json is fine but I think at smarthome systems its better to have single messages for every status. That makes it easy to put it as a new json together for the display. I checked my adapters at iobroker and see that for example kodi does put every channel or switch in a single message/object. servername systeminfo arrayStatus arrayProtection ... vm vm1 switch_1 id status usb name attached ... docker container1 switch_1 imageUrl name status ... Quote Link to comment
ElectricBrainUK Posted December 23, 2019 Author Share Posted December 23, 2019 (edited) Thanks a lot! Im glad you think so. Interesting, the dockers that arent showing, is there anything unusual about them? Perhaps you could send me a private message with a screen shot of some of the dockers in your unraid UI that arent showing up, if that's alright with you? Okay that is interesting, I'll raise an issue to remind myself to add a more segmented version of the mqtt side as an option. Might take a bit though as things will be slow over the holiday period! Edit: (Issue for tracking https://github.com/ElectricBrainUK/UnraidAPI/issues/5) Edited December 23, 2019 by ElectricBrainUK 1 Quote Link to comment
meep Posted January 7, 2020 Share Posted January 7, 2020 Hi tried to get this up and running but no joy. Maybe I'm just using it wrong or have incorrect expectations; I'm trying to stay away from HA in my setup as it's just introducing another layer of complexity. I'm trying to build everything in Node-Red with MQTT as the messaging platform. As such, I set up this docker and tried sending it a direct MQTT message: meehab/api/getServers Am I wrong to expect the docker to respond on the mqtt base topic with a list of servers? Further, It's unclear what I'm supposed to see when I access the docker UI. Here's what I have; To get here, I had to enter my unraid username & password twice, first in the above box, then again in a pop up a few seconds later. The only affect seems to be the appearance of the shallow grey box on the right. What should i expect to see here? if I click on 'API Docs' and then back to welcome, I seem to be logged out (not connected) and must log in again. Here's my docker config; Quote Link to comment
ElectricBrainUK Posted January 7, 2020 Author Share Posted January 7, 2020 Hi, that all seems correct to me. I will get rid of the second log in at a later date as it's not necessary. Are you using https for your unraid instance? If so you need to add the https:// part in the IP section. Will make this more clear in the docs. Otherwise what information is in the logs? Quote Link to comment
meep Posted January 10, 2020 Share Posted January 10, 2020 On 1/7/2020 at 4:34 PM, ElectricBrainUK said: Hi, that all seems correct to me. I will get rid of the second log in at a later date as it's not necessary. Are you using https for your unraid instance? If so you need to add the https:// part in the IP section. Will make this more clear in the docs. Otherwise what information is in the logs? Thanks. My docker log is filled with multiple instances of the following (ip obfuscated by me); 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 Dashboard Details for ip: 192.168.n.n Failed with status code: undefined Request failed with status code 404 Get Docker Details for ip: 192.168.n.n Failed with status code: undefined Request failed with status code 404 Get VM Details for ip: 192.168.n.n Failed with status code: undefined Request failed with status code 404 Get Main Details for ip: 192.168.n.n Failed with status code: undefined Request failed with status code 404 This repeats over and over. There are no timestamps. Quote Link to comment
ElectricBrainUK Posted January 10, 2020 Author Share Posted January 10, 2020 Okay thanks, just to check: - is your unraid ui served over https or http? - do you have any unusual plugins that alter the unraid ui? - a 404 status code suggests it cannot reach the IP of your server at all, how is the network configured for the unraid API? Host, bridge etc. Quote Link to comment
meep Posted January 10, 2020 Share Posted January 10, 2020 Hi unraid UI is served over http PlugIn list attached, nothing too unusual, I believe. My unraidAPi network is configured as per screenshot in original post: Bridget, privileges off. Maybe the following would have an impact? 1. My MQTT docker is configured as host; (I'm not sure why it's set like this, I think it's the only way I could Node-Red to talk to it because.... 2. My unRaid UI is running on a non-standard port (I needed to map port 80 directly to port 80 in a NodeRed docker as my Alexa LAN discovery node insists it is configurerd so) Quote Link to comment
ElectricBrainUK Posted January 10, 2020 Author Share Posted January 10, 2020 Ahh it is probably the non standard port, if you delete your servers.json file and restart the api, then set the server up as ip:port it should work 1 Quote Link to comment
meep Posted January 10, 2020 Share Posted January 10, 2020 Actually, thinking about it, the non-standard port is likely the issue? If your docker is attempting to make calls to port 80, it won't work for me. As indicated, sometimes it's necessary to run UnRaid on an alternative port. Would you need to expose a variable for unRaid UI host port in the docker config? Quote Link to comment
meep Posted January 10, 2020 Share Posted January 10, 2020 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. Quote Link to comment
ElectricBrainUK Posted January 10, 2020 Author Share Posted January 10, 2020 That's great! Quote Link to comment
TheBuz Posted February 10, 2020 Share Posted February 10, 2020 (edited) Is there a way to spin up all disks? or call a user script to do it? Edited February 10, 2020 by TheBuz Quote Link to comment
ElectricBrainUK Posted February 10, 2020 Author Share Posted February 10, 2020 Not at the minute, but I'll add it to the to-do list! Quote Link to comment
TheBuz Posted February 10, 2020 Share Posted February 10, 2020 That's awesome thank you. The idea is, when the UPS goes on battery. to shutdown most VMs and Dockers and to spin down disks (ideally with no I/O activity or set their spin down time to a few minutes) to maximize the amount of time the server can stay on battery for. Quote Link to comment
JonathanM Posted February 11, 2020 Share Posted February 11, 2020 41 minutes ago, TheBuz said: maximize the amount of time the server can stay on battery for. Unless you have an industrial grade UPS with additional battery packs, that is not a good strategy. Most consumer level battery backups are sized in such a way that running them for more than 10 minutes or so drains the batteries to the point that long term battery health is negatively impacted. You need to accurately measure the draw with your server at full power with all services running on your UPS, find the runtime chart for your specific model, and plot how many minutes until 50% battery depletion. That's how long you have to fully shut down your server with brand new fully charged batteries. Then you need to put your server into the typical use configuration, and trigger an unattended shutdown. Time how long it takes for all the VM's and containers to shut down, all the disks to spin up, and the array to fully and properly stop and power down. Most rigs really should be triggering a shutdown after 3-5 minutes of the power loss in order to keep from dipping below the 50% mark on battery. If the power comes back on, then back off shortly after, you need enough power reserve in an emergency to shut down a second time before the batteries have a chance to recover. Typical recharge rates are 10 to 20 times longer than the time on battery, so if you discharged to 10 minutes, it's likely to be 2 hours before the batteries have recovered. 1 1 Quote Link to comment
chip Posted February 11, 2020 Share Posted February 11, 2020 So how do I put this over to my HA system? I just started diving into HA and have a few things going but would like to pull some stuff over off of Unraid into HA? I have this Docker up and running so now what do I need to do to get the info available for HA? Quote Link to comment
TheBuz Posted February 11, 2020 Share Posted February 11, 2020 9 hours ago, jonathanm said: Unless you have an industrial grade UPS with additional battery packs, that is not a good strategy. Most consumer level battery backups are sized in such a way that running them for more than 10 minutes or so drains the batteries to the point that long term battery health is negatively impacted. You need to accurately measure the draw with your server at full power with all services running on your UPS, find the runtime chart for your specific model, and plot how many minutes until 50% battery depletion. That's how long you have to fully shut down your server with brand new fully charged batteries. Then you need to put your server into the typical use configuration, and trigger an unattended shutdown. Time how long it takes for all the VM's and containers to shut down, all the disks to spin up, and the array to fully and properly stop and power down. Most rigs really should be triggering a shutdown after 3-5 minutes of the power loss in order to keep from dipping below the 50% mark on battery. If the power comes back on, then back off shortly after, you need enough power reserve in an emergency to shut down a second time before the batteries have a chance to recover. Typical recharge rates are 10 to 20 times longer than the time on battery, so if you discharged to 10 minutes, it's likely to be 2 hours before the batteries have recovered. This is very helpful thank you, and thinking about it there is no real benefit to server or Home Assistant staying online during a power cut, as I wouldn’t be able to use anything anyway. Looking at getting a 1400va. Currently have a 7 year old 700va. I did think about having 2nd UPS on the TV, but after all the calculations (based on what I think is a reasonable cost) I might get 20 minutes of runtime. Which doesn’t seem worth worrying about. I will get a 2nd 1400va UPS so I can still run network equipment and POE / DVR Security cameras for an hour or so. (60 watts total). That seems like a better plan. Thanks again Quote Link to comment
gruffdris Posted February 13, 2020 Share Posted February 13, 2020 Hi Found this on the HA forum and though id give it a try, when i sign in i get all my VMs, containers, HW etc but i dont get anything into HA. The logs i get back just repeat. Any suggestions on what to change? > [email protected] start /app > cross-env NUXT_HOST=0.0.0.0 NUXT_PORT=80 NODE_ENV=production node server/index.js Connected to mqtt broker READY Server listening on http://0.0.0.0:80 There was a problem retrieving a field for a docker image Cannot read property 'contents' of undefined There was a problem retrieving a field for a docker image Cannot read property 'contents' of undefined There was a problem retrieving a field for a docker image Cannot read property 'contents' of undefined Quote Link to comment
ElectricBrainUK Posted February 13, 2020 Author Share Posted February 13, 2020 Hey, Okay thanks for bringing that to my attention I'll look into it - however I do believe that it should work in HA despite this Do you have autodiscovery turned on for the MQTT integration in HA? If so do you have both that and the unraid API configured to use the same base topic? Cheers 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.