Trigger when noone is home

Hi,

I’m currently playing a bit with Home Assistant and recently took a look at automations. In my test scenario I want to turn off certain devices if noone is home, however I’m a bit unsure about the trigger. I’ve checked the “zone notification” template which has “person x is leaving zone y” as trigger which could be adapted for my needs. However something like “there’s nobody in zone y” as trigger would be better imho, esp when there’re more persons. I’ve tried to use a “Numeric state trigger” with the zone entity being below 1 but this doesn’t seem to work. Is there anything I’m missing or is there any better way to trigger an automation if nobody is in a specific zone?

Would also be great if you could me point to a solution that also works the other way (ie trigger when the first person enters a zone)

Thanks,
Jones

Just use state on the zone.

This is the yaml I use in an automation to track when the zone goes from “empty” to someone home:

platform: state
entity_id: zone.home
from: "0"
to: "1"

I use almost the same thing, but I test for changing from 0 to anything else (or > 0). I believe that this solution presented here might fail if 2 or more people arrive at exactly the same time (so the state goes from 0 to 2 for example) although I’ve never tested this specific situation. My children visit in pairs - so I wanted to make sure it caught this situation.