I have used that exact UPS. It works with NUT.
It will run for at least an hour with a 37W load.
I have used that exact UPS. It works with NUT.
It will run for at least an hour with a 37W load.
HA supports all UPSes supported by NUT. NUT supports HID UPSes.
Thanks Tom. I got one myself now on Amazon Prime day. I struggled a bit with the “Network UP Tools (NUT)” until I found it was both an Add-On AND an Integration and I needed both!
I’ve got 5 entities available (Battery charge, Load,Voltage, Status and Status Data) and 15 not available.
So whilst I can monitor the voltage, say, and shutdown HA gracefully if it starts looking low, if the mains power comes back on before the UPS actually cuts out HA will not reboot. I have the BIOS set to boot on power-up.
It seems to me that I’m better off doing nothing and letting HA die with the UPS; then at least it will come back on again. Not very graceful.
Thoughts?
SoC (state of charge) will be a better sensor to monitor than voltage.
For your very small load I’d disable the shutdown command and automate shutting down home assistant at SoC = 10%. That way you would be unlucky if the power came back before the UPS shutdown, but yeah it could still happen. Not sure how to get around that.
Is there a recommendation which UPS to purchase when the task is „only“ to keep alive the HA machine (NanoPi running at 5V 4W) and the Internet AP (FritzBox running at 12V 5W) for something like 1h and integrating into HA? My first idea was one of those 18650-UPS-boxes sold for cheap but presumably they will not broadcast their status in any way
Yes. the boxes for cheap were my go-to solution and, yes. they have no monitoring of the status of the “UPS”. They are just big battery banks with low voltage output. Think of it as an electronics project waiting to happen.
To separate the low-voltage battery packs from the mains voltage “big” UPSes I have created a new thread for those solutions: Low-voltage UPS array with at least outage notification? - #4 by Cabletwister
Fully aware of the drawbacks of those solutions.
You can activate a bunch more diagnostic entities in any NUT device. Go to the device page and see the hidden disabled entities then enable them.
I can see the realtime load and power factor! So nice.
After three power losses in ten minutes toasted my raid and being a true to form home assistant cheapskate, I came up with a way of monitoring power status i.e if there is mains power or not.
If anyone is interested in getting a cheap UPS (not monitored) solution to shutdown in the event of a power failure, then here’s my WIP
It’s hardly enterprise grade but it will shutdown (once I write that bit) after a predetermined time. This is paired with the cheapest POS UPS I could find online, 800VA with a 80 watt load =~ 6-8 mins, so the shutdown script will run after five minutes if the plug status goes unavailable and will cancel if the state changes from unavailable to anything else i.e. on/off.
The way it works:
HA script uses button.press
to ping a zigbee plug every minute, automations monitor this state and trigger the shutdown or cancel shutdown scripts. I prefer using automations to trigger scripts rather than automations alone since (unless this has changed recently), a step failing in an automation breaks the rest of the automation, scripts will run if a step fails.
automation.yaml
# Ping Zigbee plug every minute
- id: 'mains_power_plug_ping'
alias: mains power ping power plug
description: Ping Z-Wave power plug every minute
trigger:
- platform: time_pattern
minutes: "/1"
condition: []
action:
- service: button.press
target:
entity_id: button.heater_ping
data: {}
mode: single
# Trigger shutdown script if power lost
- id: 'mains_power_lost'
alias: Mains Power Lost
description: Shutdown after 5 mins if power is lost
trigger:
- platform: state
entity_id:
- switch.heater
to: unavailable
for:
hours: 0
minutes: 1
seconds: 0
condition: []
action:
- service: script.mains_power_lost_script
- service: input_boolean.turn_off
target:
entity_id:
- input_boolean.mains_power
data: {}
mode: single
# Cancel shutdown script if power restored
- id: 'mains_power_restored'
alias: Mains Power Restored
description: Reset Input Boolean cancel Shutdown
trigger:
- platform: state
entity_id:
- switch.heater
from: unavailable
for:
hours: 0
minutes: 3
seconds: 0
condition: []
action:
- service: script.mains_power_restored_script
- service: input_boolean.turn_on
target:
entity_id:
- input_boolean.mains_power
data: {}
The scripts called by the automations:
scripts.yaml
mains_power_lost_script:
alias: "Mains Power Lost Script"
sequence:
- service: input_boolean.turn_off
target:
entity_id:
- input_boolean.mains_power
- variables:
start: 5
end: 0
step: -1
- repeat:
until:
- condition: template
value_template: >-
{{
(step == 0) or ((step < 0) and
(start + step * ( repeat.index - 1)) <= end) or
((step > 0) and
(start + step * ( repeat.index - 1)) >= end)
}}
sequence:
- variables:
current: '{{ start + step * ( repeat.index - 1 ) }}'
- service: logbook.log
data:
name: countdown.test
message: "Power lost {{current}} minutes until system shutdown"
- service: system_log.write
data:
logger: countdown.test
level: warning
message: >-
{{ 'Loop %d, val=%d, step=%d, test=%d' % (repeat.index, current,
step, (step==0) or ((step < 0) and current < end) or ((step > 0)
and current > end) ) }}
- service: notify.alexa_media_desk
metadata: {}
data:
message: "Power lost {{current}} minutes until system shutdown"
title: '!!! POWER ALERT !!!'
- service: notify.mobile_app_cph2025
metadata: {}
data:
message: "Power lost {{current}} minutes until system shutdown"
title: "!!!! POWER LOST !!!!"
# - service: notify.rods_join
# data:
# message: "Power has been lost - system will shutdown in {{current}} minutes"
# title: "!!!! POWER LOST !!!!"
- delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 500
- service: system_log.write
data:
logger: countdown.test
level: warning
message: "SHUTDOWN STARTED"
- service: notify.alexa_media_desk
metadata: {}
data:
message: "SHUTDOWN STARTED Power has been lost"
title: 'Shutdown NOW !!! POWER ALERT !!!'
- service: notify.mobile_app_cph2025
metadata: {}
data:
message: "SHUTDOWN STARTED Power has been lost"
title: "Shutdown NOW !!!! POWER LOST !!!!"
mode: restart
mains_power_restored_script:
alias: "Mains Power Restored Script"
sequence:
- service: script.turn_off
target:
entity_id:
- script.mains_power_lost_script
data: {}
- service: input_boolean.turn_on
target:
entity_id:
- input_boolean.mains_power
data: {}
- service: notify.alexa_media_desk
metadata: {}
data:
message: "Power RESTORED"
title: '!!! POWER RESTORED !!!'
- service: notify.mobile_app_cph2025
metadata: {}
data:
message: "Power RESTORED"
title: "!!!! POWER RESTORED !!!!"
- service: notify.rods_join
metadata: {}
data:
message: "Power RESTORED"
title: "!!!! POWER RESTORED !!!!"
- service: system_log.write
data:
message: "Power Restored\n Shutdown Cancelled"
level: info