[Support] Fork Unraid API-RE


Recommended Posts

9 hours ago, Orishas said:

Hi,

 

i tested this release it fixes problem that the entity becomes unavailable after a HA restart, but now it always retains the status on:true

Thanks, will check on that, I think the problem is unrelated but I will create a fix for it. 

 

3 hours ago, ABEIDO said:

Another reflection i had was the Shutdown, Reboot and Parity Check actions should be set as buttons and not as switches which they are now. Or am i missing something?

Is this is right? considering the HA developers page states buttons are stateless

 

A button entity is an entity that can fire an event / trigger an action towards a device or service but remains stateless from the Home Assistant perspective. It can be compared to a real live momentary switch, push-button, or some other form of a stateless switch. 

 

https://developers.home-assistant.io/docs/core/entity/button/

Link to comment
19 hours ago, BoKKeR said:

Thanks, will check on that, I think the problem is unrelated but I will create a fix for it. 

 

Is this is right? considering the HA developers page states buttons are stateless

 

A button entity is an entity that can fire an event / trigger an action towards a device or service but remains stateless from the Home Assistant perspective. It can be compared to a real live momentary switch, push-button, or some other form of a stateless switch. 

 

https://developers.home-assistant.io/docs/core/entity/button/

 

First off, massive thanks to you Bokker for keeping Unraid-API alive and continue improving the functionality. The last fix that fixed HA reboot issues was really nice.

 

Regarding buttons/switches:

I think reboot/shutdown/parity check was seen as button before some updates, i could be wrong thou. And also everything works fine anyway with the switch as it is now. It does what is supposed to and the switch goes to on for a bit then back to off(as it is not a static on or off activity)

 

So it just estetics i my mind, like below from a another mqtt service i use. Here reboot is considered as button and gets press the "Press" in ui. So nothing big on the user end, and its really up to you.

 

image.png.892ab495bacdf387e7d23fecec33df36.png

 

Restart Functionality for Unraid API

Im trying to find a way to restart UnraidAPI container via HA. As stop/start wont work as stop kills the container and then no more connection. All other containers i can work with stop then start. Is there any way to add a restart for especially unraid-api?

 

Link to comment

Thank you so much for picking up this plugin  :)

I've setup HomeAssistant to get the data, and I just discovered a minor flaw in naming which I think is inconsistent:
My server-name is (originally enough!) unRaid1
- so the friendy_name of the server-entity is "unraid1"   - so far so god

- then the friendly_name of the array-switch is getting to be "unraid1 unraid1_array"  - so a duplication of server-name and a blank space
   - could friendly name be changed to "unraid1_array" ?

- then the dockers come with friendly_names with spaces and underline: "unraid1 _docker_adguard-home"

   - could friendly name be changed to "unraid1_docker_adguard-home" ?   (without the space)

image.thumb.png.ffa321d6bc70d50472ead40c010d9087.png
I'm not a programmer,, so not sure where the friendly-names get created,, but somehow I guess you can fix this  ;)

 

 

 

EDIT:

just noticed that also deleted dockers get to HA :)
image.thumb.png.c90083f873ebe30edd612442812a47dd.png

the Adminer and Krusader is deleted from docker-tab,, but not sure I've restarted server after removing,, so that might be why they show up,,

But the naming of theese do not include additional space between servername and underscore_docker_name 

thought I'd share so might be easier to troubleshoot?


 

Edited by ArveVM
additional findings
  • Like 2
Link to comment

I just pushed a new release with the following:

- added button to restart docker containers

- changed switch for parity/restart/power/mover to button

 

I am still looking into a way to set the ON:False upon turning off the server.

 

@ArveVM I couldnt reproduce this problem. Will try again but all my containers/vms have the non space name as default. Could you try removing the mqtt addon and re-adding it? I also added a trim to the server name. Maybe it fixes your problem. Are you using any custom theme? 

 

image.thumb.png.504ab711851b54c429d45e1c7d058201.png

Edited by BoKKeR
  • Like 1
Link to comment

I had a problem with the latest release, updated the docker this morning and lost my unraid ui. Took me about 30 minute to figure out what was going on. Doing this in the cli brought it back but only temporary.

 

/etc/rc.d/rc.php-fpm restart

 

it kept stopping. All the docker were fine. All my hosted apps fine. Only the UI that kept stopping

 

