Automation help for presence detection

im trying to do an automation that welcomes me, or whoever i add, home when our presence is changed from away to home but it doesn’t seem to ever trigger. im using one that just detects when my phone connects to the wifi. i know its detecting me as a card on my lovelace updates when i connect and disconnect from the wifi. but the automation never triggers. Any ideas?

alias: Announce blanks arrival
description: ''
trigger:
  - platform: state
    entity_id: device_tracker.blank
    to: home
    for:
      hours: 0
      minutes: 0
      seconds: 0
      milliseconds: 0
    from: away
condition: []
action:
  - service: notify.alexa_media_blanks_s_echo_dot
    data:
      message: 'blank has Arrived '
mode: single

I think device_trackers change from “not_home” to “home” (“away” is an invalid state), you also do not need the “for” so this could be simplified as follows:

alias: Announce blanks arrival
description: ''
trigger:
  - platform: state
    entity_id: device_tracker.blank
    to: home
condition: []
action:
  - service: notify.alexa_media_blanks_s_echo_dot
    data:
      message: 'blank has Arrived '
mode: single

Another way to achieve this would be to create a person entity that references one (or more) device_trackers then use the person changing to home in the trigger rather than the device_tracker. This is particularly useful is you have more than one device_tracker that can be associated with a person.

1 Like

As Jonah said, the state isn’t away it’s not_home, as mentioned in the docs.

Any time you’re working with states, the current actual state can be seen in Developer Tools → States. Anything you see elsewhere, or in entity history, is translated and so can’t be trusted.