home-assistant-configuration/config/scripts/lights.yaml

142 lines
3.4 KiB
YAML
Executable File

#########################################
#
# Light Based Scripts
#
#########################################
# Turn on Living Room Lights if sun is down or cloud coverage is above 70%
livingroom_lamps_on:
sequence:
- condition: or
conditions:
- condition: state
entity_id: sun.sun
state: 'below_horizon'
- service: scene.turn_on
entity_id: scene.normal_livingroom_lighting
# Turn off Living Room Lights if sun is up and it is sunny or partly cloudy
livingroom_lights_off:
sequence:
- condition: and
conditions:
- condition: state
entity_id: sun.sun
state: 'above_horizon'
- condition: state
entity_id: binary_sensor.living_room_occupancy
state: 'off'
- condition: template
value_template: >
{%- if states.weather.home.state == "sunny" or states.weather.home.state == "partlycloudy" -%}
true
{%- endif -%}
- service: group.turn_off
entity_id: group.livingroom
# Turn off Kitchen Lights if sun is up and it is sunny or partly cloudy
kitchen_lights_off:
sequence:
- condition: and
conditions:
- condition: state
entity_id: sun.sun
state: 'above_horizon'
- condition: state
entity_id: binary_sensor.kitchen_occupancy
state: 'off'
- condition: template
value_template: >
{%- if states.weather.home.state == "sunny" or states.weather.home.state == "partlycloudy" -%}
true
{%- endif -%}
- service: group.turn_off
entity_id: group.kitchen
good_night_loft:
sequence:
- condition: state
entity_id: media_player.pn60e550_pn60e550
state: "off"
- service: switch.turn_off
entity_id: switch.croft_fan
- service: switch.turn_off
entity_id: switch.croft_light
kitchen_lights_on:
sequence:
- condition: state
entity_id: sun.sun
state: 'below_horizon'
- condition: time
after: '05:30:00'
before: '22:30:00'
- service: scene.turn_on
entity_id: scene.normal_kitchen_lighting
kitchen_lights_night:
sequence:
- condition: and
conditions:
- condition: state
entity_id: sun.sun
state: 'below_horizon'
- condition: time
after: '22:30:00'
before: '05:30:00'
- service: scene.turn_on
entity_id: scene.diminished_kitchen_lighting
- delay:
minutes: 18
- service: light.turn_off
entity_id: light.kitchen_cabinets
theater_lights_out:
sequence:
- condition: and
conditions:
- condition: template
value_template: >
{%- if states.media_player.home_theater != "playing" -%}
true
{%- endif -%}
- condition: template
value_template: >
{%- if states.media_player.playstation_4 != "playing" -%}
true
{%- endif -%}
- condition: state
entity_id: binary_sensor.theater_occupancy
state: 'off'
- service: scene.turn_on
entity_id: scene.theater_dark
- service: switch.turn_off
entity_id: switch.theater_fan
theater_lights_down:
sequence:
- service: scene.turn_on
entity_id: scene.theater_dim
- delay:
minutes: 1
- service: scene.turn_on
entity_id: scene.theater_dark
theater_lights_up:
sequence:
- service: scene.turn_on
entity_id: scene.theater_dim
- delay:
minutes: 1
- service: scene.turn_on
entity_id: scene.theater_bright