#Power Off TrueNAS when power goes out with Athom smart plug for sensing with HA

23 messages · Page 1 of 1 (latest)

cosmic elbow
#

So I am using home assistant just as a means to an end (for now). I have 2 esphome athom smart plugs. My UPS is dumb so I was thinking that I plug the UPS into the wall through the smart plug and when it goes offline due to a power outage, home assistant will send a shutdown to the trueNAS server via its REST API.
https://www.athom.tech/blank-1/uk-v2-plug-for-esphome

I am a complete noob when it comes to smart home stuff so if something here sounds stupid then is probably so I am all ears for alternatives. I have manually HA installed on the TN server in an ubuntu server VM that has pihole, unbound and tailscale.
Now some quirks. It seems when the smartplug loses power, home assistant doesn't show it as unavailable. It reports the last received value until it comes back online and then goes unavailable for a second.
The power sensor reports every 5 seconds so I was thinking if the sensor data is stale for more than 30 seconds it will send the shutdown then unless you guys know how to to fix the thing not reporting as unavailable.

The solution needs to be pretty immediate. I might get a Pi in the future that will always stay online and work as a kvm. Thanks for reading.

zealous ore
#

I don't know how good the athom sensors are, but a more effective method might be to have one plugged in to something that always consumes some power and assume a power cut if that goes to 0 for a few seconds
That said, isn't the point of the UPS to keep your server running when there's a power cut? it seems counterintuitive to turn it off when there is one

cosmic elbow
#

I guess if the smart plugs are bad I could also do it by pinging the second wireless AP in my house and send a shutdown from HA if it doesn't respond for more than 30 seconds.

zealous ore
#

Those plugs also seem to just be running esphome so you could probably change their behaviour on losing power, but not sure how to do that

jagged forum
#

Why not just use the UPS service in TrueNAS itself? This is already baked-in functionality. Not sure why you would need a smart plug.

cosmic elbow
#

I am not sure how the UPS service in truenas is going to know it is now on battery and not on wall power

#

My UPS doesn't have any management features.

jagged forum
#

It doesn't need any management features. Basically, the upsd service can detect when power is coming from battery or mains.

cosmic elbow
#

It can tell if it's on battery?

jagged forum
#

Does the UPS have a USB port on it? If so, then you can connect it to TrueNAS and use the upsd service to monitor it.

cosmic elbow
cosmic elbow
#

It is difficult to find a proper online or line interactive UPS with shutdown features here

jagged forum
#

Ah gotcha. Sorry about that. Even the cheap ones here have a mgmt interface. 😔

cosmic elbow
jagged forum
cosmic elbow
#

Can I throw in just about any SLA battery or are they picky about it?

jagged forum
#

A friend of mine recommended mightymax batteries as replacements.

cosmic elbow
jagged forum
#

No. If you know the brand and model, you can just google replacement batteries for it.

cosmic elbow
cosmic elbow