Two parter…
Can some tell me what is wrong with this? Template editor is throwing TemplateSyntaxError: unexpected '} ’
trigger:
- platform: template
value_template: "{% if is_state('media_player.emby_basement', 'playing') and (state_attr('media_player.emby_basement', 'media_content_type') in ['movie', 'tvshow']) }true{% endif %}"
Also, can I list multiple value templates as triggers for an automation? Such as:
trigger:
- platform: template
value_template: 11111111
- platform: template
value_template: 2222222
- platform: template
value_template: 333333
petro
(Petro)
July 30, 2019, 2:56am
2
VMCosco:
value_template: “{% if is_state(‘media_player.emby_basement’, ‘playing’) and (state_attr(‘media_player.emby_basement’, ‘media_content_type’) in [‘movie’, ‘tvshow’]) }true{% endif %}”
Your problem is that you’re missing a %
before the }true
. But in all honesty, none of that is needed. You can simply trigger with
value_template: "{{ is_state('media_player.emby_basement', 'playing') and state_attr('media_player.emby_basement', 'media_content_type') in ['movie', 'tvshow'] }}"
petro
(Petro)
July 30, 2019, 2:59am
3
Yes. They just have to be templates that return true and false.
Can I nest the the 3 templates into one statement using “or”? May be too complicated though
petro
(Petro)
July 30, 2019, 11:40am
5
Yes you can. It can be as complicated as you want it to be.
Thanks. One more question on the same topic. Is this a proper template to trigger an action when the boolean is “on” and the state changes from playing? The state could change to paused or idle which is why i used “from”. It does not seem to be working though.
trigger:
- platform: template
value_template: "{{ is_state('input_boolean.video_playback_basement', 'on') and from_state('media_player.emby_basement', 'playing') }}"
petro
(Petro)
July 30, 2019, 10:58pm
7
No, there is a list of available functions that can be used in templates. What you are tying to do is not possible for a template trigger.
AhmadK
(akasma74)
July 31, 2019, 10:45am
8
How about converting your action to something like
trigger:
- platform: state
entity_id: media_player.emby_basement
from: 'playing'
condition:
condition: template
value_template: "{{ is_state('input_boolean.video_playback_basement', 'on') }"
(I didn’t check syntax, just an idea)