I’m trying to achieve the following:
When I press a button and a certain channel on my media player is active, switch to a certain channel.
So, the trigger is the press of a button and the condition the state of the media player.
trigger:
- device_id: acdc951e0ae411eb9baccd9b5879f7a5
domain: deconz
platform: device
type: remote_button_long_press
subtype: dim_up
condition:
- condition: template
value_template: >-
{{ (state_attr('media_player.sonos_kleines_bad', 'media_channel')) in 'Deutschlandfunk' }}
action:
- service: media_player.select_source
data:
source: ROCK ANTENNE Heavy Metal
target:
entity_id: media_player.sonos_kuche
mode: single
That works, as long as the media_player returns “Deutschlandfunk” exactly.
But sometimes it returns “Deutschlandfunk - Nachrichten” or the like. And then this check fails.
So, what I essentially need, is some wildcard functionality to achieve that.
I already tried:
{{ 'Deutschlandfunk' in states('media_player.sonos_kleines_bad') }}
{{ 'Deutschlandfunk' in states('media_player.sonos_kleines_bad.media_channel') }}
but both return “false”.
When I check the entity itself, it returns the following:
media_channel: Deutschlandfunk
I really do not understand the documentation and thus do not know how to do it right.