Upgrade/Fix: Quit motion-off sequences immediately when enabled_helper goes off

This commit is contained in:
mike 2023-12-19 23:33:39 -08:00
parent 0f41bf3f6a
commit 3534adff19

View File

@ -260,6 +260,7 @@ action:
name: "Enabled helper" name: "Enabled helper"
message: "Enabled helper name is: {{ enabled_helper }}" message: "Enabled helper name is: {{ enabled_helper }}"
# Action #2 # Action #2
- alias: "Debug log the current delay_seconds value" - alias: "Debug log the current delay_seconds value"
if: if:
@ -271,6 +272,7 @@ action:
name: "Delay seconds" name: "Delay seconds"
message: "Delay seconds is: {{ states[delay_seconds_helper].state }}" message: "Delay seconds is: {{ states[delay_seconds_helper].state }}"
# Action #3 # Action #3
- alias: "Debug log the on_just_before_off_seconds value" - alias: "Debug log the on_just_before_off_seconds value"
if: if:
@ -291,7 +293,7 @@ action:
- Enabled helper is on - Enabled helper is on
- Enabled helper is off - Enabled helper is off
then: then:
# Debug log # Debug log
- alias: "Debug log - Enabled Helper On/Off" - alias: "Debug log - Enabled Helper On/Off"
if: if:
@ -318,7 +320,7 @@ action:
- alias: "auto mode: Activate ON scene, if motion is currently detected, otherwise activate the OFF scene" - alias: "auto mode: Activate ON scene, if motion is currently detected, otherwise activate the OFF scene"
if: if:
- condition: template - condition: template
value_template: "{{ disabled_scene == 'auto' or is_state( enabled_helper, 'on' ) }}" value_template: "{{ disabled_scene == 'auto' or (enabled_helper != None and is_state( enabled_helper, 'on' )) }}"
then: then:
- if: - if:
- condition: state - condition: state
@ -394,7 +396,7 @@ action:
# Take actions based on whether Motion is detected # Take actions based on whether Motion is detected
- alias: "Refuse to do anything if the enabled-helper says we're OFF." - alias: "Refuse to do anything if the enabled-helper says we're OFF."
if: if:
- condition: template - condition: template
value_template: "{{ enabled_helper != None }}" value_template: "{{ enabled_helper != None }}"
- condition: template - condition: template
@ -445,7 +447,17 @@ action:
# Initial period where nothing happens # Initial period where nothing happens
- alias: "Delay appropriately before doing anything" - alias: "Delay appropriately before doing anything"
wait_template: "{{ states[motion_sensor].state == 'on' }}" wait_template: "{{ states[motion_sensor].state == 'on' }}"
timeout: "{{ states[delay_seconds_helper].state }}" timeout: "{{ states[delay_seconds_helper].state or (enabled_helper != None and is_state(enabled_helper, 'off') ) }}"
- alias: "Quit now if the enabled-helper went OFF"
if:
- condition: template
value_template: "{{ enabled_helper != None }}"
- condition: template
value_template: "{{ is_state( enabled_helper, 'off' ) }}"
then:
stop: "Quitting early because the enabled-helper went OFF."
- if: - if:
- condition: state - condition: state
entity_id: !input motion_sensor entity_id: !input motion_sensor
@ -480,8 +492,19 @@ action:
target: target:
entity_id: !input scene_notice entity_id: !input scene_notice
- alias: "Delay during the notice period" - alias: "Delay during the notice period"
wait_template: "{{ states[motion_sensor].state == 'on' }}" wait_template: "{{ states[motion_sensor].state == 'on' or (enabled_helper != None and is_state('enabled_helper', 'off') ) }}"
timeout: "{{ notice_seconds }}" timeout: "{{ notice_seconds }}"
- alias: "Quit now if the enabled-helper went OFF"
if:
- condition: template
value_template: "{{ enabled_helper != None }}"
- condition: template
value_template: "{{ is_state( enabled_helper, 'off' ) }}"
then:
stop: "Quitting early because the enabled-helper went OFF."
- if: - if:
- condition: state - condition: state
entity_id: !input motion_sensor entity_id: !input motion_sensor
@ -550,8 +573,21 @@ action:
target: target:
entity_id: !input scene_warning entity_id: !input scene_warning
- alias: "Delay during the warning period" - alias: "Delay during the warning period"
wait_template: "{{ states[motion_sensor].state == 'on' }}" wait_template: "{{ states[motion_sensor].state == 'on' or (enabled_helper != None and is_state('enabled_helper', 'off') ) }}"
timeout: "{{ warning_seconds }}" timeout: "{{ warning_seconds }}"
- alias: "Quit now if the enabled-helper went OFF"
if:
- condition: template
value_template: "{{ enabled_helper != None }}"
- condition: template
value_template: "{{ is_state( enabled_helper, 'off' ) }}"
then:
stop: "Quitting early because the enabled-helper went OFF."
- if: - if:
- condition: state - condition: state
entity_id: !input motion_sensor entity_id: !input motion_sensor