So I finally stop the unraid-api docker. And the problem went away.  I think the docker was hammering the unraid server. Found a bunch of these in the logs and overloaded the UI

Oct  1 07:30:18 SERVER nginx: 2023/10/01 07:30:18 [error] 9491#9491: *125230 limiting requests, excess: 20.002 by zone "authlimit", client: 172.17.0.13, server: , request: "GET /login HTTP/1.1", host: "192.168.7.11"

 

They went away when I stopped the unraid-ap docker and the UI came back for good.

 

I confirmed the issue by restarting the container eventually the UI was unresponsive.

 

Not sure what is going on, passing along the info. Let me know if you need anything. Heading out on business tomorrow so i will be unresponsive during the week.
 

 

 

Link to comment
22 hours ago, BoKKeR said:

Could you try removing the mqtt addon and re-adding it?

 

Running Mosquitto as docker in unraid,,
Did a "force update",, is that the equivalent of removing/re-adding ??

did'nt seem to have an impact on naming - but got new button which worked :)
image.png.237e872613b6108feb6bc1cc6244f912.png

 

I believe it might have to do with my naming,, and possible "old history" where devices have been added for each entity?
image.thumb.png.1b5d356f9a42189be6d4a483f2f5a918.png

 

i have a bunch of theese devices,, with no entities in them:
image.thumb.png.452f32134b3d05b5fc37eba592684a40.png

 

and it "must" be old news,, because the adminer-docker was setup a long time ago,,, and is stuck with my old server-info (upgraded earlier this summer to Gigabyte mobo)
image.thumb.png.41d72fd1e3d9edb31ee8cd4a0becfc40.png

 

i believe it comes down to renaming device which is not effecting the renaming devices?
Tried to rename the correct device to "unraidAPI",, and came up with this new naming :(
 

image.png.a915f25ef888e00c670fea01058f5c53.png

 

image.png.a8de0bbb3e2ac5bf2deb96b1735eec5a.png

 

image.png.c6f2d122bf06827b67dea8b0f130d1cb.png

 

 

Will try and delete the old devices,, then rename again and see if it makes any difference,,,

And thanks for the quick response,,  :)

 

 

Link to comment
14 minutes ago, ArveVM said:

Will try and delete the old devices,, then rename again and see if it makes any difference,,,

 

image.png.f4324ec81f3f8489250f97914dd9b8dc.png

 

Deleted all the old devices and renamed the one with updated/active entities to "unraidAPI2",, and the naming of entities are still adding a space between the device-name and the entity-part of the friendly name

Can you re-create my issue if you change device-name??
(sorry for the confusion earlier,, )

Link to comment
5 hours ago, Faspina said:

I had a problem with the latest release, updated the docker this morning and lost my unraid ui. Took me about 30 minute to figure out what was going on. Doing this in the cli brought it back but only temporary.

 

/etc/rc.d/rc.php-fpm restart

 

it kept stopping. All the docker were fine. All my hosted apps fine. Only the UI that kept stopping

 

So I finally stop the unraid-api docker. And the problem went away.  I think the docker was hammering the unraid server. Found a bunch of these in the logs and overloaded the UI

Oct  1 07:30:18 SERVER nginx: 2023/10/01 07:30:18 [error] 9491#9491: *125230 limiting requests, excess: 20.002 by zone "authlimit", client: 172.17.0.13, server: , request: "GET /login HTTP/1.1", host: "192.168.7.11"

 

They went away when I stopped the unraid-ap docker and the UI came back for good.

 

I confirmed the issue by restarting the container eventually the UI was unresponsive.

 

Not sure what is going on, passing along the info. Let me know if you need anything. Heading out on business tomorrow so i will be unresponsive during the week.
 

 

 

 

Sorry, I reverted that change

 

@ArveVM Could you try to remove the mqtt addon, and add it back again. This will just remove the old entities, and once you add it back the existing ones will show again

 

image.thumb.png.08f815d46204ac5338e2ddbc6e464e8e.png

Edited by BoKKeR
Link to comment
10 hours ago, BoKKeR said:

@ArveVM Could you try to remove the mqtt addon, and add it back again. This will just remove the old entities, and once you add it back the existing ones will show again.

 

