Hi,
I got a script that takes a parameter which is what view should be cast to my Nest hub.
From the examples I’ve seen I should be able to set a variable in a condition template
While also performing a conditional check
I.e.
- condition: template
value_template: >
{{ param in state_attr('input_select.google_cast_rooms', 'options') }
{% set cast_target = true %}
So basically if it’s an valid parameter, perform the cast, if not, ignore.
But my last conditional does not seem to evaluate properly?
If I uncomment it, the script works…
Where am I doing wrong… Can someone help me?
- condition: template
value_template: '{{ cast_target == true }}'
Full function
cast_by_param2:
alias: Cast|Hubben|Param
description: "Cast Param to Hubben"
variables:
cast_target: false
fields:
param:
description: "Room name as found in input_select.google_cast_rooms"
example: "vardagsrum"
sequence:
- service: media_player.turn_off
entity_id: media_player.hubben
- choose:
- conditions:
- condition: template
value_template: >
{{ param in state_attr('input_select.google_cast_rooms', 'options') }}
{% set cast_target = true %}
sequence:
- service: input_select.select_option
data:
entity_id: input_select.google_cast_rooms
option: "{{ param }}"
- conditions:
- condition: template
value_template: >
{{ param in state_attr('input_select.google_cast_others', 'options') }}
{% set cast_target = true %}
sequence:
- service: input_select.select_option
data:
entity_id: input_select.google_cast_others
option: "{{ param }}"
# end choose
- delay: 1
- condition: template
value_template: '{{ cast_target == true }}'
- service: cast.show_lovelace_view
data:
dashboard_path: lovelace-rum
entity_id: media_player.hubben
view_path: "{{ param }}"