Automation to discover status of ZHA light and mark appropriatly

My ZHA bulb show connected after a few hours of mains OFF. ( need to find time to fix this implementation)
So I want to create automation for now that would send power off command to the light and change my Toggle if the command returns : Error: Failed to send request: device did not respond.
How to change this condition so it returns true using GUI. Or that is the case when a template needs to be created? Thank you.

This is the result of the power_off command:
Error: Failed to send request: device did not respond

This is the code that checking what was returned by power_off command.

 - condition: state
    state:
      - unknown
    entity_id: light.third_reality_inc_3rcb01057z_8
    for:
      hours: 0
      minutes: 2
      seconds: 0

It returns: false

Result:

result: false

## entity_id/0

Executed: April 3, 2026 at 1:33:15 PM
Result:

result: false state: 'on' wanted_state: unavailable

entity: light.third_reality_inc_3rcb01057z_8

Here is the Automation


alias: Zigbee health test
description: ""
triggers:
  - trigger: time_pattern
    id: Triggered every xxx minutes
    enabled: true
    minutes: /3
conditions: []
actions:
  - action: light.turn_off
    metadata: {}
    target:
      entity_id: light.third_reality_inc_3rcb01057z_8
    data: {}
    continue_on_error: true
  - condition: state
    state:
      - unknown
    entity_id: light.third_reality_inc_3rcb01057z_8
    for:
      hours: 0
      minutes: 2
      seconds: 0
  - action: input_boolean.turn_off
    metadata: {}
    target:
      entity_id: input_boolean.garage_second_light_status
    data: {}
mode: restart

I think you’re going about this the wrong way. Zigbee routers (most mains powered devices) shouldn’t be switched off since that will cause issues with the rest of your zigbee mesh.

The general recommendation is to avoid dumb switches with smart bulbs, since smart bulbs don’t really like it when you cut off their power.

Having said that, there’s 2 things you can try if you want to ignore my advice.

  1. Add unavailable as a state in your automation condition section. You’re currently only looking for unknown.
  2. Get rid of the automation entirely. ZHA has a specific setting to poll mains powered devices every X minutes (set to 6 hours by default iirc).
    Lower that setting to something more frequent, but I don’t recommend setting it to 3 minutes because you’ll end up spamming your mesh.

In addition to what Shadow said, this… The condition may have already been unknown when you restarted HA or saved this automation.

yes, I plan to fix the implementation to keep mains ON. Just not a priority for now. And working on Band-Aid solution now.