Delay in zone.home incrementing number of persons home

I have an automation that opens the garage door when I ender the home zone, by triggering a script:

  - action: script.open_garage

In the script, I make sure someone is home before opening the garage:

  - condition: numeric_state
    entity_id: zone.home
    above: 0

The problem I’m having as that zone.home increments to 1 several seconds after I enter the home zone and the script is executed (so the garage doesn’t open). I can verify these times in the traces and zone.home history. There was a 4-second delay last time. I put a sleep in the automation, but that seems like a bandaid. Was wondering if anyone else has run into this and if it’s a known thing.

-Ryan

While I agree this should not be, testing this will always remain a race condition because you never know which entity changes first. Why do you test zone home? If the trigger is you are home, then someone is home. So to avoid the race condition, you should not check the same thing in two different ways.

Ok, at least it’s known, thanks. I created a script with the check so it can be used elsewhere if needed, but I never want to accidentally trigger something that opens the garage when we’re not home.

That does make sense. One always succeeding solution would be to only trigger the scene when you know both are true. That is a bit of a hassle, because you need to trigger on you coming home and trigger on zone home going non zero, and test for both (assuming other people should not trigger the garage door).

Another option is to trigger on zone home, and look inside the persons attribute if you are a ong the ones home. But that would also be rather awkward.