From 91b59ef6eb7193d9f4824685b49cf017b14c8497 Mon Sep 17 00:00:00 2001 From: Georgi Gardev Date: Fri, 1 May 2020 22:59:53 +0300 Subject: [PATCH] Split lighting module automations by rooms --- .../modules/lighting/by_rooms/hallway.yaml | 73 ++++++++ .../modules/lighting/by_rooms/kitchen.yaml | 66 +++++++ .../lighting/by_rooms/master_bedroom.yaml | 28 +++ .../lighting/{ => setup}/connectors.yaml | 0 .../modules/lighting/{ => setup}/groups.yaml | 0 .../modules/lighting/{ => setup}/mqtt.yaml | 0 .../modules/lighting/{ => setup}/tuya.yaml | 0 .../modules/lighting/{ => setup}/zha.yaml | 0 config/packages/modules/lighting/state.yaml | 166 ------------------ 9 files changed, 167 insertions(+), 166 deletions(-) create mode 100644 config/packages/modules/lighting/by_rooms/hallway.yaml create mode 100644 config/packages/modules/lighting/by_rooms/kitchen.yaml create mode 100644 config/packages/modules/lighting/by_rooms/master_bedroom.yaml rename config/packages/modules/lighting/{ => setup}/connectors.yaml (100%) rename config/packages/modules/lighting/{ => setup}/groups.yaml (100%) rename config/packages/modules/lighting/{ => setup}/mqtt.yaml (100%) rename config/packages/modules/lighting/{ => setup}/tuya.yaml (100%) rename config/packages/modules/lighting/{ => setup}/zha.yaml (100%) diff --git a/config/packages/modules/lighting/by_rooms/hallway.yaml b/config/packages/modules/lighting/by_rooms/hallway.yaml new file mode 100644 index 0000000..70f7588 --- /dev/null +++ b/config/packages/modules/lighting/by_rooms/hallway.yaml @@ -0,0 +1,73 @@ +automation: + - alias: Lighting · Hallway · Day mode · Motion · Turn lights on + trigger: + platform: state + entity_id: binary_sensor.motion_2_ias_zone + to: "on" + condition: + condition: and + conditions: + - condition: state + entity_id: input_select.house_mode + state: 'day' + - condition: state + entity_id: sun.sun + state: 'below_horizon' + action: + - service: light.turn_on + entity_id: light.hallway_all_lights + + - alias: Lighting · Hallway · Day mode · Motion · Turn lights off + trigger: + platform: state + entity_id: binary_sensor.motion_2_ias_zone + to: "off" + for: + minutes: 5 + condition: + condition: state + entity_id: input_select.house_mode + state: 'day' + action: + - service: light.turn_off + entity_id: light.hallway_all_lights + + - alias: Lighting · Hallway · Night mode · Motion · Turn lights on + trigger: + platform: state + entity_id: binary_sensor.motion_2_ias_zone + to: "on" + condition: + condition: template + value_template: "{{ not is_state('input_select.house_mode', 'day') }}" + action: + - service: light.turn_on + entity_id: light.light_lohas_6 + data: + brightness_pct: 30 + - service: light.turn_on + entity_id: light.light_le_8 + data: + brightness_pct: 13 + + - alias: Lighting · Hallway · Night mode · Motion · Turn lights off + trigger: + platform: state + entity_id: binary_sensor.motion_2_ias_zone + to: "off" + for: + minutes: 5 + condition: + condition: template + value_template: "{{ not is_state('input_select.house_mode', 'day') }}" + action: + - service: light.turn_on + entity_id: + - light.light_le_8 + - light.light_lohas_6 + data: + brightness_pct: 100 + - service: light.turn_off + entity_id: + - light.light_lohas_6 + - light.light_le_8 diff --git a/config/packages/modules/lighting/by_rooms/kitchen.yaml b/config/packages/modules/lighting/by_rooms/kitchen.yaml new file mode 100644 index 0000000..feb4519 --- /dev/null +++ b/config/packages/modules/lighting/by_rooms/kitchen.yaml @@ -0,0 +1,66 @@ +automation: + - alias: Lighting · Kitchen · Day mode · Motion · Turn lights on after sunset + trigger: + platform: state + entity_id: binary_sensor.motion_1_ias_zone + to: "on" + condition: + condition: and + conditions: + - condition: state + entity_id: input_select.house_mode + state: 'day' + - condition: state + entity_id: sun.sun + state: 'below_horizon' + action: + - service: light.turn_on + entity_id: light.tuya_kitchen_all_lights + + - alias: Lighting · Kitchen · Day mode · Motion · Turn lights off + trigger: + platform: state + entity_id: binary_sensor.motion_1_ias_zone + to: "off" + for: + minutes: 30 + condition: + condition: state + entity_id: input_select.house_mode + state: 'day' + action: + - service: light.turn_off + entity_id: light.tuya_kitchen_all_lights + + + - alias: Lighting · Kitchen · Night mode · Motion · Turn lights on + trigger: + platform: state + entity_id: binary_sensor.motion_1_ias_zone + to: "on" + condition: + condition: template + value_template: "{{ not is_state('input_select.house_mode', 'day') }}" + action: + - service: light.turn_on + entity_id: light.light_le_12 + data: + brightness_pct: 13 # this is the lowest it'll go ¯\_(ツ)_/¯ + + - alias: Lighting · Kitchen · Night mode · Motion · Turn lights off + trigger: + platform: state + entity_id: binary_sensor.motion_1_ias_zone + to: "off" + for: + minutes: 5 + condition: + condition: template + value_template: "{{ not is_state('input_select.house_mode', 'day') }}" + action: + - service: light.turn_on + entity_id: light.light_le_12 + data: + brightness_pct: 100 + - service: light.turn_off + entity_id: light.light_le_12 diff --git a/config/packages/modules/lighting/by_rooms/master_bedroom.yaml b/config/packages/modules/lighting/by_rooms/master_bedroom.yaml new file mode 100644 index 0000000..c773b61 --- /dev/null +++ b/config/packages/modules/lighting/by_rooms/master_bedroom.yaml @@ -0,0 +1,28 @@ +automation: + - alias: Lighting · Master bedroom · Toggle lights on bedside switch single click + trigger: + platform: event + event_type: zha_event + event_data: + device_ieee: !secret master_bedroom_bedside_switch_ieee + command: single + action: + - service: light.toggle + data_template: + entity_id: >- + + {% if is_state('input_select.house_mode', 'day') %} + light.master_bedroom_main_lights + {% elif is_state('input_select.house_mode', 'bed') %} + light.bedside_light, light.bed_led + {% elif is_state('input_select.house_mode', 'night') %} + light.bed_led + {% endif %} + brightness_pct: >- + + {% if is_state('input_select.house_mode', 'night') %} + 40 + {% else %} + 100 + {% endif %} + diff --git a/config/packages/modules/lighting/connectors.yaml b/config/packages/modules/lighting/setup/connectors.yaml similarity index 100% rename from config/packages/modules/lighting/connectors.yaml rename to config/packages/modules/lighting/setup/connectors.yaml diff --git a/config/packages/modules/lighting/groups.yaml b/config/packages/modules/lighting/setup/groups.yaml similarity index 100% rename from config/packages/modules/lighting/groups.yaml rename to config/packages/modules/lighting/setup/groups.yaml diff --git a/config/packages/modules/lighting/mqtt.yaml b/config/packages/modules/lighting/setup/mqtt.yaml similarity index 100% rename from config/packages/modules/lighting/mqtt.yaml rename to config/packages/modules/lighting/setup/mqtt.yaml diff --git a/config/packages/modules/lighting/tuya.yaml b/config/packages/modules/lighting/setup/tuya.yaml similarity index 100% rename from config/packages/modules/lighting/tuya.yaml rename to config/packages/modules/lighting/setup/tuya.yaml diff --git a/config/packages/modules/lighting/zha.yaml b/config/packages/modules/lighting/setup/zha.yaml similarity index 100% rename from config/packages/modules/lighting/zha.yaml rename to config/packages/modules/lighting/setup/zha.yaml diff --git a/config/packages/modules/lighting/state.yaml b/config/packages/modules/lighting/state.yaml index 1ed46ea..eccae4e 100644 --- a/config/packages/modules/lighting/state.yaml +++ b/config/packages/modules/lighting/state.yaml @@ -22,169 +22,3 @@ automation: action: - service: light.turn_off entity_id: light.all_lights - - - alias: Lighting · Master bedroom · Toggle lights on bedside switch single click - trigger: - platform: event - event_type: zha_event - event_data: - device_ieee: !secret master_bedroom_bedside_switch_ieee - command: single - action: - - service: light.toggle - data_template: - entity_id: >- - - {% if is_state('input_select.house_mode', 'day') %} - light.master_bedroom_main_lights - {% elif is_state('input_select.house_mode', 'bed') %} - light.bedside_light, light.bed_led - {% elif is_state('input_select.house_mode', 'night') %} - light.bed_led - {% endif %} - brightness_pct: >- - - {% if is_state('input_select.house_mode', 'night') %} - 40 - {% else %} - 100 - {% endif %} - - - alias: Lighting · Kitchen · Day mode · Motion · Turn lights on after sunset - trigger: - platform: state - entity_id: binary_sensor.motion_1_ias_zone - to: "on" - condition: - condition: and - conditions: - - condition: state - entity_id: input_select.house_mode - state: 'day' - - condition: state - entity_id: sun.sun - state: 'below_horizon' - action: - - service: light.turn_on - entity_id: light.tuya_kitchen_all_lights - - - alias: Lighting · Kitchen · Day mode · Motion · Turn lights off - trigger: - platform: state - entity_id: binary_sensor.motion_1_ias_zone - to: "off" - for: - minutes: 30 - condition: - condition: state - entity_id: input_select.house_mode - state: 'day' - action: - - service: light.turn_off - entity_id: light.tuya_kitchen_all_lights - - - - alias: Lighting · Kitchen · Night mode · Motion · Turn lights on - trigger: - platform: state - entity_id: binary_sensor.motion_1_ias_zone - to: "on" - condition: - condition: template - value_template: "{{ not is_state('input_select.house_mode', 'day') }}" - action: - - service: light.turn_on - entity_id: light.light_le_12 - data: - brightness_pct: 13 # this is the lowest it'll go ¯\_(ツ)_/¯ - - - alias: Lighting · Kitchen · Night mode · Motion · Turn lights off - trigger: - platform: state - entity_id: binary_sensor.motion_1_ias_zone - to: "off" - for: - minutes: 5 - condition: - condition: template - value_template: "{{ not is_state('input_select.house_mode', 'day') }}" - action: - - service: light.turn_on - entity_id: light.light_le_12 - data: - brightness_pct: 100 - - service: light.turn_off - entity_id: light.light_le_12 - - - alias: Lighting · Hallway · Day mode · Motion · Turn lights on - trigger: - platform: state - entity_id: binary_sensor.motion_2_ias_zone - to: "on" - condition: - condition: and - conditions: - - condition: state - entity_id: input_select.house_mode - state: 'day' - - condition: state - entity_id: sun.sun - state: 'below_horizon' - action: - - service: light.turn_on - entity_id: light.hallway_all_lights - - - alias: Lighting · Hallway · Day mode · Motion · Turn lights off - trigger: - platform: state - entity_id: binary_sensor.motion_2_ias_zone - to: "off" - for: - minutes: 5 - condition: - condition: state - entity_id: input_select.house_mode - state: 'day' - action: - - service: light.turn_off - entity_id: light.hallway_all_lights - - - alias: Lighting · Hallway · Night mode · Motion · Turn lights on - trigger: - platform: state - entity_id: binary_sensor.motion_2_ias_zone - to: "on" - condition: - condition: template - value_template: "{{ not is_state('input_select.house_mode', 'day') }}" - action: - - service: light.turn_on - entity_id: light.light_lohas_6 - data: - brightness_pct: 30 - - service: light.turn_on - entity_id: light.light_le_8 - data: - brightness_pct: 13 - - - alias: Lighting · Hallway · Night mode · Motion · Turn lights off - trigger: - platform: state - entity_id: binary_sensor.motion_2_ias_zone - to: "off" - for: - minutes: 5 - condition: - condition: template - value_template: "{{ not is_state('input_select.house_mode', 'day') }}" - action: - - service: light.turn_on - entity_id: - - light.light_le_8 - - light.light_lohas_6 - data: - brightness_pct: 100 - - service: light.turn_off - entity_id: - - light.light_lohas_6 - - light.light_le_8