Detect unavailable devices and control them once they're back online

I have several MQTT (through Zigbee2MQTT) electricity sockets around the house which default to ‘off’ state after a power cut. I’d like to be able to detect when a power cut has happened and switch these devices back on again.

Would the best way to do that be to have an automation detect when one of these devices which should always be on (e.g. the fridge/freezer) has been in an “off” state for more than a certain amount of time and switch them all back on?

- id: c860f3d1-400e-4b78-8724-00293bae3d3e
  alias: 'Auto Turn on Fridge'
  trigger:
  - platform: state
    entity_id: switch.fridge
    to: 'off'
    for: "0:01:00"
  action:
  - service: switch.turn_on
    target:
      entity_id: switch.fridge

Or a better question to ask is if they should always be on when there is power then why have them on a smart/controllable outlet in the first place? Just plug them into a hardwired outlet.

I do it for power monitoring. Also allows for compressor alerts it the fridge has not run in a specified time.

1 Like

I use temp sensors.

Yeah, I’ve thought about that but my fridge has a stainless steel skin. Not sure I want to go poking holes in it.

I use zigbee aqara sensors and they work really good for being inside of a big steel Faraday cage. I was surprised they work at all TBH.

Ok that might be worth a try. I have two repeaters right near the fridge too.

The Aqara contact sensors have an ambient sensor, so I could monitor the door and temperature.

Do you only use a sensor in the fridge compartment?

My fridge has two doors and I imagine the lithium battery won’t like the freezer temperature.

I have two refrigerators and a deep freezer that I monitor. One of the refrigerators doesn’t have a freezer and I don’t monitor the freezer section of my main refrigerator. I figure if the fridge is cold then so is the freezer. The only thing that won’t guard against is if someone leaves the freezer door open. But we would likely notice that in time.

The batteries report a low value (27% for the freezer and 34% for the refrigerators) all the time but they stay like that for a long time then fall off rapidly when they do finally die.

1 Like

Ok, I’ve ordered some Aqara contact sensors. I’ll give it a go. Thanks.

1 Like

It’s an old house, there aren’t enough sockets to go around and putting a power monitor plug on one would make the fridge stick out too much unfortunately! The same goes for most of the other devices on the smart sockets.

Also, the sockets were cheaper than the power monitoring plugs :grinning: