Hi All,
I have been doing quite a bit of reading as I get deeper into learning YAML. I am attempting to write my first if/then statement and need a little help (so I can reverse engineer and understand the syntax).
Use Case: When someone ring my doorbell I want to display the camera on my family room TV (if the TV is turned on) and kitchen display. If the family room TV is not turned on then I just want to display on the kitchen display.
First, here is the code to properly display the camera to the kitchen display:
#------------------------------------------------------------------------------
# STREAM DOORBIRD CAMERA TO DISPLAY WHEN DOORBELL RINGS
#------------------------------------------------------------------------------
- alias: 'Doorbell'
# hide_entity: true
trigger:
- platform: event
event_type: doorbird_front_gate_somebody_pressed_the_button
action:
- service: camera.play_stream
data:
entity_id: camera.front_gate_live
media_player: media_player.kitchen_display
- delay: '00:00:10'
- service: media_player.turn_off
data:
entity_id: media_player.kitchen_display
Next, here is where I am, so far, in trying to figure out the logic with it:
- alias: 'Doorbell'
# hide_entity: true
trigger:
- platform: event
event_type: doorbird_front_gate_somebody_pressed_the_button
action:
- service: camera.play_stream
data_template:
entity_id: camera.front_gate_live
media_player: >
{% if is_state("media_player.family_room_tv","on") %}
media_player.family_room_tv
media_player.kitchen_display
{% else %}
media_player.kitchen_display
{% endif %}
- delay: '00:00:10'
- service: media_player.turn_off
data_template:
entity_id: >
{% if is_state("media_player.family_room_tv","on") %}
media_player.family_room_tv
media_player.kitchen_display
{% else %}
media_player.kitchen_display
{% endif %}
I realize I cannot just throw in two different media players for the if statement… I need some help here
Thanks!