Someone Home Automation

The below Trigger by itself works, however, with the conditions, it fires every time someone arrives home. This doesn’t seem to be working and wonder if the conditions are cancelling out the Trigger. I want this to only fire once when the first person arrives home. Is there better way to write this?

- id: '1568072625365'
  alias: Someone Home
  trigger:
  - entity_id: device_tracker.life360_s
    event: enter
    platform: zone
    zone: zone.home
  - entity_id: device_tracker.life360_j
    event: enter
    platform: zone
    zone: zone.home
  condition:
  - condition: state
    entity_id: device_tracker.life360_s
    state: not_home
  - condition: state
    entity_id: device_tracker.life360_j
    state: not_home
  action:
  - data:
      message: Someone is Home
    service: notify.notify

I would suggest just using the state of the device tracker. Something along these lines:

  trigger:
    platform: state
    entity_id:
      - device_tracker.person1
      - device_tracker.person2
    from: 'not_home'
    to: 'home'
  action:
    <action>

You shouldn’t need any conditions here because its looking for “not_home” to change to “home”

I’ll give it a try; thank you.

Add your trackers to a group, and use the group as a tracker.
The group’s state will be home when at least 1 tracker is home

Funny thing…I had just created a tracker group for my Everyone Away automation; I had not read closely what the trigger conditions would be. Thank you.

Does this look correct?

- id: '1568072625365'
  alias: Someone Home
  trigger:
  - platform: state
    entity_id: group.my_people
    to: home
  condition: []
  action:
  - data:
      message: Someone is Home
    service: notify.notify

Sounds about right. You might need to put home in quotes though.
Same for your message

Thanks. Regarding the single quotations…what is the point of them? I do not see them in all code. They are not added in the GUI Automation editor, and if you do add them, they get quoted in the yaml file. I am confused about that.

quote generally denote a string.
Most of the time HA will be clever enough to recognise the text and class it as a string, but sometimes it doesn’t and this can lead to errors.
It’s always a good idea / practice to enclose your strings in quotes. You can use either single or double.
More info here:
https://docs.ansible.com/ansible/latest/reference_appendices/YAMLSyntax.html

This is not firing (with and w/o quotes). No notifications received, History shows it always On, and the logbook shows Trigger as Never. There would have been multiple opportunities for this to execute over the past 24 hrs.

Had the status for the group changed? If not this is where the issue lies. If yes it’s down to the automation. Do you have any conditions ?

Developer Tools / Template - the default template editor contains a simplified version of this.
https://my-ha-site.duckdns.org:8123/developer-tools/template

{% if is_state("device_tracker.paulus", "home") and
      is_state("device_tracker.anne_therese", "home") -%}
  You are both home, you silly
{%- else -%}
  Anne Therese is at {{ states("device_tracker.anne_therese") }}
  Paulus is at {{ states("device_tracker.paulus") }}
{%- endif %}

Thank you, I’ll try this.

Where would I tell if the group status did change? No conditions.

go to Developer Tools > States, locate your group and click on the blue icon next to it, you’ll see its history and whether its status changed over time.
Don’t forget you need just 1 of the device trackers in the group for the group to show home, don’t add to many devices, especially sedentary devices that might always be home…

Got it, thanks.

I realized my tracker names were wrong. I have fixed and will track progress now.

1 Like