Want to run something when neither of the 2 mobiles are in the zone

Hi,

I want to run an automation task when neither of the 2 mobile phones are in the zone. I’ve created an automation task with the following config:

condition: not
conditions:

  • condition: zone
    entity_id: device_tracker.mobile1
    zone: zone.home
  • condition: zone
    entity_id: device_tracker.mobile2
    zone: zone.home

and another task when either of the 2 mobiles enters the zone:

condition: and
conditions:

  • condition: zone
    entity_id: device_tracker.mobile1
    zone: zone.home
  • condition: or
    conditions:
    • condition: zone
      entity_id: device_tracker.mobile2
      zone: zone.home

Is this correct?

Thanks in advance!

A zone has a state which is a number corresponding to the number of tracked devices in it. This would be the trigger for your automation - no need for any conditions.

triggers:
  - trigger: numeric_state
    entity_id:
      - zone.home
    below: 1

Please post your code in preformatted text (</> in the cogwheel menu in the toolbar).

1 Like

Thank you very much!

Would the counteraction be just the opposite?

above: 0

That’s it… :smile:

1 Like

The action with the value below 1 works fine, but the counteraction does not. Should the value be 0 or 0.1?

Greater than zero, I would have thought. What does your code look like?

Just a slight correction to Jack’s description… The state of the zone reflects the numbers of person entities in the zone, device trackers themselves aren’t part of the count.

3 Likes

Here’s the code:

trigger: numeric_state
entity_id:

  • zone.home
    above: 0.1

Again, it’s hard to read if it isn’t preformatted text, but if that’s…

triggers:
  - trigger: numeric_state
    entity_id:
      - zone.home
    above: 0

…I think it ought to fire.

When you’re testing, bear in mind that the number of person entities in the home zone has to change from zero to above zero. If it’s already above zero when you start testing, nothing will happen.

1 Like

Thanks. I’ve done testing with the value of 0 and nothing really happens, but 0.1 looks to do the trick. :slight_smile: