Hi. I have a few Tuya/SmartLife bulbs and Home Assistant running on a RaspberryPi 3B+. I encounter an issue where all Tuya lights remain on after a power outage. On reading their FAQ, their bulbs don’t have a ‘memory function’ to restore state after an outage. Is it possible to use Home Assistant as the ‘memory function’? The RaspberryPi is connected to a UPS, and is usually on by the time power is restored.
1 Like
I have fixed it with the following Blueprint. It requires a device_tracker enabled. Since the host machine of HomeAssistant is on a UPS, it can ‘see’ when other devices go offline. When the Canary Device goes from not_home
(due to power loss) to home
(power restoration) for 1 minute, the action is triggered.
blueprint:
name: Turn off Smart Life bulbs
description: Turn off Smart Life bulbs when power has returned after an outage.
domain: automation
input:
canary_device:
name: Canary Device
selector:
entity:
domain: device_tracker
target_light:
name: Target Lights
selector:
target:
entity:
domain: light
integration: tuya
mode: restart
max_exceeded: silent
trigger:
platform: state
entity_id: !input canary_device
for: "00:01:00"
from: "not_home"
to: "home"
action:
- service: light.turn_off
target: !input target_light
Was inspired by Restore lights to status they had before power outage
I’m looking at this several years after the solution was posted. Isn’t there a way to do this without device tracker, and instead just look at the light’s state which should be marked as unavailable?