hassio-addons / addon-nut

Network UPS Tools - Home Assistant Community Add-ons
https://addons.community
MIT License
192 stars 37 forks source link

Disable FSD and auto-shutdown of host and/or add-on #368

Closed pspot2 closed 5 months ago

pspot2 commented 5 months ago

Problem/Motivation

I'd like to be able to disable the FSD / auto-shutdown completely for 3 reasons:

My goal is to manage the "low battery" situation myself with my own automations and notifications.

Expected behavior

If I understand the add-on documentation correctly, setting the powervalue config option to 0 is supposed to do the trick.

Actual behavior

When setting powervalue to 0, the add-on refuses to start because of the MINSUPPLIES option which is set to 1 in upsmon.conf. According to the error message, powervalue cannot be lower than MINSUPPLIES.

Steps to reproduce

Try setting powervalue to 0 and restart the add-on.

Proposed changes

Assuming that setting the powervalue to 0 is the correct way to solve my problem (e.g. completely disable setting the FSD flag and shutting down the host/add-on), I suppose the MINSUPPLIES option should be configurable as well.

If that assumption is wrong, I'm open for better suggestions on how to achieve this.

Thanks

sinclairpaul commented 5 months ago

I'm not sure there is a way to get NUT not to issue and FSD, the powervalue config is meant for multiple UPS devices.

As HA in my case runs inside a Proxmox VM, NUT can only shut down the VM itself which doesn't make any sense as this won't shutdown other VMs and the Proxmox host itself.

Why wouldn't you run NUT on the host, rather than in a container inside a VM?

The NUT add-on behaves weirdly when shutdown_host is deactivated: it goes into the shutdown/startup loop and the respective integration floods HA with events. This makes it impossible to build any meaningful automations.

The addon shouldn't restart unless the "Watchdog" functionality is enabled.

pspot2 commented 5 months ago

Why wouldn't you run NUT on the host, rather than in a container inside a VM?

I'm running a HA NUT add-on (e.g. this GitHub project). HA add-ons are containers, right?

Another reason is my second point from the motivation section: even if NUT manages to shut down the physical host, other hardware plugged into the UPS doesn't have remote interfaces for graceful shutdown.

The addon shouldn't restart unless the "Watchdog" functionality is enabled.

Watchdog is not enabled. Logs from the restart loops are attached below.

Click me ``` Jun 24 21:37:27 home-assistant addon_a0d7b954_nut[548]: {"message":"Event nut.ups_event fired."}Network UPS Tools upsmon 2.8.0 Jun 24 21:37:27 home-assistant addon_a0d7b954_nut[548]: {"message":"Event nut.ups_event fired."}{"message":"Event nut.ups_event fired."}Network UPS Tools upsmon 2.8.0 Jun 24 21:37:27 home-assistant addon_a0d7b954_nut[548]: Network UPS Tools upsmon 2.8.0 Jun 24 21:37:27 home-assistant addon_a0d7b954_nut[548]: {"message":"Event nut.ups_event fired."}Network UPS Tools upsmon 2.8.0 Jun 24 21:37:32 home-assistant addon_a0d7b954_nut[548]: s6-svscanctl: fatal: unable to control /var/run/s6/services: No such file or directory Jun 24 21:37:32 home-assistant addon_a0d7b954_nut[548]: 5.009493 Unable to call shutdown command: s6-svscanctl -t /var/run/s6/services Jun 24 21:37:32 home-assistant addon_a0d7b954_nut[548]: Network UPS Tools upsmon 2.8.0 Jun 24 21:37:32 home-assistant addon_a0d7b954_nut[548]: [20:37:32] INFO: upsmon stopped, restarting... Jun 24 21:37:33 home-assistant addon_a0d7b954_nut[548]: [20:37:33] INFO: Starting the UPS monitor and shutdown controller... Jun 24 21:37:33 home-assistant addon_a0d7b954_nut[548]: kill: No such process Jun 24 21:37:33 home-assistant addon_a0d7b954_nut[548]: 0.000000 Using power down flag file /etc/killpower Jun 24 21:37:33 home-assistant addon_a0d7b954_nut[548]: 0.000057 UPS: ups_powerwalker_800csw@localhost (primary) (power value 1) Jun 24 21:37:33 home-assistant addon_a0d7b954_nut[548]: 0.000074 [D1] debug level is '1' Jun 24 21:37:33 home-assistant addon_a0d7b954_nut[548]: 0.000132 [D1] debug level is '1' Jun 24 21:37:33 home-assistant addon_a0d7b954_nut[548]: 0.000136 Warning: running as one big root process by request (upsmon -p) Jun 24 21:37:33 home-assistant addon_a0d7b954_nut[548]: 0.000171 [D1] Saving PID 877 into /run/nut/upsmon.pid Jun 24 21:37:33 home-assistant addon_a0d7b954_nut[548]: Init SSL without certificate database Jun 24 21:37:33 home-assistant addon_a0d7b954_nut[548]: 0.001659 [D1] Trying to connect to UPS [ups_powerwalker_800csw@localhost] Jun 24 21:37:33 home-assistant addon_a0d7b954_nut[548]: 83369.671109 User upsmonmaster@127.0.0.1 logged into UPS [ups_powerwalker_800csw] Jun 24 21:37:33 home-assistant addon_a0d7b954_nut[548]: 0.002313 [D1] Logged into UPS ups_powerwalker_800csw@localhost Jun 24 21:37:33 home-assistant addon_a0d7b954_nut[548]: 0.002604 [D1] Critical UPS: ups_powerwalker_800csw@localhost Jun 24 21:37:33 home-assistant addon_a0d7b954_nut[548]: 0.002860 [D1] Shutting down any UPSes in PRIMARY mode... Jun 24 21:37:33 home-assistant addon_a0d7b954_nut[548]: 83369.672010 Client upsmonmaster@127.0.0.1 set FSD on UPS [ups_powerwalker_800csw] Jun 24 21:37:33 home-assistant addon_a0d7b954_nut[548]: 0.003366 [D1] This system is a primary... waiting for secondaries to logout... Jun 24 21:37:33 home-assistant addon_a0d7b954_nut[548]: 0.003639 Executing automatic power-fail shutdown Jun 24 21:37:33 home-assistant addon_a0d7b954_nut[548]: {"message":"Event nut.ups_event fired."}Network UPS Tools upsmon 2.8.0 Jun 24 21:37:33 home-assistant addon_a0d7b954_nut[548]: {"message":"Event nut.ups_event fired."}Network UPS Tools upsmon 2.8.0 Jun 24 21:37:38 home-assistant addon_a0d7b954_nut[548]: s6-svscanctl: fatal: unable to control /var/run/s6/services: No such file or directory Jun 24 21:37:38 home-assistant addon_a0d7b954_nut[548]: 5.007803 Unable to call shutdown command: s6-svscanctl -t /var/run/s6/services Jun 24 21:37:38 home-assistant addon_a0d7b954_nut[548]: Network UPS Tools upsmon 2.8.0 Jun 24 21:37:38 home-assistant addon_a0d7b954_nut[548]: [20:37:38] INFO: upsmon stopped, restarting... Jun 24 21:37:40 home-assistant addon_a0d7b954_nut[548]: [20:37:40] INFO: Starting the UPS monitor and shutdown controller... Jun 24 21:37:40 home-assistant addon_a0d7b954_nut[548]: kill: No such process Jun 24 21:37:40 home-assistant addon_a0d7b954_nut[548]: 0.000000 Using power down flag file /etc/killpower Jun 24 21:37:40 home-assistant addon_a0d7b954_nut[548]: 0.000088 UPS: ups_powerwalker_800csw@localhost (primary) (power value 1) Jun 24 21:37:40 home-assistant addon_a0d7b954_nut[548]: 0.000127 [D1] debug level is '1' Jun 24 21:37:40 home-assistant addon_a0d7b954_nut[548]: 0.000232 [D1] debug level is '1' Jun 24 21:37:40 home-assistant addon_a0d7b954_nut[548]: 0.000238 Warning: running as one big root process by request (upsmon -p) Jun 24 21:37:40 home-assistant addon_a0d7b954_nut[548]: 0.000295 [D1] Saving PID 910 into /run/nut/upsmon.pid Jun 24 21:37:40 home-assistant addon_a0d7b954_nut[548]: Init SSL without certificate database Jun 24 21:37:40 home-assistant addon_a0d7b954_nut[548]: 0.001812 [D1] Trying to connect to UPS [ups_powerwalker_800csw@localhost] Jun 24 21:37:40 home-assistant addon_a0d7b954_nut[548]: 83375.766304 User upsmonmaster@127.0.0.1 logged into UPS [ups_powerwalker_800csw] Jun 24 21:37:40 home-assistant addon_a0d7b954_nut[548]: 0.002652 [D1] Logged into UPS ups_powerwalker_800csw@localhost Jun 24 21:37:40 home-assistant addon_a0d7b954_nut[548]: 0.003145 [D1] Critical UPS: ups_powerwalker_800csw@localhost Jun 24 21:37:40 home-assistant addon_a0d7b954_nut[548]: 0.003422 [D1] Shutting down any UPSes in PRIMARY mode... Jun 24 21:37:40 home-assistant addon_a0d7b954_nut[548]: 83375.767342 Client upsmonmaster@127.0.0.1 set FSD on UPS [ups_powerwalker_800csw] Jun 24 21:37:40 home-assistant addon_a0d7b954_nut[548]: 0.003793 [D1] This system is a primary... waiting for secondaries to logout... Jun 24 21:37:40 home-assistant addon_a0d7b954_nut[548]: 0.004016 Executing automatic power-fail shutdown Jun 24 21:37:40 home-assistant addon_a0d7b954_nut[548]: {"message":"Event nut.ups_event fired."}Network UPS Tools upsmon 2.8.0 Jun 24 21:37:40 home-assistant addon_a0d7b954_nut[548]: {"message":"Event nut.ups_event fired."}Network UPS Tools upsmon 2.8.0 Jun 24 21:37:45 home-assistant addon_a0d7b954_nut[548]: s6-svscanctl: fatal: unable to control /var/run/s6/services: No such file or directory Jun 24 21:37:45 home-assistant addon_a0d7b954_nut[548]: 5.008153 Unable to call shutdown command: s6-svscanctl -t /var/run/s6/services Jun 24 21:37:45 home-assistant addon_a0d7b954_nut[548]: Network UPS Tools upsmon 2.8.0 Jun 24 21:37:45 home-assistant addon_a0d7b954_nut[548]: [20:37:45] INFO: upsmon stopped, restarting... Jun 24 21:37:46 home-assistant addon_a0d7b954_nut[548]: [20:37:46] INFO: Starting the UPS monitor and shutdown controller... Jun 24 21:37:46 home-assistant addon_a0d7b954_nut[548]: kill: No such process Jun 24 21:37:46 home-assistant addon_a0d7b954_nut[548]: 0.000000 Using power down flag file /etc/killpower Jun 24 21:37:46 home-assistant addon_a0d7b954_nut[548]: 0.000155 UPS: ups_powerwalker_800csw@localhost (primary) (power value 1) Jun 24 21:37:46 home-assistant addon_a0d7b954_nut[548]: 0.000179 [D1] debug level is '1' Jun 24 21:37:46 home-assistant addon_a0d7b954_nut[548]: 0.000359 [D1] debug level is '1' Jun 24 21:37:46 home-assistant addon_a0d7b954_nut[548]: 0.000369 Warning: running as one big root process by request (upsmon -p) Jun 24 21:37:46 home-assistant addon_a0d7b954_nut[548]: 0.000404 [D1] Saving PID 943 into /run/nut/upsmon.pid Jun 24 21:37:46 home-assistant addon_a0d7b954_nut[548]: Init SSL without certificate database Jun 24 21:37:46 home-assistant addon_a0d7b954_nut[548]: 0.001995 [D1] Trying to connect to UPS [ups_powerwalker_800csw@localhost] Jun 24 21:37:46 home-assistant addon_a0d7b954_nut[548]: 83381.859839 User upsmonmaster@127.0.0.1 logged into UPS [ups_powerwalker_800csw] Jun 24 21:37:46 home-assistant addon_a0d7b954_nut[548]: 0.002923 [D1] Logged into UPS ups_powerwalker_800csw@localhost Jun 24 21:37:46 home-assistant addon_a0d7b954_nut[548]: 0.003345 [D1] Critical UPS: ups_powerwalker_800csw@localhost Jun 24 21:37:46 home-assistant addon_a0d7b954_nut[548]: 0.003373 [D1] Shutting down any UPSes in PRIMARY mode... Jun 24 21:37:46 home-assistant addon_a0d7b954_nut[548]: 83381.860415 Client upsmonmaster@127.0.0.1 set FSD on UPS [ups_powerwalker_800csw] Jun 24 21:37:46 home-assistant addon_a0d7b954_nut[548]: 0.003477 [D1] This system is a primary... waiting for secondaries to logout... Jun 24 21:37:46 home-assistant addon_a0d7b954_nut[548]: 0.003527 Executing automatic power-fail shutdown Jun 24 21:37:46 home-assistant addon_a0d7b954_nut[548]: {"message":"Event nut.ups_event fired."}Network UPS Tools upsmon 2.8.0 Jun 24 21:37:46 home-assistant addon_a0d7b954_nut[548]: {"message":"Event nut.ups_event fired."}Network UPS Tools upsmon 2.8.0 Jun 24 21:37:51 home-assistant addon_a0d7b954_nut[548]: s6-svscanctl: fatal: unable to control /var/run/s6/services: No such file or directory Jun 24 21:37:51 home-assistant addon_a0d7b954_nut[548]: 5.007574 Unable to call shutdown command: s6-svscanctl -t /var/run/s6/services Jun 24 21:37:51 home-assistant addon_a0d7b954_nut[548]: Network UPS Tools upsmon 2.8.0 Jun 24 21:37:51 home-assistant addon_a0d7b954_nut[548]: [20:37:51] INFO: upsmon stopped, restarting... Jun 24 21:37:52 home-assistant addon_a0d7b954_nut[548]: [20:37:52] INFO: Starting the UPS monitor and shutdown controller... Jun 24 21:37:52 home-assistant addon_a0d7b954_nut[548]: kill: No such process Jun 24 21:37:52 home-assistant addon_a0d7b954_nut[548]: 0.000000 Using power down flag file /etc/killpower Jun 24 21:37:52 home-assistant addon_a0d7b954_nut[548]: 0.000062 UPS: ups_powerwalker_800csw@localhost (primary) (power value 1) Jun 24 21:37:52 home-assistant addon_a0d7b954_nut[548]: 0.000079 [D1] debug level is '1' Jun 24 21:37:52 home-assistant addon_a0d7b954_nut[548]: 0.000134 [D1] debug level is '1' Jun 24 21:37:52 home-assistant addon_a0d7b954_nut[548]: 0.000138 Warning: running as one big root process by request (upsmon -p) Jun 24 21:37:52 home-assistant addon_a0d7b954_nut[548]: 0.000172 [D1] Saving PID 976 into /run/nut/upsmon.pid Jun 24 21:37:52 home-assistant addon_a0d7b954_nut[548]: Init SSL without certificate database Jun 24 21:37:52 home-assistant addon_a0d7b954_nut[548]: 0.001559 [D1] Trying to connect to UPS [ups_powerwalker_800csw@localhost] Jun 24 21:37:52 home-assistant addon_a0d7b954_nut[548]: 83387.953601 User upsmonmaster@127.0.0.1 logged into UPS [ups_powerwalker_800csw] Jun 24 21:37:52 home-assistant addon_a0d7b954_nut[548]: 0.002485 [D1] Logged into UPS ups_powerwalker_800csw@localhost Jun 24 21:37:52 home-assistant addon_a0d7b954_nut[548]: 0.003068 [D1] Critical UPS: ups_powerwalker_800csw@localhost Jun 24 21:37:52 home-assistant addon_a0d7b954_nut[548]: 0.003098 [D1] Shutting down any UPSes in PRIMARY mode... Jun 24 21:37:52 home-assistant addon_a0d7b954_nut[548]: 83387.954562 Client upsmonmaster@127.0.0.1 set FSD on UPS [ups_powerwalker_800csw] Jun 24 21:37:52 home-assistant addon_a0d7b954_nut[548]: 0.003613 [D1] This system is a primary... waiting for secondaries to logout... Jun 24 21:37:52 home-assistant addon_a0d7b954_nut[548]: 0.003819 Executing automatic power-fail shutdown Jun 24 21:37:52 home-assistant addon_a0d7b954_nut[548]: {"message":"Event nut.ups_event fired."}Network UPS Tools upsmon 2.8.0 Jun 24 21:37:52 home-assistant addon_a0d7b954_nut[548]: {"message":"Event nut.ups_event fired."}Network UPS Tools upsmon 2.8.0 Jun 24 21:37:57 home-assistant addon_a0d7b954_nut[548]: s6-svscanctl: fatal: unable to control /var/run/s6/services: No such file or directory Jun 24 21:37:57 home-assistant addon_a0d7b954_nut[548]: Network UPS Tools upsmon 2.8.0 Jun 24 21:37:57 home-assistant addon_a0d7b954_nut[548]: 5.008347 Unable to call shutdown command: s6-svscanctl -t /var/run/s6/services Jun 24 21:37:57 home-assistant addon_a0d7b954_nut[548]: [20:37:57] INFO: upsmon stopped, restarting... Jun 24 21:37:58 home-assistant addon_a0d7b954_nut[548]: [20:37:58] INFO: Starting the UPS monitor and shutdown controller... Jun 24 21:37:58 home-assistant addon_a0d7b954_nut[548]: kill: No such process Jun 24 21:37:58 home-assistant addon_a0d7b954_nut[548]: 0.000000 Using power down flag file /etc/killpower Jun 24 21:37:58 home-assistant addon_a0d7b954_nut[548]: 0.000087 UPS: ups_powerwalker_800csw@localhost (primary) (power value 1) Jun 24 21:37:58 home-assistant addon_a0d7b954_nut[548]: 0.000102 [D1] debug level is '1' Jun 24 21:37:58 home-assistant addon_a0d7b954_nut[548]: 0.000157 [D1] debug level is '1' Jun 24 21:37:58 home-assistant addon_a0d7b954_nut[548]: 0.000180 Warning: running as one big root process by request (upsmon -p) Jun 24 21:37:58 home-assistant addon_a0d7b954_nut[548]: 0.000216 [D1] Saving PID 1009 into /run/nut/upsmon.pid Jun 24 21:37:58 home-assistant addon_a0d7b954_nut[548]: Init SSL without certificate database Jun 24 21:37:58 home-assistant addon_a0d7b954_nut[548]: 0.001611 [D1] Trying to connect to UPS [ups_powerwalker_800csw@localhost] Jun 24 21:37:58 home-assistant addon_a0d7b954_nut[548]: 83394.045456 User upsmonmaster@127.0.0.1 logged into UPS [ups_powerwalker_800csw] Jun 24 21:37:58 home-assistant addon_a0d7b954_nut[548]: 0.002553 [D1] Logged into UPS ups_powerwalker_800csw@localhost Jun 24 21:37:58 home-assistant addon_a0d7b954_nut[548]: 0.003020 [D1] Critical UPS: ups_powerwalker_800csw@localhost Jun 24 21:37:58 home-assistant addon_a0d7b954_nut[548]: 0.003270 [D1] Shutting down any UPSes in PRIMARY mode... Jun 24 21:37:58 home-assistant addon_a0d7b954_nut[548]: 83394.046558 Client upsmonmaster@127.0.0.1 set FSD on UPS [ups_powerwalker_800csw] Jun 24 21:37:58 home-assistant addon_a0d7b954_nut[548]: 0.003724 [D1] This system is a primary... waiting for secondaries to logout... Jun 24 21:37:58 home-assistant addon_a0d7b954_nut[548]: 0.004027 Executing automatic power-fail shutdown Jun 24 21:37:58 home-assistant addon_a0d7b954_nut[548]: {"message":"Event nut.ups_event fired."}Network UPS Tools upsmon 2.8.0 ```
sinclairpaul commented 5 months ago

