Refactor plex lighting automation

This commit is contained in:
Correl Roush 2018-06-14 18:26:31 -04:00
parent 05b9e214e8
commit 0da054c34c
1 changed files with 14 additions and 25 deletions

View File

@ -1,5 +1,5 @@
automation:
- alias: Dim when Plex is active
- alias: Dim lights for movie
action:
- service: scene.turn_on
entity_id: scene.dimmed_brightness
@ -12,10 +12,19 @@ automation:
- condition: state
entity_id: light.living_room
state: 'on'
- alias: Restore nighttime lights after Plex
- condition: template
value_template: >-
{{ state_attr('media_player.plex_ps4', 'media_content_type') == 'movie'}}
- alias: Restore lights after movie
action:
- service: scene.turn_on
entity_id: scene.nighttime_brightness
data_template:
entity_id: >-
{% if is_state('sun.sun', 'below_horizon') %}
scene.nighttime_brightness
{% else %}
scene.normal_brightness
{% endif %}
trigger:
- platform: state
entity_id: media_player.plex_ps4
@ -25,25 +34,6 @@ automation:
- condition: state
entity_id: light.living_room
state: 'on'
- condition: state
entity_id: sun.sun
state: 'below_horizon'
- alias: Restore normal lights after Plex
action:
- service: scene.turn_on
entity_id: scene.normal_brightness
trigger:
- platform: state
entity_id: media_player.plex_ps4
to: idle
from: playing
condition:
- condition: state
entity_id: light.living_room
state: 'on'
- condition: state
entity_id: sun.sun
state: 'above_horizon'
group:
Plex:
@ -59,6 +49,5 @@ group:
plex_automations:
name: Automations
entities:
- automation.dim_when_plex_is_active
- automation.restore_nighttime_lights_after_plex
- automation.restore_normal_lights_after_plex
- automation.dim_lights_for_movie
- automation.restore_lights_after_movie