Power Outage Oddities

Hey all. First post here…

Last night, we lost power at my house for about 10 minutes (despite HA showing only 16 seconds? see attached image). When I got up this morning, a LOT of my HA devices had toggled states. Most biggest concern was my gas fireplace had come on in the night.

I think I understand what happened, but not how to solve the problem. Every device that “toggled” has a Shelly 1 Gen 4 relay controlling it. It’s mostly lights, but also my gas fireplace. When I installed them, I wired the old switches as inputs to the Shelly device, and if someone toggles the physical switch - I toggle the Shelly output - all via an automation, of course.

Looking at the history of one of the switch inputs in the Shelly and it went from “On” → “Unavailable” → “On” (see attached pic). So, when the power was out, it went to an Unavailable state (and my HA instance was offline too, since I don’t have a UPS). I assume my automation trigged due to leaving the “Powered” state, and then coming back into the “Powered” state?

alias: Toggle Fireplace Flames
description: ""
triggers:
  - type: powered
    device_id: ef33bf843f8d41da29db7efb80da16e7
    entity_id: 2c1e3712d507cf4e77d6ea0f06823953
    domain: binary_sensor
    trigger: device
  - type: not_powered
    device_id: ef33bf843f8d41da29db7efb80da16e7
    entity_id: 2c1e3712d507cf4e77d6ea0f06823953
    domain: binary_sensor
    trigger: device
conditions: []
actions:
  - action: switch.toggle
    metadata: {}
    target:
      device_id: ef33bf843f8d41da29db7efb80da16e7
    data: {}
mode: single

Wondering if anyone has seen this, and a good fix. Obviously my gas fireplace can’t come on anytime power is restored after a loss…

Off topic, I’ve had HA for about a month and am loving it. I’m a programmer at heart, so jinja is very enjoyable to me. Reminds me of server side scripting in PHP waaaaay back in the day…

TIA!
PinJim

You should be able to change the power on mode of the Shelly device from the Shelly web ui.

1 Like

I would recommend not to use a HA automation here, just configure directly in the Shelly Web UI “edge mode” for the input, see

1 Like

I would recommend using entity-id’s instead of device-id’s and then use not_from unavailable in the trigger.

Adapt as required…

2 Likes

I use this with so many triggers. It is an under used feature, probably because it requires switching the trigger editor to yaml view so a lot of people don’t realize it is an option.

1 Like

Thanks, I’ll give it a shot!

I have the Shelly stuff set up to default to off after a power outage. Before HA, Shelly was doing the toggling too. But after I put in HA, I move it there. I guess I never considered leaving the toggle logic within the Shelly stuff. If I do that, would it still work without cloud access?

I moved it to HA because I’m doing to much more with those outputs. My fireplace is now Alexa enabled, has a “auto-start” at X time for cold morning wake ups, I new delay turning off the fan for 15 minutes after the burner goes off, etc. Who knew one could have that much fun with a fireplace?

Yes. This works without the cloud. You can get to the Shelly UI from HA. Go to the device using the Shelly integration page and click on the “visit” icon. This takes you to the UI and you can configure the power on option as well as other options

1 Like