alias: Populate Terasa TV metadata when user stopped playing
description: ''
trigger:
- platform: state
entity_id:
- media_player.terasa_tv
from: playing
to: idle
condition:
- condition: template
value_template: >-
{{ trigger.to_state.context.user_id is defined }}
action:
- service: input_text.set_value
data:
value: 'true'
target:
entity_id: input_text.terasa_tv_stopped_by_user
mode: single
The template condition returns true for null values of trigger’s user_id
The trigger is below:
this:
entity_id: automation.populate_terasa_tv_metadata_when_user_stopped_playing
state: 'on'
attributes:
last_triggered: '2022-06-21T22:19:46.937425+00:00'
mode: single
current: 0
id: '1652250758913'
friendly_name: Populate Terasa TV metadata when user stopped playing
last_changed: '2022-06-22T11:00:01.680321+00:00'
last_updated: '2022-06-22T11:00:01.680321+00:00'
context:
id: 01G65H3CGGECPQ7DNQA4FGSH0Q
parent_id: null
user_id: null
trigger:
id: '0'
idx: '0'
platform: state
entity_id: media_player.terasa_tv
from_state:
entity_id: media_player.terasa_tv
state: playing
attributes:
volume_level: 0.4000000059604645
is_volume_muted: false
media_content_id: http://radio.local:8000/md.plai
media_duration: 19081.560816
media_position: 19080.914255
media_position_updated_at: '2022-06-22T19:24:12.926543+00:00'
media_title: '[MD] RADIO PLAI'
app_id: CC1AD845
app_name: Default Media Receiver
entity_picture_local: null
friendly_name: Terasa TV
supported_features: 152463
last_changed: '2022-06-22T19:24:12.927085+00:00'
last_updated: '2022-06-22T19:24:12.927085+00:00'
context:
id: 01G66DYJQZSYSWBQ0VB3NEZGFX
parent_id: null
user_id: null
to_state:
entity_id: media_player.terasa_tv
state: idle
attributes:
volume_level: 0.4000000059604645
is_volume_muted: false
media_content_id: http://radio.local:8000/md.plai
media_duration: 19081.560816
media_position: 0
media_position_updated_at: '2022-06-22T19:24:13.602723+00:00'
media_title: '[MD] RADIO PLAI'
app_id: CC1AD845
app_name: Default Media Receiver
entity_picture_local: null
friendly_name: Terasa TV
supported_features: 152463
last_changed: '2022-06-22T19:24:13.603218+00:00'
last_updated: '2022-06-22T19:24:13.603218+00:00'
context:
id: 01G66DYKD3KJEY3ZGX66D3C8N7
parent_id: null
user_id: null
for: null
attribute: null
description: state of media_player.terasa_tv
I am trying to create an automation that only triggers when a certain person says the trigger phrase. So far i’m not having much luck. Should I change anything in this automation?