I guess what you meant was delete the integration and re-add the integration? (since the Add-on is the mosquito-engine, and the integration is the "getting data from mosquitto into HA"

 

so I've tried that,, and no success (name is back to unraid1 which is servername in unraid) and there are still spaces in friendly-name and for array the server-name is presented twice (with space between them)
image.thumb.png.f1a50b3d09b68781d1eabb2d4f6eea68.png



Tried once again,, now deleting integration - restart HA (to ensure removal of entities) - add integration,, and it keep getting in with theese "strange" naming conventions,,,
image.png.6d1e2a021f8b9660e376ae2b0a61f4f6.png

servername space servername underscore array - should be servername underscore array?

docker switch come with same 
image.png.301e4529c213065ac4ec7074bacc1a93.png

button same as switch

image.png.3861c2e7e28aed96842eef216ca81407.png

 

"master sensor" with just server-name (Which seems right)

image.png.8d26958bde84123c53ad8ac9643f2846.png

 

 

------- 
Then I try to rename the device to unraidAPI  (Since I want my sensors to reflect the name of the integration/source the data comes from),, and then get theese namings:
image.png.16f55860666958c732988c944d4f02c6.png

image.png.9b628b08e940d71a3007ae835c05f877.png

image.png.684753638c868e8dd073e40269615a4f.png

image.png.a7262f6f4876891c5d2f7c8c2405e5fe.png

 

so now that I've cleaned out (my old crap) and installed integration again:

- the device name and entity_id are renaming just fine,,

- but the friendly name of docker-entities/mover/paritycheck(poweroff/reboot have an additional "unwanted" space between servername and 'entity'


Hope you understand this is not a critical bug,, so if you want to park it that is just fine - I'll just instruct my OCD to live with it  :)


Love the getting all entites into one device - and the button is also better  - so great work!!

 

image.png

Link to comment
5 hours ago, lanky8804 said:

Love it that this API has been taken up again. Having issues in docker with nothing showing under the sever??

Are you sure you have changed to the new docker?
I believe it was like your screenshot until i updated to the new repository,,,
image.png.142860fde58c5c4de2bc92c22b1f5cf6.png

Link to comment
22 hours ago, BoKKeR said:

 

Sorry, I reverted that change

 

 

Oh, so reason for entire UI death was this? I already downgraded back to 6.12.3 because did not figure out reason (and it fixed it). Also this HA shutdown did not work this morning :( So My Unraid was on that 40 eurocent / kWh hour... Now it seems to be working, but there was no update for docker yet in community store?

 

-edit- oh sorry, seems it have been autoupdated 17 hours ago. But after that my Unraid webgui came pretty unresponsive? So is this now incompatible with 6.12.4?

Edited by ByteHeaven
Link to comment
On 9/23/2023 at 2:27 PM, ABEIDO said:

Restart Functionality for Unraid API

Im trying to find a way to restart UnraidAPI container via HA. As stop/start wont work as stop kills the container and then no more connection. All other containers i can work with stop then start. Is there any way to add a restart for especially unraid-api?

 

 

What I use in HA is: Unraid is behind Meross smart plug (controlled in HA). Bios setting set to start the computer after power break. And I have (based on Nordpool Spot prices) two automations. When Electricity price goes above 18 eurocents an hour, HA shuts the Unraid down through this api docker with a command (clean shutdown). When price goes back below that, HA shuts the Meross smart plug, counts to 5, and puts power back on ;) (with sanity check that power consumption is less than 10 W thus computer IS off, not to turn off power from running computer)

 

Bang, Unraid starts. No need to touch it :) 

 

-edit- Simple is beautiful (compared to hassle around gettin wake up on lan working reliably)

Edited by ByteHeaven
Link to comment
10 hours ago, ByteHeaven said:

 

 

Oh, so reason for entire UI death was this? I already downgraded back to 6.12.3 because did not figure out reason (and it fixed it). Also this HA shutdown did not work this morning :( So My Unraid was on that 40 eurocent / kWh hour... Now it seems to be working, but there was no update for docker yet in community store?

 

-edit- oh sorry, seems it have been autoupdated 17 hours ago. But after that my Unraid webgui came pretty unresponsive? So is this now incompatible with 6.12.4?

 

It is compatible with 6.12.4, I think an update messed up the dashboard crawling but its reverted now.

 

Offtopic:

You might want to change from a smart plug start/stop to a controlled shut down for your data-s sake. I dont think the drives enjoy having the plug pulled, ram wiped etc.

 

Alternative solution would be having a pi zero ssh into your unraid server and send shutdown command, or have a esp32 which bridges the power button headers on your motherboard for a second which initiates a controlled shutdown. 

 

@ArveVM I cant really reproduce it, but I will try further on the weekend. Could you confirm that there is no space in the name of the server? Also are you using any custom theme? 

 

image.thumb.png.1eed043ef754afcf0cd6a33fb6355d86.png

Link to comment
15 hours ago, ArveVM said:

Are you sure you have changed to the new docker?
I believe it was like your screenshot until i updated to the new repository,,,
image.png.142860fde58c5c4de2bc92c22b1f5cf6.png

Thanks for the reply.

 

My repo was booker/unraidapi-re:6.12

 

Have changed it to booker/unraidapi-re but still the same issue.

 

The logs from the docker seem odd with the ip being 0.0.0.0:80

 

My unraid server is on port 8443

 

image.thumb.png.d6e422d982d3c1aa306f05602428824f.png

 

image.thumb.png.cac6a104e76bae8dff27146555c09336.png

Link to comment

So have rebooted HA a few times and left it for a while but still nothing being added to MQTT integration. Have searched entities also but nothing new added.

 

Should the UnraidAPI just appear in the MQTT integration or do we still need to install that API addon like in the original version?

Link to comment
7 hours ago, BoKKeR said:

Offtopic:

You might want to change from a smart plug start/stop to a controlled shut down for your data-s sake. I dont think the drives enjoy having the plug pulled, ram wiped etc.

 

Alternative solution would be having a pi zero ssh into your unraid server and send shutdown command, or have a esp32 which bridges the power button headers on your motherboard for a second which initiates a controlled shutdown. 

 

 

Oh, sorry if I wrote unclear, shutdown of server goes with this api from HA (clean shutdown). Turning computer on, when it is shut down goes by: have bios setting to start after power break, and then with shut down computer turn power off and on with smart plug (with sanity check before doing it that power consumption is less than 10W thus computer is NOT on. :)  (thus simple compared to hassle around getting wake on lan working reliably)

Edited by ByteHeaven
Link to comment

Hi, that you went with the restart and buttons, awsome to see that the integration grows. Good work Bokker.

Im having 2 issues thou:

 

HA Restart bug:
But it seems that the HA restart issue is back which you fixed a couple of updates before. When i restart HA the sensors/switches/buttons goes unavailable again.


Doubled naming:
Same as above that has strange naming on the 5 ”new” button/switch, doubled unraidserver name.
button.unraidservername_unraidservername_mover
button.unraidservername_unraidservername__partitycheck
button.unraidservername_unraidservername__power_off
button.unraidservername_unraidservername__reboot
switch.unraidservername_unraidservername__array
 

Link to comment

Good news everyone! I located the naming issues cause https://community.home-assistant.io/t/psa-mqtt-name-changes-in-2023-8/598099

 

I couldnt reproduce it since I was running the older version of HA. 

 

Here is an example error you might have noticed in HA:

 

2023-10-03 10:48:52.147 WARNING (MainThread) [homeassistant.components.mqtt.mixins] MQTT entity name starts with the device name in your config {'payload_available': 'True', 'payload_not_available': 'False', 'json_attributes_topic': 'homeassistant/unraidvm/home-assistant-container', 'name': 'unraidvm_docker_home-assistant-container_restart', 'unique_id': 'unraidvm_home-assistant-container_restart', 'payload_press': 'restart', 'device': {'identifiers': ['unraidvm'], 'name': 'unraidvm', 'manufacturer': 'ASUS ASUSTeK COMPUTER INC. , Version Rev 2802', 'model': 'Docker', 'connections': []}, 'command_topic': 'homeassistant/unraidvm/home-assistant-container/dockerState', 'encoding': 'utf-8', 'availability_mode': 'latest', 'qos': 0, 'enabled_by_default': True, 'retain': False}, this is not expected. Please correct your configuration. The device name prefix will be stripped off the entity name and becomes '_docker_home-assistant-container_restart'

 

Meaning the friendly name cant start with the same string as the device name! 

 

I will have to look into proper naming with the new HA release. I am open to suggestions! 

 

image.png.61667ebea40df673ca51a2fa6ea2f75d.png

Edited by BoKKeR
Link to comment
31 minutes ago, BoKKeR said:

Good news everyone! I located the naming issues cause https://community.home-assistant.io/t/psa-mqtt-name-changes-in-2023-8/598099

 

I couldnt reproduce it since I was running the older version of HA. 

 

Here is an example error you might have noticed in HA:

 

2023-10-03 10:48:52.147 WARNING (MainThread) [homeassistant.components.mqtt.mixins] MQTT entity name starts with the device name in your config {'payload_available': 'True', 'payload_not_available': 'False', 'json_attributes_topic': 'homeassistant/unraidvm/home-assistant-container', 'name': 'unraidvm_docker_home-assistant-container_restart', 'unique_id': 'unraidvm_home-assistant-container_restart', 'payload_press': 'restart', 'device': {'identifiers': ['unraidvm'], 'name': 'unraidvm', 'manufacturer': 'ASUS ASUSTeK COMPUTER INC. , Version Rev 2802', 'model': 'Docker', 'connections': []}, 'command_topic': 'homeassistant/unraidvm/home-assistant-container/dockerState', 'encoding': 'utf-8', 'availability_mode': 'latest', 'qos': 0, 'enabled_by_default': True, 'retain': False}, this is not expected. Please correct your configuration. The device name prefix will be stripped off the entity name and becomes '_docker_home-assistant-container_restart'

 

Meaning the friendly name cant start with the same string as the device name! 

 

I will have to look into proper naming with the new HA release. I am open to suggestions! 

 

image.png.61667ebea40df673ca51a2fa6ea2f75d.png

 

 

Yeah theres more integrations with the same issue with naming. Ive never really understood the issue fully more than that entity cannot have the devicename in its name. And i rename everything to fit my naming scheme. With thats said keep it simple and set unraidapi or unraid, short and simple.

 

FYI: When you do update i noticed that parity-check button was misspelled, now we are on a really shallow level of problems :)

 

And regarding the HA restart issue that was back for me (where you need to restart UnraidAPI docker after HA restart), did anyone else notice this or is it something at my setup only?

 

 

Link to comment
1 hour ago, ABEIDO said:

 

 

Yeah theres more integrations with the same issue with naming. Ive never really understood the issue fully more than that entity cannot have the devicename in its name. And i rename everything to fit my naming scheme. With thats said keep it simple and set unraidapi or unraid, short and simple.

 

FYI: When you do update i noticed that parity-check button was misspelled, now we are on a really shallow level of problems :)

 