Jun 24 21:37:32 home-assistant addon_a0d7b954_nut[548]: s6-svscanctl: fatal: unable to control /var/run/s6/services: No such file or directory Jun 24 21:37:32 home-assistant addon_a0d7b954_nut[548]: 5.009493 Unable to call shutdown command: s6-svscanctl -t /var/run/s6/services

Then that's an issue we should look at, unfortunately it's the first report I've seen..

As per the NUT documentation The whole point of UPS software is to bring down the OS cleanly when you run out of battery power. Everything else is roughly eye candy. https://networkupstools.org/docs/user-manual.chunked/Configuration_notes.html#UPS_shutdown

My view is that you should control shutdown events at the base operating system (Proxmox in your case), virtualising and running containers means that you have no visibility to the state of the OS. The addon is designed for those without the knowledge to configure it themselves.

pspot2 commented 5 months ago

As per the NUT documentation The whole point of UPS software is to bring down the OS cleanly when you run out of battery power. Everything else is roughly eye candy. https://networkupstools.org/docs/user-manual.chunked/Configuration_notes.html#UPS_shutdown

Yes, I've read that documentation. This is a rather narrow view, highlighting just one of the use-cases. Imagine you'd like to automatically start a backup generator based on the "low battery" event. In this case you do NOT want to shut anything down, plus you want to have a customizable hook and not a pre-defined action that you cannot change.

My view is that you should control shutdown events at the base operating system (Proxmox in your case), virtualising and running containers means that you have no visibility to the state of the OS. The addon is designed for those without the knowledge to configure it themselves.

I could certainly give it a try, but from your earlier responses I understood that NUT doesn't offer control over FSD and auto-shutdown irrespective of whether the software is packaged as a container or runs natively.

sinclairpaul commented 5 months ago

The addon wraps the NUT software, this isn't something we are likely to implement, so I will close this out.

starsoccer commented 5 months ago

+1 have the same request. Id like the ability to not force a shutdown simply because the UPS is low.

gyp5y commented 4 months ago

Same here. My UPS is modified with much bigger battery than it ever seen in production so it runs very long time in critical state. It would be nice to still got data from it.