Skip to content

Commit

Permalink
refactor: rework light scenes trigger
Browse files Browse the repository at this point in the history
  • Loading branch information
bdossantos committed Nov 10, 2024
1 parent 2ffe272 commit b3bdf31
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 296 deletions.
219 changes: 29 additions & 190 deletions homeassistant/automation/light.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,13 @@
entity_id: input_boolean.guest_mode
state: "off"
action:
- service: scene.turn_on
entity_id: scene.sun_gets_dim
- service: hue.activate_scene
data:
transition: 30
target:
entity_id:
- scene.hallway_read
- scene.livingroom_read

- alias: "Turn more lights on as the sun gets dimmer"
initial_state: "True"
Expand All @@ -56,8 +61,14 @@
entity_id: input_boolean.guest_mode
state: "off"
action:
- service: scene.turn_on
entity_id: scene.sun_gets_dimmer
- service: hue.activate_scene
data:
transition: 30
target:
entity_id:
- scene.hallway_relax
- scene.livingroom_relax
- scene.kitchen_relax

- alias: "Turn on nightlight at dusk"
initial_state: "True"
Expand All @@ -74,8 +85,14 @@
entity_id: input_boolean.guest_mode
state: "off"
action:
- service: scene.turn_on
entity_id: scene.nightlight
- service: hue.activate_scene
data:
transition: 30
target:
entity_id:
- scene.hallway_nightlight
- scene.livingroom_nightlight
- scene.kitchen_nightlight

- alias: "Turn on lights when dark and we Just Arrived"
initial_state: "True"
Expand All @@ -90,194 +107,16 @@
after: sunset
- condition: sun
before: sunrise
action:
- service: scene.turn_on
entity_id: scene.just_arrived
- service: switch.turn_on
entity_id: switch.smartplug_kitchen1

- alias: "Turn on kitchen lights when there is a movement"
trigger:
platform: state
entity_id:
- binary_sensor.hue_motion_sensor_kitchen_motion
to: "on"
condition:
- condition: numeric_state
entity_id: sensor.hue_motion_sensor_kitchen_illuminance
below: 150
- condition: state
entity_id: input_boolean.guest_mode
state: "off"
action:
- service: switch.turn_on
entity_id: switch.smartplug_kitchen1
- service: light.turn_on
data_template:
entity_id:
- light.kitchen_lights
color_temp: >
{%- if now().strftime('%H') | int >= 20 %}
450
{%- elif now().strftime('%H') | int >= 7 %}
350
{%- else %}
500
{%- endif %}
brightness_pct: >
{%- if now().strftime('%H') | int >= 20 %}
60
{%- elif now().strftime('%H') | int >= 8 %}
80
{%- else %}
50
{%- endif %}
- alias: "Turn off kitchen lights few minutes after last movement"
trigger:
platform: state
entity_id:
- binary_sensor.hue_motion_sensor_kitchen_motion
to: "off"
for:
minutes: 1
condition:
- condition: state
entity_id: input_boolean.guest_mode
state: "off"
action:
- service: switch.turn_off
entity_id: switch.smartplug_kitchen1
- service: light.turn_off
entity_id:
- light.kitchen

- alias: "Turn on dressing lights when there is a movement"
trigger:
platform: state
entity_id:
- binary_sensor.hue_motion_sensor_dressing1_motion
- binary_sensor.hue_motion_sensor_dressing2_motion
to: "on"
condition:
- condition: state
entity_id: input_boolean.guest_mode
state: "off"
action:
- service: light.turn_on
data_template:
entity_id:
- light.dressing
color_temp: >
{%- if now().strftime('%H') | int >= 20 %}
450
{%- elif now().strftime('%H') | int >= 7 %}
350
{%- else %}
500
{%- endif %}
brightness_pct: >
{%- if now().strftime('%H') | int >= 20 %}
60
{%- elif now().strftime('%H') | int >= 8 %}
80
{%- else %}
50
{%- endif %}
- alias: "Turn off dressing lights few minutes after last movement"
trigger:
platform: state
entity_id:
- binary_sensor.hue_motion_sensor_dressing1_motion
- binary_sensor.hue_motion_sensor_dressing2_motion
to: "off"
for:
minutes: 1
condition:
- condition: state
entity_id: input_boolean.guest_mode
state: "off"
action:
- service: light.turn_off
entity_id:
- light.dressing

- alias: "Turn on living room lights when there is a movement and when dark"
trigger:
platform: state
entity_id:
- binary_sensor.livingroom_motion_sensor
to: "on"
condition:
condition: and
conditions:
- condition: state
entity_id: group.family
state: "home"
- condition: state
entity_id: input_boolean.guest_mode
state: "off"
- condition: state
entity_id: light.livingroom1
entity_id: light.livingroom
state: "off"
- condition: or
conditions:
- condition: sun
after: sunset
- condition: sun
before: sunrise
action:
- service: light.turn_on
data_template:
- service: hue.activate_scene
target:
entity_id:
- light.livingroom1
color_temp: >
{%- if now().strftime('%H') | int <= 9 %}
350
{%- else %}
500
{%- endif %}
brightness_pct: >
{%- if now().strftime('%H') | int <= 9 %}
30
{%- else %}
70
{%- endif %}
- alias: "Turn off living room lights when there is not movement and when dark"
trigger:
platform: state
entity_id:
- binary_sensor.livingroom_motion_sensor
to: "off"
for:
minutes: 1
condition:
condition: and
conditions:
- condition: state
entity_id: group.family
state: "home"
- condition: state
entity_id: light.livingroom1
state: "on"
- condition: time
after: "02:00:00"
before: "06:00:00"
- condition: state
entity_id: input_boolean.guest_mode
state: "off"
- condition: or
conditions:
- condition: sun
after: sunset
- condition: sun
before: sunrise
action:
- service: light.turn_off
entity_id:
- light.livingroom1
- scene.hallway_relax
- scene.livingroom_relax
- scene.kitchen_relax

- alias: "Turn off all lights when everybody is Away"
initial_state: "True"
Expand Down
6 changes: 0 additions & 6 deletions homeassistant/light_profiles.csv

This file was deleted.

20 changes: 0 additions & 20 deletions homeassistant/scene/candle.yaml

This file was deleted.

19 changes: 0 additions & 19 deletions homeassistant/scene/just-arrived.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions homeassistant/scene/sun-gets-dim.yaml

This file was deleted.

48 changes: 0 additions & 48 deletions homeassistant/scene/sun-gets-dimmer.yaml

This file was deleted.

0 comments on commit b3bdf31

Please sign in to comment.