How can I get alerted when any sensor state changes

I’m trying to keep an eye on when people move into and out of range of my BLE and BT scanners, and I’d like to trigger a notify when the state of any of the “device_tracker” entries change.

Can anyone tell me what I need to do? Thanks!

1 Like

I believe you want https://home-assistant.io/docs/configuration/events/#event-state_changed Do post any progress since I mean to test this soon myself :slight_smile:

This is what I use to send me messages when the IOS app updates my location… It might get you started.

- alias: Notify iOS moving
  trigger:
    platform: state
    entity_id: device_tracker.ryans_iphone_app
  action:
    service: notify.ios_ryans_iphone_app
    data_template:
      message: >
        {{trigger.from_state}}
        {{trigger.to_state}}
1 Like

or publish to mqtt, then use a mqtt client on your phone

I would have thought the most explicit way to do this would be:

  trigger:
    platform: event
    entity_id: device_tracker.ryans_iphone_app
    event_type: state_changed 
  action:
    service: notify.ios_ryans_iphone_app
    data_template:
      message: >
        {{state.ios_ryans_iphone_app.state.from_state}}
        {{state.ios_ryans_iphone_app.state.to_state}}

Although the docs state ‘any state change will be announced on the event bus as a state_changed event containing the previous and the new state of an entity’ so the @rabittn approach works. If anyone can comment of the relative merits of the two approaches I would be grateful :slight_smile:

Wouldn’t the Alert component cover this?
I haven’t used alert to verify but believe this is use case.