And regarding the HA restart issue that was back for me (where you need to restart UnraidAPI docker after HA restart), did anyone else notice this or is it something at my setup only?

 

 

 

Thanks I fixed that typo! 

Link to comment

BoKKeR,

 

THANK YOU SO MUCH FOR CONTINUING THIS PROJECT

 

As you said UnRaid has no readily accessible API so this is the best option out there right now.

 

I was curious as to if the Memory Leak issue that was an issue with the original repo has been addressed yet?

 

The lack of support from electricbrainuk on this project (and particularly this issue) was the death of the UUD (Ultimate Unraid Dashboard) project as sensor information was replaced easily by tools like NetData but this API's shining light is the MQTT control which is great for us Home Assistant users. 

 

I was able to get around the memory leak by having a script force the container to restart every 4 hours (yes it was that bad for me) but not having to do this may make it worth revisting UUD and finally getting a page setup for UnRaid in HA

 

 

Link to comment
4 hours ago, Foehammer1982 said:

BoKKeR,

 

THANK YOU SO MUCH FOR CONTINUING THIS PROJECT

 

As you said UnRaid has no readily accessible API so this is the best option out there right now.

 

I was curious as to if the Memory Leak issue that was an issue with the original repo has been addressed yet?

 

The lack of support from electricbrainuk on this project (and particularly this issue) was the death of the UUD (Ultimate Unraid Dashboard) project as sensor information was replaced easily by tools like NetData but this API's shining light is the MQTT control which is great for us Home Assistant users. 

 

I was able to get around the memory leak by having a script force the container to restart every 4 hours (yes it was that bad for me) but not having to do this may make it worth revisting UUD and finally getting a page setup for UnRaid in HA

 

 

 

Could you tell me more how you detected the memory leak? What was your setup? 

 

@lanky8804 did you manage to figure it out? Could you try removing the info config file and starting fresh? there is also an env variable that might show if the scraping is working:

WRITE_HTML_OUTPUT=true

 

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