There are some topics with this, but didn’t work out for me.
I want a automation on a group. Then it send a message to pushover with the info of the triggered entity within the group.
I tried everything but it still not working… Can someone assist me with this?
###########################################################################################
# NOTIFY WHEN WRT DEVICES GOES OFFLINE OR ONLINE
###########################################################################################
- alias: "Notification - WRT Devices Online/Offline"
trigger:
platform: state
entity_id:
- group.wrt
to: "off"
mode: restart
action:
service: script.pushover_engine
data_template:
message: >-
{{ trigger.from_state.attributes.friendly_name }} is {{ 'online' if trigger.to_state.state == 'home' else 'offline' }}
priority: "0"
sound: "bike"
title: "HA Notify Engine"
A group of device_tracker entities will not be 'on' or 'off', it will be 'home' or 'not_home', so using to: "off" doesn’t make sense anyway.
So I’m not sure exactly what you’re trying to do. But whatever you use for the trigger, I’m guessing you want to find the entity in the group that changed last. If so, then maybe something like this:
action:
service: script.pushover_engine
data_template:
message: >
{% set last = (expand('group.tracked_people')|sort(attribute='last_changed'))[-1] %}
{{ last.name }} is {{ 'online' if last.state == 'home' else 'offline' }}
priority: "0"
sound: "bike"
title: "HA Notify Engine"