From 8e93e14df1d436f4a5bbe8c125f2aae7ad106dd6 Mon Sep 17 00:00:00 2001 From: Przemek Grondek Date: Sat, 22 Apr 2023 20:03:39 +0200 Subject: [PATCH] Switch to presence sensor --- configuration/automations/hallway.yaml | 2 +- configuration/automations/kitchen-motion.yaml | 66 ++++++++++--------- .../automations/living-room-button.yaml | 51 +------------- .../automations/living-room-presence.yaml | 25 +++++++ .../automations/office-brightness.yaml | 5 +- .../automations/office-presence.yaml | 25 +++++++ configuration/automations/table-presence.yaml | 25 +++++++ scripts/96.lights-living-room.yaml | 66 +++++++++++++++++++ 8 files changed, 183 insertions(+), 82 deletions(-) create mode 100644 configuration/automations/living-room-presence.yaml create mode 100644 configuration/automations/office-presence.yaml create mode 100644 configuration/automations/table-presence.yaml create mode 100644 scripts/96.lights-living-room.yaml diff --git a/configuration/automations/hallway.yaml b/configuration/automations/hallway.yaml index bc62872..421d817 100644 --- a/configuration/automations/hallway.yaml +++ b/configuration/automations/hallway.yaml @@ -34,7 +34,7 @@ condition: - condition: numeric_state entity_id: sensor.office_illuminance - below: '170' + below: '200' action: - service: script.hallway_lights_on diff --git a/configuration/automations/kitchen-motion.yaml b/configuration/automations/kitchen-motion.yaml index c38cd7f..ae45d29 100644 --- a/configuration/automations/kitchen-motion.yaml +++ b/configuration/automations/kitchen-motion.yaml @@ -2,19 +2,22 @@ alias: '[Kitchen] Lights On' mode: single trigger: +# - platform: state +# entity_id: binary_sensor.kitchen_motion_sensor +# from: 'off' +# to: 'on' +# - platform: state +# entity_id: binary_sensor.kitchen_tabletop_motion_detection +# to: 'on' - platform: state - entity_id: binary_sensor.kitchen_motion_sensor - from: 'off' - to: 'on' - - platform: state - entity_id: binary_sensor.kitchen_tabletop_motion_detection + entity_id: binary_sensor.presence_sensor_fp2_kitchen to: 'on' action: - choose: - conditions: - condition: numeric_state entity_id: sensor.office_illuminance - below: '170' + below: '200' sequence: - service: script.kitchen_lights_on @@ -23,30 +26,33 @@ mode: restart trigger: - platform: state - entity_id: binary_sensor.kitchen_motion_sensor - for: '0:02:00' - from: 'on' + entity_id: binary_sensor.presence_sensor_fp2_kitchen to: 'off' - - platform: state - entity_id: binary_sensor.kitchen_sink_motion_sensor - to: 'off' - for: '0:02:00' - - platform: state - entity_id: binary_sensor.kitchen_tabletop_motion_detection - to: 'off' - for: '0:02:00' - condition: - - condition: state - entity_id: binary_sensor.kitchen_motion_sensor - state: 'off' - for: '0:02:00' - - condition: state - entity_id: binary_sensor.kitchen_sink_motion_sensor - state: 'off' - for: '0:02:00' - - condition: state - entity_id: binary_sensor.kitchen_tabletop_motion_detection - state: 'off' - for: '0:02:00' +# - platform: state +# entity_id: binary_sensor.kitchen_motion_sensor +# for: '0:02:00' +# from: 'on' +# to: 'off' +# - platform: state +# entity_id: binary_sensor.kitchen_sink_motion_sensor +# to: 'off' +# for: '0:02:00' +# - platform: state +# entity_id: binary_sensor.kitchen_tabletop_motion_detection +# to: 'off' +# for: '0:02:00' +# condition: +# - condition: state +# entity_id: binary_sensor.kitchen_motion_sensor +# state: 'off' +# for: '0:02:00' +# - condition: state +# entity_id: binary_sensor.kitchen_sink_motion_sensor +# state: 'off' +# for: '0:02:00' +# - condition: state +# entity_id: binary_sensor.kitchen_tabletop_motion_detection +# state: 'off' +# for: '0:02:00' action: - service: script.kitchen_lights_off diff --git a/configuration/automations/living-room-button.yaml b/configuration/automations/living-room-button.yaml index 0fb3088..5576776 100644 --- a/configuration/automations/living-room-button.yaml +++ b/configuration/automations/living-room-button.yaml @@ -23,56 +23,7 @@ type: remote_button_alt_short_press subtype: button_2 action: - - choose: - - conditions: - - condition: state - entity_id: light.couch_lights - state: 'on' - sequence: - - service: light.turn_off - entity_id: light.couch_lights - - conditions: - - condition: state - entity_id: light.couch_lights - state: 'off' - sequence: - - 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.couch_lights - data: - brightness_pct: 100 - kelvin: 2000 - - conditions: - - condition: state - entity_id: input_boolean.sleep_mode - state: 'off' - sequence: - - service: light.turn_on - entity_id: light.couch_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.couch_lights - data: - brightness_pct: 5 - kelvin: 2700 + - service: script.living_room_lights_toggle - id: living-room-button-3 # Middle left alias: '[Living Room] Button 3 - AndroidTV' diff --git a/configuration/automations/living-room-presence.yaml b/configuration/automations/living-room-presence.yaml new file mode 100644 index 0000000..6bf589f --- /dev/null +++ b/configuration/automations/living-room-presence.yaml @@ -0,0 +1,25 @@ +- id: living-room-lights-on + alias: '[Living Room] Lights On' + mode: single + trigger: + - platform: state + entity_id: binary_sensor.presence_sensor_fp2_couch + to: 'on' + action: + - choose: + - conditions: + - condition: numeric_state + entity_id: sensor.office_illuminance + below: '200' + sequence: + - service: script.living_room_lights_on + +- id: living-room-lights-off + alias: '[Living Room] Lights Off' + mode: restart + trigger: + - platform: state + entity_id: binary_sensor.presence_sensor_fp2_couch + to: 'off' + action: + - service: script.living_room_lights_off diff --git a/configuration/automations/office-brightness.yaml b/configuration/automations/office-brightness.yaml index c074cc3..3977d73 100644 --- a/configuration/automations/office-brightness.yaml +++ b/configuration/automations/office-brightness.yaml @@ -26,7 +26,7 @@ trigger: - platform: numeric_state entity_id: sensor.office_illuminance - below: '170' + below: '200' for: hours: 0 minutes: 5 @@ -43,6 +43,9 @@ - condition: state entity_id: device_tracker.amdn4684 state: 'home' + - condition: state + entity_id: binary_sensor.presence_sensor_fp2_office + state: 'on' - condition: state entity_id: input_select.home_mode state: Day diff --git a/configuration/automations/office-presence.yaml b/configuration/automations/office-presence.yaml new file mode 100644 index 0000000..5745859 --- /dev/null +++ b/configuration/automations/office-presence.yaml @@ -0,0 +1,25 @@ +- id: office-lights-on + alias: '[Office] Lights On' + mode: single + trigger: + - platform: state + entity_id: binary_sensor.presence_sensor_fp2_office + to: 'on' + action: + - choose: + - conditions: + - condition: numeric_state + entity_id: sensor.office_illuminance + below: '200' + sequence: + - service: script.office_lights_on + +- id: office-lights-off + alias: '[Office] Lights Off' + mode: restart + trigger: + - platform: state + entity_id: binary_sensor.presence_sensor_fp2_office + to: 'off' + action: + - service: script.office_lights_off diff --git a/configuration/automations/table-presence.yaml b/configuration/automations/table-presence.yaml new file mode 100644 index 0000000..832b555 --- /dev/null +++ b/configuration/automations/table-presence.yaml @@ -0,0 +1,25 @@ +- id: table-lights-on + alias: '[Table] Lights On' + mode: single + trigger: + - platform: state + entity_id: binary_sensor.presence_sensor_fp2_table + to: 'on' + action: + - choose: + - conditions: + - condition: numeric_state + entity_id: sensor.office_illuminance + below: '200' + sequence: + - service: script.table_lights_on + +- id: table-lights-off + alias: '[Table] Lights Off' + mode: restart + trigger: + - platform: state + entity_id: binary_sensor.presence_sensor_fp2_table + to: 'off' + action: + - service: script.table_lights_off diff --git a/scripts/96.lights-living-room.yaml b/scripts/96.lights-living-room.yaml new file mode 100644 index 0000000..48d7bb4 --- /dev/null +++ b/scripts/96.lights-living-room.yaml @@ -0,0 +1,66 @@ +living_room_lights_toggle: + alias: '[Living Room] Lights toggle' + sequence: + - choose: + - conditions: + - condition: state + entity_id: light.table_lamp_lights + state: 'on' + sequence: + living_room_ice: script.table_lights_off + - conditions: + - condition: state + entity_id: light.table_lamp_lights + state: 'off' + sequence: + living_room_ice: script.table_lights_on + +living_room_lights_on: + alias: '[Living Room] Lights on' + sequence: + - 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.couch_lights + data: + brightness_pct: 100 + kelvin: 2000 + - conditions: + - condition: state + entity_id: input_boolean.sleep_mode + state: 'off' + sequence: + - service: light.turn_on + entity_id: light.couch_lights + data: + brightness_pct: 100 + kelvin: 3200 + - conditions: + - condition: state + entity_id: input_select.home_mode + state: Night + sequence: + - service: light.turn_on + data: + brightness_pct: 40 + hs_color: + - 360 + - 100 + target: + entity_id: light.couch_lights + +living_room_lights_off: + alias: '[Living Room] Lights off' + sequence: + - service: light.turn_off + entity_id: light.couch_lights