How to power cut proof your appliances

i made a home automation project with openhab and nodemcu it uses 2 relays, it works like a charm but my problem is when the power goes off nodemcu restarts on boot and resets the relays to off i want it to remember the state when it reboots. otherwise it is very inconvenient to switch it on and then off again from the basic UI.

You’ll want to look into persistence for the openHAB remembering part.

A System started triggered rule can copy restored-on-startup states to devices.

Getting a restore to your relays if only the nodemcu is powered off/on depends more on how they communicate. Is there some way OH can recognize when that happens? Otherwise you can’t take any action.

I would advise against reseting a relay to on after a power cut for safety reasons. Imagine that you are not home for a while and there is a power cut. Your appliance will turn on and create a fire risk.

1 Like

Would a low voltage UPS, to maintain your OH server not be an answer?

Or in my use case.

I have an APC SmartXL 2200 with 54 AH battery array, which maintains…

  • Both circuits of lighting.
  • Central heating & on-demand water heating.
  • OH server & VDSL router.

Recently, I’ve learnt how to retrieve the APC data and display it in OH, so my next step is to send a notification when the UPS is in action and another when the battery reserve is low.

Thank you so much for the reply guys i have set the mqtt to retain the messages so that the appliance goes back to its last state before the power cut. This solution works fine for me