From 41a5ede2686f8a219483c8de19e868e48de90a0d Mon Sep 17 00:00:00 2001 From: Tony Stork Date: Mon, 27 Mar 2023 23:28:57 -0400 Subject: [PATCH] New "upstairs bathroom occupied" binary sensor --- node-red/projects/NerdFlows | 2 +- packages/lighting_and_scenes.yaml | 38 +++++++++++-------------------- packages/presence.yaml | 3 +++ scripts.yaml | 2 +- 4 files changed, 18 insertions(+), 27 deletions(-) diff --git a/node-red/projects/NerdFlows b/node-red/projects/NerdFlows index 52ffbb4..21060f8 160000 --- a/node-red/projects/NerdFlows +++ b/node-red/projects/NerdFlows @@ -1 +1 @@ -Subproject commit 52ffbb42ba25733c1ff249023d84c01d6b183f1e +Subproject commit 21060f85e7d16082cea02c6d2a18bff24cc5cf5e diff --git a/packages/lighting_and_scenes.yaml b/packages/lighting_and_scenes.yaml index b9be689..f629780 100644 --- a/packages/lighting_and_scenes.yaml +++ b/packages/lighting_and_scenes.yaml @@ -996,25 +996,17 @@ script: entity_id: input_boolean.shower_mode state: 'off' then: - - choose: - - conditions: - - condition: state - entity_id: binary_sensor.upstairs_bathroom_motion - state: 'on' - sequence: - - service: input_select.select_option - target: - entity_id: input_select.upstairs_bathroom_scenes - data: - option: Adaptive - - conditions: - - condition: template - value_template: "{{ is_state('binary_sensor.upstairs_bathroom_motion','off') and is_state('timer.upstairs_bathroom_motion_timer','active') }}" - sequence: - - service: timer.finish - target: - entity_id: timer.upstairs_bathroom_motion_timer - default: + - if: + - condition: state + entity_id: binary_sensor.upstairs_bathroom_occupied + state: 'on' + then: + - service: input_select.select_option + target: + entity_id: input_select.upstairs_bathroom_scenes + data: + option: Adaptive + else: - if: - condition: state entity_id: binary_sensor.early_night_mode @@ -1309,9 +1301,7 @@ script: entity_id: input_select.upstairs_bathroom_scenes data: option: > - {% if is_state('binary_sensor.upstairs_bathroom_motion','on') %} - Adaptive - {% elif is_state('timer.upstairs_bathroom_motion_timer','active') %} + {% if is_state('binary_sensor.upstairs_bathroom_occupied','on') %} Adaptive {% else %} Nightlight @@ -1366,9 +1356,7 @@ script: entity_id: input_select.upstairs_bathroom_scenes data: option: > - {% if is_state('binary_sensor.upstairs_bathroom_motion','on') %} - Adaptive - {% elif is_state('timer.upstairs_bathroom_motion_timer','active') %} + {% if is_state('binary_sensor.upstairs_bathroom_occupied','on') %} Adaptive {% else %} Nightlight diff --git a/packages/presence.yaml b/packages/presence.yaml index 065c6b8..d50cc6d 100644 --- a/packages/presence.yaml +++ b/packages/presence.yaml @@ -273,6 +273,9 @@ template: {% else %} false {% endif %} + - name: "Upstairs Bathroom Occupied" + unique_id: 7ec69a26-1013-4b0d-8662-a91ab9f040ca + state: "{{ is_state('timer.upstairs_bathroom_motion_timer','active') or is_state('binary_sensor.upstairs_bathroom_motion','on') or is_state('input_boolean.shower_mode','on') }}" mqtt: sensor: diff --git a/scripts.yaml b/scripts.yaml index df02deb..ff622ae 100644 --- a/scripts.yaml +++ b/scripts.yaml @@ -302,7 +302,7 @@ going_upstairs: target: entity_id: light.basement_studio_lights alias: Turn off the lights - - wait_template: '{{ is_state(''binary_sensor.upstairs_bathroom_motion'',''on'') + - wait_template: '{{ is_state(''binary_sensor.upstairs_bathroom_occupied'',''on'') or is_state(''input_boolean.goodnight'',''on'') }}' timeout: 00:10:00 alias: Wait until I'm in the bathroom or in bed