Retry Mechanism for Zigbee Devices in Case of Failed

Sometimes, when I turn off a Zigbee device (that acts as a router), it doesn’t actually turn off. Is there a method to ensure that if an automation or manual action doesn’t work correctly, it gets retried?

The idea behind two-way communication is that the status is correctly reported back. If this fails, I would like it to be retried automatically (without having to create multiple duplicate actions, which would feel more like a “fire and forget” approach).

Home Assistant knows what the status of the device should be. If that status doesn’t get confirmed, I would like Home Assistant to retry it a few more times.

Without having to build a separate repeat function for each action, as described here: Confirm Zigbee Switch Automation and Retry Every X min on Fail

Not clear from your post whether HA shows the device as on or off.

It HA is aware of it’s actual state (ie still on having failed to turn off) there’s a custom integration which might help:

But Zigbee will have repeated the command many times already (and there should be an error in the log).

If HA thinks the device has successfully turned off, I’m not sure if there’s anything you can do about it.

Either way, you might be better off investigating why the device is failing.

I’ve been investigating this issue in detail.

When my back door is normally closed, everything works fine — the MESH network finds its way to the outdoor sensors without problems.

However, when the back door stays open for a longer period (which happens more often now with the warmer weather), the MESH network starts to “optimize” itself, finding a lower-resistance path through the open door. But once the door is closed again, that newly formed path collapses, and it takes quite a while before the network re-stabilizes.
This behavior repeats itself every time.

And yes — the door really does block the signal. Even WiFi barely reaches the outside when the door is shut.

What I’d like to have is some kind of queue or retry mechanism.
Because what happens now is: I turn off the light when I go to bed, but the next morning the light is still on — the command was lost due to the temporary mesh failure.

What I’ve been experimenting with:

I’m playing around with checking service call events like this:

alias: Check lamp status after command
trigger:
  - platform: event
    event_type: call_service
    event_data:
      domain: light
      service: turn_on
  - platform: event
    event_type: call_service
    event_data:
      domain: light
      service: turn_off

When a light’s status is changed, this event (trigger.event.data) returns something like:

{'domain': 'light', 'service': 'turn_on', 'service_data': {'entity_id': 'light.tz3000skuggeg3ts0012'}}

So in theory, you could check if light.tz3000skuggeg3ts0012 is still OFF two minutes after the ON command, and if so, send the ON command again.
I just don’t know if there’s a cleaner way to access this — or whether Home Assistant splits commands like Bash or Python does. Or would I need to handle this in JavaScript?