Hello all,
For some fun on Friday I thought I would share some of my config segments
With tts installed a new movie playing can be announced audibly by HA with the following code added
#Under Automation segment
automation:
- alias: 'Announcement Movie state changed'
hide_entity: true
trigger:
platform: state
entity_id: media_player.kodi
# you can leave this following line out if you want an announcement on every state change.
to: 'playing'
action:
service: shell_command.speak_movie
#Under Shell commands
shell_command:
speak_movie: tts '{{ states.media_player.kodi.attributes.media_title }} is now {{ states.media_player.kodi.state }} in the {{ states.media_player.kodi.attributes.
If you prefer a more silent approach then you could work with persistent notifications
#Under Group segment
group:
default_view:
view: yes
entities:
- persistent_notification.movie
- persistent_notification.music
- persistent_notification.occupants
#Under Automation segment
automation:
- alias: 'Announcement Movie state changed'
hide_entity: true
trigger:
platform: state
entity_id: media_player.kodi, media_player.kodi_bedroom, media_player.lg_tv
action:
service: persistent_notification.create
data_template:
message: >
{{ trigger.to_state.attributes.media_title }} is now {{ trigger.to_state.state }} in the {{ trigger.to_state.attributes.friendly_name }}.
notification_id: "movie"
- alias: 'Announcement Music state changed'
hide_entity: true
trigger:
platform: state
entity_id: media_player.livingroom, media_player.bedroom
action:
service: persistent_notification.create
data_template:
message: >
{{ trigger.to_state.attributes.media_artist }} - {{ trigger.to_state.attributes.media_title }} is now {{ trigger.to_state.state }} in the {{ trigger.to_state.attributes.friendly_name }}.
notification_id: "music"
Ah you want to know about the presence notication as well? Here you go with a nice timestamp added,
- alias: 'Occupants State Change Alert'
hide_entity: true
trigger:
platform: state
entity_id: device_tracker.kylo_ren, device_tracker.snoke, device_tracker.rey
action:
service: persistent_notification.create
data_template:
message: >
{{ trigger.to_state.attributes.friendly_name }} is {% if trigger.to_state.state == 'not_home' %}away{% else %}home{% endif %} since {{now().strftime("%H:%M:%S")}}
notification_id: "occupants"
And yes persistent notifications show nicely on the default view if you use my placement
If you are looking for a popup per resident create one for each like this
- alias: 'Kylo Ren State Change Alert'
hide_entity: true
trigger:
platform: state
entity_id: device_tracker.kylo_ren
action:
service: persistent_notification.create
data_template:
message: >
{{ trigger.to_state.attributes.friendly_name }} is {% if trigger.to_state.state == 'not_home' %}away{% else %}home{% endif %} since {{now().strftime("%H:%M:%S")}}
notification_id: "kylo ren"