From 2af639deb4a33b233bbcb64c6e7f348c4194845e Mon Sep 17 00:00:00 2001 From: pgrondek Date: Tue, 25 May 2021 14:33:35 +0200 Subject: [PATCH] Change lights automations Merge with white temperature automations --- .../automations/bathroom-lights.yaml | 3 +- configuration/automations/bedroom-motion.yaml | 26 ++++- .../automations/computer-button.yaml | 48 +++++++- configuration/automations/hallway-motion.yaml | 75 ++++++------ configuration/automations/kitchen-button.yaml | 107 ++++++++++++++++-- configuration/automations/kitchen-motion.yaml | 79 +++++++------ home-assistant.yml | 4 - templates/lights.yaml.j2 | 31 ----- 8 files changed, 248 insertions(+), 125 deletions(-) diff --git a/configuration/automations/bathroom-lights.yaml b/configuration/automations/bathroom-lights.yaml index bc912b8..adad32a 100644 --- a/configuration/automations/bathroom-lights.yaml +++ b/configuration/automations/bathroom-lights.yaml @@ -36,7 +36,6 @@ data: brightness_pct: 100 kelvin: 3200 - - choose: - conditions: - condition: state entity_id: input_select.home_mode @@ -66,7 +65,7 @@ condition: - condition: state entity_id: binary_sensor.bathroom_motion_occupancy - for: '0:02:00' + for: '0:05:00' state: 'off' - condition: state entity_id: binary_sensor.shower_motion diff --git a/configuration/automations/bedroom-motion.yaml b/configuration/automations/bedroom-motion.yaml index 8aa11dc..6d4206e 100644 --- a/configuration/automations/bedroom-motion.yaml +++ b/configuration/automations/bedroom-motion.yaml @@ -14,11 +14,27 @@ entity_id: input_select.home_mode state: Day action: - - service: light.turn_on - entity_id: light.bedroom_lights - data: - brightness_pct: 60 - kelvin: 2000 + - choose: + - conditions: + - condition: state + entity_id: input_boolean.sleep_mode + state: 'on' + sequence: + - service: light.turn_on + entity_id: light.bedroom_lights + data: + brightness_pct: 60 + kelvin: 2000 + - conditions: + - condition: state + entity_id: input_boolean.sleep_mode + state: 'off' + sequence: + - service: light.toggle + entity_id: light.bedroom_lights + data: + brightness_pct: 60 + kelvin: 3200 - id: bedroom-motion-off alias: '[Bedroom] Motion Off' diff --git a/configuration/automations/computer-button.yaml b/configuration/automations/computer-button.yaml index f9e320a..2cdb425 100644 --- a/configuration/automations/computer-button.yaml +++ b/configuration/automations/computer-button.yaml @@ -7,9 +7,27 @@ type: remote_button_short_press subtype: turn_on action: - - service: light.turn_on - data: - entity_id: light.desk_lightbar + - choose: + - conditions: + - condition: state + entity_id: input_boolean.sleep_mode + state: 'on' + sequence: + - service: light.turn_on + entity_id: light.desk_lightbar + data: + brightness_pct: 100 + kelvin: 2000 + - conditions: + - condition: state + entity_id: input_boolean.sleep_mode + state: 'off' + sequence: + - service: light.toggle + entity_id: light.desk_lightbar + data: + brightness_pct: 100 + kelvin: 3200 mode: single - id: button-computer-cave-off @@ -35,9 +53,27 @@ device_id: 5b972523e427721ec88e095994f7cc16 command: move_with_on_off action: - - service: light.turn_on - data: - entity_id: light.tv_lights + - choose: + - conditions: + - condition: state + entity_id: input_boolean.sleep_mode + state: 'on' + sequence: + - service: light.turn_on + entity_id: light.tv_lights + data: + brightness_pct: 100 + kelvin: 2000 + - conditions: + - condition: state + entity_id: input_boolean.sleep_mode + state: 'off' + sequence: + - service: light.toggle + entity_id: light.tv_lights + data: + brightness_pct: 100 + kelvin: 3200 mode: single - id: button-computer-cave-hold-off diff --git a/configuration/automations/hallway-motion.yaml b/configuration/automations/hallway-motion.yaml index d32827b..e02e3a2 100644 --- a/configuration/automations/hallway-motion.yaml +++ b/configuration/automations/hallway-motion.yaml @@ -1,43 +1,52 @@ -- id: hallway-motion-day - alias: '[Hallway] Motion Day' +- id: hallway-lightstrip-on + alias: '[Hallway] Lights strip on' mode: restart trigger: - platform: state entity_id: binary_sensor.hallway_motion_sensor from: 'off' to: 'on' - condition: - - condition: state - entity_id: input_select.home_mode - state: Day action: - - service: light.turn_on - entity_id: light.hallway_lightstrip - data: - brightness_pct: 100 - kelvin: 3200 - -- id: hallway-motion-night - alias: '[Hallway] Motion Night' - mode: restart - trigger: - - platform: state - entity_id: binary_sensor.hallway_motion_sensor - from: 'off' - to: 'on' - condition: - - condition: state - entity_id: input_select.home_mode - state: Night - action: - - service: light.turn_on - entity_id: light.hallway_lightstrip - data: - brightness_pct: 5 - rgb_color: - - 255 - - 0 - - 0 + - choose: + - conditions: + - condition: state + entity_id: input_select.home_mode + state: Day + sequence: + - choose: + - conditions: + - condition: state + entity_id: input_boolean.sleep_mode + state: 'on' + sequence: + - service: light.turn_on + entity_id: light.hallway_lightstrip + data: + brightness_pct: 100 + kelvin: 2000 + - conditions: + - condition: state + entity_id: input_boolean.sleep_mode + state: 'off' + sequence: + - service: light.toggle + entity_id: light.hallway_lightstrip + data: + brightness_pct: 100 + kelvin: 3200 + - conditions: + - condition: state + entity_id: input_select.home_mode + state: Night + sequence: + - service: light.turn_on + entity_id: light.hallway_lightstrip + data: + brightness_pct: 5 + rgb_color: + - 255 + - 0 + - 0 - id: hallway-motion-off alias: '[Hallway] Motion Off' diff --git a/configuration/automations/kitchen-button.yaml b/configuration/automations/kitchen-button.yaml index 1008627..62ac1a2 100644 --- a/configuration/automations/kitchen-button.yaml +++ b/configuration/automations/kitchen-button.yaml @@ -10,9 +10,43 @@ type: remote_button_short_press subtype: button_1 action: - - service: light.turn_on - target: - entity_id: light.kitchen_lights + - choose: + - conditions: + - condition: state + entity_id: input_select.home_mode + state: Day + sequence: + - choose: + - conditions: + - condition: state + entity_id: input_boolean.sleep_mode + state: 'on' + sequence: + - service: light.turn_on + entity_id: light.kitchen_lights + data: + brightness_pct: 100 + kelvin: 2000 + - conditions: + - condition: state + entity_id: input_boolean.sleep_mode + state: 'off' + sequence: + - service: light.toggle + entity_id: light.kitchen_lights + data: + brightness_pct: 100 + kelvin: 3200 + - conditions: + - condition: state + entity_id: input_select.home_mode + state: Night + sequence: + - service: light.turn_on + entity_id: light.kitchen_lights + data: + brightness_pct: 5 + kelvin: 2700 - id: kitchen-button-2 # Upper right alias: '[Kitchen] Button 2' @@ -58,6 +92,9 @@ - service: light.turn_off target: entity_id: light.hallway_light + - service: light.turn_off + target: + entity_id: light.hallway_lightstrip - id: kitchen-button-2-held # Upper right alias: '[Kitchen] Button 2 Hold' @@ -103,9 +140,27 @@ type: remote_button_short_press subtype: turn_on action: - - service: light.turn_on - data: - entity_id: light.kitchen_sink_lighstrip + - choose: + - conditions: + - condition: state + entity_id: input_boolean.sleep_mode + state: 'on' + sequence: + - service: light.turn_on + entity_id: light.kitchen_sink_lighstrip + data: + brightness_pct: 100 + kelvin: 2000 + - conditions: + - condition: state + entity_id: input_boolean.sleep_mode + state: 'off' + sequence: + - service: light.toggle + entity_id: light.kitchen_sink_lighstrip + data: + brightness_pct: 100 + kelvin: 3200 mode: single - id: kitchen-sink-button-off @@ -131,9 +186,43 @@ device_id: a47c928b108240ed8866f9f7a70bc844 command: move_with_on_off action: - - service: light.turn_on - data: - entity_id: light.kitchen_lights + - choose: + - conditions: + - condition: state + entity_id: input_select.home_mode + state: Day + sequence: + - choose: + - conditions: + - condition: state + entity_id: input_boolean.sleep_mode + state: 'on' + sequence: + - service: light.turn_on + entity_id: light.kitchen_lights + data: + brightness_pct: 100 + kelvin: 2000 + - conditions: + - condition: state + entity_id: input_boolean.sleep_mode + state: 'off' + sequence: + - service: light.toggle + entity_id: light.kitchen_lights + data: + brightness_pct: 100 + kelvin: 3200 + - conditions: + - condition: state + entity_id: input_select.home_mode + state: Night + sequence: + - service: light.turn_on + entity_id: light.kitchen_lights + data: + brightness_pct: 5 + kelvin: 2700 mode: single - id: kitchen-sink-button-hold-off diff --git a/configuration/automations/kitchen-motion.yaml b/configuration/automations/kitchen-motion.yaml index f6e99f8..cb9c273 100644 --- a/configuration/automations/kitchen-motion.yaml +++ b/configuration/automations/kitchen-motion.yaml @@ -1,46 +1,55 @@ -- id: kitchen-motion-dark - alias: '[Kitchen] Motion day dark' +- id: kitchen-lights-on + alias: '[Kitchen] Lights On' mode: single trigger: - platform: state entity_id: binary_sensor.kitchen_motion_sensor from: 'off' to: 'on' - condition: - - condition: numeric_state - entity_id: sensor.kitchen_motion_luminance - below: '25' - - condition: state - entity_id: input_select.home_mode - state: Day action: - - service: light.turn_on - entity_id: light.kitchen_lights - data: - brightness_pct: 90 - kelvin: 2000 + - choose: + - conditions: + - condition: state + entity_id: input_select.home_mode + state: Day + - condition: numeric_state + entity_id: sensor.kitchen_motion_luminance + below: '25' + sequence: + - choose: + - conditions: + - condition: state + entity_id: input_boolean.sleep_mode + state: 'on' + sequence: + - service: light.turn_on + entity_id: light.kitchen_lights + data: + brightness_pct: 100 + kelvin: 2000 + - conditions: + - condition: state + entity_id: input_boolean.sleep_mode + state: 'off' + sequence: + - service: light.toggle + entity_id: light.kitchen_lights + data: + brightness_pct: 100 + kelvin: 3200 + - conditions: + - condition: state + entity_id: input_select.home_mode + state: Night + sequence: + - service: light.turn_on + entity_id: light.kitchen_lights + data: + brightness_pct: 5 + kelvin: 2700 -- id: kitchen-motion-night - alias: '[Kitchen] Motion night' - mode: single - trigger: - - platform: state - entity_id: binary_sensor.kitchen_motion_sensor - from: 'off' - to: 'on' - condition: - - condition: state - entity_id: input_select.home_mode - state: Night - action: - - service: light.turn_on - entity_id: light.kitchen_lights - data: - brightness_pct: 5 - kelvin: 2000 - -- id: kitchen-motion-off - alias: '[Kitchen] Motion Off' +- id: kitchen-lights-off + alias: '[Kitchen] Lights Off' mode: restart trigger: - platform: state diff --git a/home-assistant.yml b/home-assistant.yml index d74365c..a30f1f7 100644 --- a/home-assistant.yml +++ b/home-assistant.yml @@ -17,10 +17,6 @@ name: Shower Lights - entityId: light.tv_lights name: TV Lights - - entityId: light.computer_computer_cave_background - name: Computer Computer Cave Background - - entityId: light.couch_lamp - name: Couch lamp - entityId: light.desk_lightbar name: Desk Lightbar - name: Concat scripts diff --git a/templates/lights.yaml.j2 b/templates/lights.yaml.j2 index fa6c0c0..6c9e362 100644 --- a/templates/lights.yaml.j2 +++ b/templates/lights.yaml.j2 @@ -1,21 +1,5 @@ {% for light in lights %} # {{ light.name }} -- id: sleep_mode_{{ light.entityId }} - alias: '[Sleep-Mode] {{ light.name }}' - trigger: - - platform: state - entity_id: {{ light.entityId }} - to: 'on' - condition: - - condition: state - entity_id: input_boolean.sleep_mode - state: 'on' - action: - - service: light.turn_on - data: - kelvin: 2000 - entity_id: {{ light.entityId }} - mode: single - id: sleep_on_{{ light.entityId }} alias: '[Sleep-On] {{ light.name }}' trigger: @@ -31,21 +15,6 @@ kelvin: 2000 entity_id: {{ light.entityId }} mode: single -- id: day_mode_{{ light.entityId }} - alias: '[Day-Mode] {{ light.name }}' - trigger: - - platform: time - at: input_datetime.day_mode - condition: - - condition: state - entity_id: {{ light.entityId }} - state: 'on' - action: - - service: light.turn_on - data: - kelvin: 3200 - entity_id: {{ light.entityId }} - mode: single - id: day_on_{{ light.entityId }} alias: '[Day-On] {{ light.name }}' trigger: