Tuya lights stay on after a power outage

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