Hello all.
Where I leave we have many power failures and when power comes back, all lights (yeelight bulbs and ceiling lights) turn on.
I am trying to find a way to handle it.
I have a shelly plug and I was thinking to make the below automation.
- alias: Auto close Lights after power failure
initial_state: true
trigger:
- platform: state
entity_id: switch.shelly_tv_plug
from: unavailable
to: 'on'
condition: []
action:
- delay: 00:01:00
- data:
entity_id: group.all_lights
service: light.turn_off
- service: notify.mobile_app_mi_mix_3
data_template:
message: '{{states.sensor.counter_lights_on.state}} lights turned off 1'
(I have created a group for all the lights and a sensor that counts how many lights are on.)
I run HA in NUC which is plugged in UPS.
The issues that I found with the above automation, are:
If the power outage lasts longer than what UPS can stand, automation will not work.
I would prefer to check the status of lights when pluged turned to unavailable and return lights to the same status, 1 minute after status of plug changes to âonâ. I say 1 minute so as to be sure that all devices are connected to the network.
One way I have handled this in the past (and Iâve seen others do this too), is to create a âcanaryâ light. Basically take a light that you never use. Maybe put it in a room thatâs not used, or in my case I put it in an unused closet. Turn the light off with HA, then set an automation that if that light turns on (probably due to power outage), then turn it and every other yelight off
Here is mine
- alias: Zigbee Light Reset After Power Outage
trigger:
- platform: state
entity_id:
- light.canary_hue_bulb
to: 'on'
condition:
- condition: numeric_state
entity_id: sensor.ha_runtime_in_minutes
above: 2
- condition: or
conditions:
- condition: state
entity_id: input_select.house_mode
state: 'Night'
- condition: state
entity_id: input_select.house_mode
state: 'Away'
action:
- service: light.turn_off
entity_id:
- light.bedroom_lamp_one
- light.bedroom_lamp_two
- light.bedroom_tv_lights
- light.ashleys_room_lamp
- light.guest_bedroom_lamp
- light.frog_couch_backlight
- light.all_downstairs_color_lights
- light.office_lamp_two
- light.office_lamp_one
- light.canary_hue_bulb
Some of these are light groups, as well. In my case i mostly cared about this at night, where Iâd be worken up with all my lights on
In my case, I have a few WiFi Smart Power strips, and when there is power outage, they default to âOffâ state.
I was wondering, and I hope someone can help me there, if there is a way to have them turn back on in case of the power failure. This would be best if it could be added to the entityâs own attributes:
State attributes (YAML, optional)
friendly_name: Switch1
icon: 'mdi:power-plug'
I was thinking something along these lines:
-poll the device every few minutes (5 minutes would totally be fine, since I have a power generator that kicks in within a minute of the power outage).
-Yes: do nothing
No: turn on
I have my Pi with HASS and all of my network attached to a bunch of small UPS units, so those remain on at all times.
or even better, if there was a way for HASS to check the last state just before a disconnect from the network for the device (which would mean that whatever state it was âonâ or âoffâ) return the device to that same state one it reconnects to the network.
I ran into this issue last nightâŚat 3am. Lights came on and woke up half the house. Was a quick blip that did not seem to trip my UPS. So I doubt that HA even saw the issue. So is there a way to set the default state of Zigbee after power loss? I know you can do something like that with Z-Wave?
I like this idea.does it still work?
My problem is that with a virtual box I need to restart the home assistant completely after a power loss. Looks like not all usb device are working. Is there a way to also restart HA after this?
Every attempt/implementation seen so far (including this topic) might suite individual use-cases - but don´t work for everyone unfortunately.
Example: what if you only had a partial power outage which affected only one room/light? With those implementation examples seen here every other light in the house would also get turned off, even if they didn´t suffer a power outage and even worse if they were on before.
In my opinion the best option would be to set in on the source, so depending on the device integration e. g. directly in deCONZ, MQTT etc.
E. g. for deCONZ here´s what I´ve found recently: