Trigger to determine if anybody is at home (zone.home.persons) does not trigger

Hello,

After more than a decade of using node-red for automations, I’m changing to using automations.

One of the automations that works flawlessly in Node-Red but not in the HA Automations, is detecting if anybody is at home or not

In pseudo code:
If zone.home.persons >0 (or becomes >0) #Then apparently someone is at home
Then Do some stuff
If zone.home.persons =0 (or becomes 0) #apperently nobody is home
Then do some other stuff

In the automation the trigger just doesn’t trigger. Both the state as the numeric state trigger (with or without quotes)

The state (in developer tools) actually changes to the number of people at home.

Can somebody help?

Regards,
Jeroen

For these kind of things it is always good to see the yaml of your automation, properly formatted using </> so we can change it to work. For this however, we can probably do without.

The persons attribute is a list of names of persons in the zone. The state itself is the count. So do not test for an attribute, do not supply any. Test the zone itself for the number.

1 Like

Edwin,

Thank you very much. You led me in the right direction.
I did use the persons attribute but should have left the attribute blank.

Now it works like a charm.

Thanks for your switft answer!

just a comment on that, my automation recently stopped working that was checking exactly for this zone.home entity. Has there been an update that requires to change anything here? Thanks in advance

Edit: nevermind, i pasted the wrong automation, heres the correct one:

- id: '1727380441997'
  alias: SomebodyHome
  description: ''
  triggers:
  - entity_id:
    - zone.home
    attribute: persons
    for:
      hours: 0
      minutes: 0
      seconds: 0
    from: '0'
    trigger: state
  conditions: []
  actions:
  - action: switch.turn_on
    target:
      label_id: allmotionsensors
    data: {}
  - action: climate.set_temperature
    metadata: {}
    data:
      temperature: 20
    target:
      label_id: allthermostats
    enabled: false
  - action: input_boolean.turn_on
    target:
      entity_id:
      - input_boolean.hometest
    data: {}
  - action: notify.notify
    metadata: {}
    data:
      message: Somebody entered home
  mode: single

looking at it again it seems i was checking for the attribute persons, this was working fine before though. Probably a recent update removed that support. Anyway, i have corrected my yaml as follows now and will check it asap:

- id: '1727380441997'
  alias: SomebodyHome
  description: ''
  triggers:
  - trigger: numeric_state
    entity_id:
    - zone.home
    for:
      hours: 0
      minutes: 0
      seconds: 10
    above: 0
  conditions: []
  actions:
  - action: switch.turn_on
    target:
      label_id: allmotionsensors
    data: {}
  - action: climate.set_temperature
    metadata: {}
    data:
      temperature: 20
    target:
      label_id: allthermostats
    enabled: false
  - action: input_boolean.turn_on
    target:
      entity_id:
      - input_boolean.hometest
    data: {}
  - action: notify.all_devices
    metadata: {}
    data:
      message: 'Somebody entered home'
  mode: single

The attribute persons is a list of the person entities in the zone… it will never be '0'.

1 Like

Thanks for the remark!
Again this error did not strike my eyes since it was working perfectly until a few days ago when i updated to the latest version.

That attribute hasn’t changed in years… so either someone changed the automation or it wasn’t working previously. :man_shrugging: