Hi All,
I have 3 automations for my AppleTV (playing, paused, idle) but want combine those and have 3 sequences to make everything more logic. Only thing I use for playing a “for: 10 seconds” in trigger. Can someone help me how to combine include this 10 seconds part.
Here original 3 automations:
- alias: "Control - AppleTV status is idle"
trigger:
platform: state
entity_id: media_player.woonkamer_2
to: "idle"
condition:
- condition: state
entity_id: sun.sun
state: "below_horizon"
- condition: state
entity_id: input_boolean.scene_appletv
state: "on"
action:
- service: light.turn_on
data:
entity_id:
- light.livingroom_wall
- light.livingroom_window
- light.balcony
brightness_pct: 100
- service: light.turn_on
data:
entity_id: light.nanoleaf
brightness_pct: 50
- service: light.turn_on
data_template:
entity_id: light.dressoir_all
brightness_pct: "{{ 0 if is_state('binary_sensor.node_10', 'on') else 100 }}"
- service: light.turn_off
data:
entity_id:
- light.kitchen_all
- light.sink_all
- light.toilet_all
- alias: "Control - AppleTV status is playing"
trigger:
platform: state
entity_id: media_player.woonkamer_2
to: "playing"
for:
seconds: 10
condition:
- condition: state
entity_id: sun.sun
state: "below_horizon"
- condition: state
entity_id: input_boolean.scene_appletv
state: "on"
action:
- service: light.turn_on
data:
entity_id: light.livingroom_wall
brightness_pct: 60
- service: light.turn_on
data:
entity_id:
- light.livingroom_window
- light.nanoleaf
- light.balcony
brightness_pct: 30
- service: light.turn_on
data_template:
entity_id: light.dressoir_all
brightness_pct: "{{ 0 if is_state('binary_sensor.node_10', 'on') else 25 }}"
- service: light.turn_off
data:
entity_id:
- light.kitchen_all
- light.sink_all
- light.toilet_all
- alias: "Control - AppleTV status is paused"
trigger:
platform: state
entity_id: media_player.woonkamer_2
to: "paused"
condition:
- condition: state
entity_id: sun.sun
state: "below_horizon"
- condition: state
entity_id: input_boolean.scene_appletv
state: "on"
action:
- service: light.turn_on
data:
entity_id:
- light.livingroom_wall
- light.livingroom_window
- light.kitchen_all
- light.sink_all
- light.toilet_all
- light.balcony
brightness_pct: 100
- service: light.turn_on
data:
entity_id: light.nanoleaf
brightness_pct: 50
- service: light.turn_on
data_template:
entity_id: light.dressoir_all
brightness_pct: "{{ 0 if is_state('binary_sensor.node_10', 'on') else 100 }}"
Here the automation I want use and below the script sequence I created:
- alias: "Control - AppleTV Status"
trigger:
platform: state
entity_id: media_player.woonkamer_2
condition:
- condition: state
entity_id: sun.sun
state: "below_horizon"
- condition: state
entity_id: input_boolean.scene_appletv
state: "on"
action:
service_template: >-
{% if (states.media_player.woonkamer_2.state) == 'playing' %} script.appletv_control_playing
{% elif (states.media_player.woonkamer_2.state) == 'paused' %} script.appletv_control_paused
{% else %} script.appletv_control_idle
{% endif %}
below sequences:
appletv_control_paused:
alias: "AppleTV Control Paused Scene"
sequence:
- service: light.turn_on
data:
entity_id:
- light.livingroom_wall
- light.livingroom_window
- light.kitchen_all
- light.sink_all
- light.toilet_all
- light.balcony
brightness_pct: 100
- service: light.turn_on
data:
entity_id: light.nanoleaf
brightness_pct: 50
- service: light.turn_on
data_template:
entity_id: light.dressoir_all
brightness_pct: "{{ 0 if is_state('binary_sensor.node_10', 'on') else 100 }}"
appletv_control_playing:
alias: "AppleTV Control Playing Scene"
sequence:
- service: light.turn_on
data:
entity_id: light.livingroom_wall
brightness_pct: 60
- service: light.turn_on
data:
entity_id:
- light.nanoleaf
- light.livingroom_window
- light.balcony
brightness_pct: 30
- service: light.turn_on
data_template:
entity_id: light.dressoir_all
brightness_pct: "{{ 0 if is_state('binary_sensor.node_10', 'on') else 25 }}"
- service: light.turn_on
data_template:
entity_id:
- light.kitchen_all
- light.sink_all
brightness_pct: "{{ 100 if is_state('binary_sensor.node_16', 'on') else 0 }}"
- service: light.turn_on
data_template:
entity_id: light.toilet_all
brightness_pct: "{{ 100 if is_state('binary_sensor.node_20', 'on') else 0 }}"
appletv_control_idle:
alias: "AppleTV Control Idle Scene"
sequence:
- service: light.turn_on
data:
entity_id:
- light.livingroom_wall
- light.livingroom_window
- light.balcony
brightness_pct: 100
- service: light.turn_on
data:
entity_id: light.nanoleaf
brightness_pct: 50
- service: light.turn_on
data_template:
entity_id: light.dressoir_all
brightness_pct: "{{ 0 if is_state('binary_sensor.node_10', 'on') else 100 }}"
- service: light.turn_on
data_template:
entity_id:
- light.kitchen_all
- light.sink_all
brightness_pct: "{{ 100 if is_state('binary_sensor.node_16', 'on') else 0 }}"
- service: light.turn_on
data_template:
entity_id: light.toilet_all
brightness_pct: "{{ 100 if is_state('binary_sensor.node_20', 'on') else 0 }}"
new way is working, only without the “for 10 seconds” because I don’t know how to add that one for only the playing part. I thought to add "delay: “00:00:10"” but after 10 seconds the sequence is firing because it won’t check state anymore.