Automation with condition take about 5 seconds longer to complete

Hey Team,
Anyone know why automations that have a condition check cause issues with the time it takes to run?

I have some different automations all triggered on motion detected.

The automation without a condition in it, goes from motion detected to lights completely on in about 2.5 seconds.

The 2 other ones which have trigger on motion, check if the light is not turned on and if not turn them on,
It runs through this, and says “5 seconds later” and then they are turned on.
Total run time about 6.8 seconds. (Which is obviously not good when you want lights to turn on walking into a dark area)

There is no delays or transition times etc set.

Its a simple automation.
Trigger by movement detected.
Check if the light is not turned on
Turn on light group

Any ideas on what could be causing this and how to fix it?

If I remove the condition it goes roughly 5 seconds faster. Im sure this cannot be an expected experience, but cannot seem to find anything related.

How are the light and sensor being integrated into Home Assistant?

Doesn’t answer the question, but there’s no need to check whether the lights are already on. If they are, another turn on command makes no difference.

Lights are via matter, motion sensor is via Z2M.

I had the check in place as if someone changed the brightness manually and the lights were already on and it triggers it again it would reset the brightness.

You can look at the trace of the automation and see which step is using up all of the time. Checking the state of an entity shouldn’t really take any noticeable time at all, since it’s only supposed to check HA’s internal representation of the state, not poll the actual device. If it is taking time, it could represent a bug in the integration you’re using, possibly.

Perhaps post the actual yaml code and some info about what you see in the trace.

Thats what I figured too. But as soon as i remove the test condition it completes a lot quicker.

When its in there it has the test condition then “Lights turn on” then 5 seconds later then light commands being sent.

But when the test condition is not in there, it gets to the light turn on commands a lot quicker. :S

Maybe it is just HA sending it slowly. seems to be hit and miss since removing the condition. Sometimes its within a couple seconds, other times its 5+ seconds to turn the lights on.

Delay could be caused by the lookup to the Matter network? I havent actually played with them myself, I have some but not used them yet.

I have a similar setup running with lights on ZHA and the Presence sensor on Z2M and Im not seeing any delay, the moment I walk in the room, lights come on and my Windows Dashboard on the wall wakes up instantly.

I have a condition of time lookup though as I have a different automation with different light level for late at night, so Im not polling if the light is already on, Im polling the time.

Maybe if you have a zigbee light, test the same Automation but with all Zigbee setup and see if the delay is still present.

Edit: I just duplicated your automation, so lookup light status instead of the time and if light is off, then turn on, and I see no delay, its instant turn on.

Thanks for the info.

Ill make one that uses my zigbee bulbs and see if that has the same delay problem or not, that might help narrow down the cause

Yea seems to be a HA and matter problem.

The zigbee bulbs the automation completes in like 0.1 seconds.

The Matter 3-7 seconds :frowning:

Thats good to know, hopefully you can figure out why, could be a controller thing or could just be the device/light thats causing it.

I haven’t bothered with the Matter gear as yet and was trying to stay with Zigbee as it just works so well for me, and looks like the same for you.

1 Like

FYI since the most recent HA updates 2.4.1
OTBR 2.5.1 and Matter 5.5.1

These are much better with this version but still hit and miss, and if there is a lot of traffic like turn 24 lights (8 per room) in quick succession, by the 3rd room it gets a 4-7 second delay. so hopefully some fixes int he future for this