Bugfixes and upgrades:
- Fix bug where initial timeout wouldn't be interruptted by enabled_helper - Turned scene repeat delay into a variable (non-input for now) - Fixed enabled_helper==off not repeating the ON scene - Tried clarifying some logs, aliases, comments
This commit is contained in:
parent
7626c05ad2
commit
832a71380f
@ -210,6 +210,7 @@ variables:
|
|||||||
debug_mode: !input debug_mode
|
debug_mode: !input debug_mode
|
||||||
|
|
||||||
scene_repeat_count: !input scene_repeat_count
|
scene_repeat_count: !input scene_repeat_count
|
||||||
|
scene_repeat_delay_milliseconds: 500
|
||||||
|
|
||||||
trigger_variables:
|
trigger_variables:
|
||||||
enabled_helper: !input enabled_helper
|
enabled_helper: !input enabled_helper
|
||||||
@ -311,6 +312,12 @@ action:
|
|||||||
|
|
||||||
# If the enabled helper is OFF, we should start by resetting
|
# If the enabled helper is OFF, we should start by resetting
|
||||||
# the countdown timer to default
|
# the countdown timer to default
|
||||||
|
- alias: "If the enabled helper is OFF, reset countdown timer to default"
|
||||||
|
if:
|
||||||
|
- condition: trigger
|
||||||
|
id:
|
||||||
|
- Enabled Helper is off
|
||||||
|
then:
|
||||||
- alias: "Reset countdown timer when enabled helper is switched OFF."
|
- alias: "Reset countdown timer when enabled helper is switched OFF."
|
||||||
service: input_number.set_value
|
service: input_number.set_value
|
||||||
data:
|
data:
|
||||||
@ -330,18 +337,30 @@ action:
|
|||||||
state: "on"
|
state: "on"
|
||||||
then:
|
then:
|
||||||
- alias: "Activate the ON scene"
|
- alias: "Activate the ON scene"
|
||||||
service: scene.turn_on
|
repeat:
|
||||||
|
count: "{{ scene_repeat_count }}"
|
||||||
|
sequence:
|
||||||
|
- service: scene.turn_on
|
||||||
target:
|
target:
|
||||||
entity_id: !input scene_on
|
entity_id: !input scene_on
|
||||||
|
- delay:
|
||||||
|
milliseconds: "{{ scene_repeat_delay_milliseconds }}"
|
||||||
else:
|
else:
|
||||||
- alias: "Activate the OFF scene"
|
- alias: "Activate the OFF scene"
|
||||||
service: scene.turn_on
|
repeat:
|
||||||
|
count: "{{ scene_repeat_count }}"
|
||||||
|
sequence:
|
||||||
|
- service: scene.turn_on
|
||||||
target:
|
target:
|
||||||
entity_id: !input scene_off
|
entity_id: !input scene_off
|
||||||
- stop: ""
|
- delay:
|
||||||
|
milliseconds: "{{ scene_repeat_delay_milliseconds }}"
|
||||||
|
- stop: "Enabled helper was on or auto mode was on; Determined scene to activate based on current motion."
|
||||||
|
|
||||||
# In ON mode, just activate the ON scene
|
# At this point, the enabled helper is assumed to be OFF
|
||||||
- alias: "on mode: just activate the ON scene"
|
|
||||||
|
# In disabled_scene::ON mode, just activate the ON scene
|
||||||
|
- alias: "disabled_scene::on mode: just activate the ON scene"
|
||||||
if:
|
if:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ disabled_scene == 'on' }}"
|
value_template: "{{ disabled_scene == 'on' }}"
|
||||||
@ -353,11 +372,11 @@ action:
|
|||||||
target:
|
target:
|
||||||
entity_id: !input scene_on
|
entity_id: !input scene_on
|
||||||
- delay:
|
- delay:
|
||||||
milliseconds: 500
|
milliseconds: "{{ scene_repeat_delay_milliseconds }}"
|
||||||
- stop: ""
|
- stop: "Enabled helper is off and disabled scene was ON; Set ON scene"
|
||||||
|
|
||||||
# In OFF mode, just activate the OFF scene
|
# In disabled_scene::OFF mode, just activate the OFF scene
|
||||||
- alias: "off mode: just activate the ON scene"
|
- alias: "disabled_scene::off mode: just activate the OFF scene"
|
||||||
if:
|
if:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ disabled_scene == 'off' }}"
|
value_template: "{{ disabled_scene == 'off' }}"
|
||||||
@ -369,11 +388,11 @@ action:
|
|||||||
target:
|
target:
|
||||||
entity_id: !input scene_off
|
entity_id: !input scene_off
|
||||||
- delay:
|
- delay:
|
||||||
milliseconds: 500
|
milliseconds: "{{ scene_repeat_delay_milliseconds }}"
|
||||||
- stop: ""
|
- stop: "Enabled helper is off and disabled scene was OFF; Set OFF scene"
|
||||||
|
|
||||||
# In notice mode, just activate the NOTICE scene
|
# In disabled_scene::notice mode, just activate the NOTICE scene
|
||||||
- alias: "notice mode: just activate the NOTICE scene"
|
- alias: "disabled_scene::notice mode: just activate the NOTICE scene"
|
||||||
if:
|
if:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ disabled_scene == 'notice' }}"
|
value_template: "{{ disabled_scene == 'notice' }}"
|
||||||
@ -385,11 +404,11 @@ action:
|
|||||||
target:
|
target:
|
||||||
entity_id: !input scene_notice
|
entity_id: !input scene_notice
|
||||||
- delay:
|
- delay:
|
||||||
milliseconds: 500
|
milliseconds: "{{ scene_repeat_delay_milliseconds }}"
|
||||||
- stop: ""
|
- stop: "Enabled helper is off and disabled scene was NOTICE; Set NOTICE scene"
|
||||||
|
|
||||||
# In warning mode, just activate the WARNING scene
|
# In disabled_scene::warning mode, just activate the WARNING scene
|
||||||
- alias: "warning mode: just activate the WARNING scene"
|
- alias: "disabed_scene::warning mode: just activate the WARNING scene"
|
||||||
if:
|
if:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ disabled_scene == 'warning' }}"
|
value_template: "{{ disabled_scene == 'warning' }}"
|
||||||
@ -401,8 +420,8 @@ action:
|
|||||||
target:
|
target:
|
||||||
entity_id: !input scene_warning
|
entity_id: !input scene_warning
|
||||||
- delay:
|
- delay:
|
||||||
milliseconds: 500
|
milliseconds: "{{ scene_repeat_delay_milliseconds }}"
|
||||||
- stop: ""
|
- stop: "Enabled helper is off and disabled scene was WATNING; Set WARNING scene"
|
||||||
|
|
||||||
# Don't do anything after processing the enabled_helper triggers
|
# Don't do anything after processing the enabled_helper triggers
|
||||||
- stop: "Done handling enabled helper"
|
- stop: "Done handling enabled helper"
|
||||||
@ -448,7 +467,7 @@ action:
|
|||||||
target:
|
target:
|
||||||
entity_id: !input scene_on
|
entity_id: !input scene_on
|
||||||
- delay:
|
- delay:
|
||||||
milliseconds: 500
|
milliseconds: "{{ scene_repeat_delay_milliseconds }}"
|
||||||
|
|
||||||
|
|
||||||
# Motion is not detected
|
# Motion is not detected
|
||||||
@ -467,8 +486,8 @@ 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' or (enabled_helper != None and is_state(enabled_helper, 'off') ) }}"
|
||||||
timeout: "{{ states[delay_seconds_helper].state or (enabled_helper != None and is_state(enabled_helper, 'off') ) }}"
|
timeout: "{{ states[delay_seconds_helper].state }}"
|
||||||
|
|
||||||
- alias: "Quit now if the enabled-helper went OFF"
|
- alias: "Quit now if the enabled-helper went OFF"
|
||||||
if:
|
if:
|
||||||
@ -477,9 +496,10 @@ action:
|
|||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ is_state( enabled_helper, 'off' ) }}"
|
value_template: "{{ is_state( enabled_helper, 'off' ) }}"
|
||||||
then:
|
then:
|
||||||
stop: "Quitting early because the enabled-helper went OFF."
|
stop: "Interrupted initial delay because the enabled helper turned OFF."
|
||||||
|
|
||||||
- if:
|
- alias: "Motion detected again during initial delay; Interrupt initial delay"
|
||||||
|
if:
|
||||||
- condition: state
|
- condition: state
|
||||||
entity_id: !input motion_sensor
|
entity_id: !input motion_sensor
|
||||||
state: "on"
|
state: "on"
|
||||||
@ -516,7 +536,7 @@ action:
|
|||||||
target:
|
target:
|
||||||
entity_id: !input scene_notice
|
entity_id: !input scene_notice
|
||||||
- delay:
|
- delay:
|
||||||
milliseconds: 500
|
milliseconds: "{{ scene_repeat_delay_milliseconds }}"
|
||||||
|
|
||||||
- alias: "Delay during the notice period"
|
- alias: "Delay during the notice period"
|
||||||
wait_template: "{{ states[motion_sensor].state == 'on' or (enabled_helper != None and is_state('enabled_helper', 'off') ) }}"
|
wait_template: "{{ states[motion_sensor].state == 'on' or (enabled_helper != None and is_state('enabled_helper', 'off') ) }}"
|
||||||
@ -529,10 +549,11 @@ action:
|
|||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ is_state( enabled_helper, 'off' ) }}"
|
value_template: "{{ is_state( enabled_helper, 'off' ) }}"
|
||||||
then:
|
then:
|
||||||
stop: "Quitting early because the enabled-helper went OFF."
|
stop: "Interrupting NOTICE period because the enabled-helper went OFF."
|
||||||
|
|
||||||
|
|
||||||
- if:
|
- alias: "If motion interrupted the NOTICE period, activate the ON scene"
|
||||||
|
if:
|
||||||
- condition: state
|
- condition: state
|
||||||
entity_id: !input motion_sensor
|
entity_id: !input motion_sensor
|
||||||
state: "on"
|
state: "on"
|
||||||
@ -604,7 +625,7 @@ action:
|
|||||||
target:
|
target:
|
||||||
entity_id: !input scene_warning
|
entity_id: !input scene_warning
|
||||||
- delay:
|
- delay:
|
||||||
milliseconds: 500
|
milliseconds: "{{ scene_repeat_delay_milliseconds }}"
|
||||||
|
|
||||||
- alias: "Delay during the warning period"
|
- alias: "Delay during the warning period"
|
||||||
wait_template: "{{ states[motion_sensor].state == 'on' or (enabled_helper != None and is_state('enabled_helper', 'off') ) }}"
|
wait_template: "{{ states[motion_sensor].state == 'on' or (enabled_helper != None and is_state('enabled_helper', 'off') ) }}"
|
||||||
@ -617,9 +638,10 @@ action:
|
|||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ is_state( enabled_helper, 'off' ) }}"
|
value_template: "{{ is_state( enabled_helper, 'off' ) }}"
|
||||||
then:
|
then:
|
||||||
stop: "Quitting early because the enabled-helper went OFF."
|
stop: "Interrupting the WARNING sequence because the enabled-helper went OFF."
|
||||||
|
|
||||||
- if:
|
- alias: "If motion interrupts the WARNING sequence, just activate the ON scene"
|
||||||
|
if:
|
||||||
- condition: state
|
- condition: state
|
||||||
entity_id: !input motion_sensor
|
entity_id: !input motion_sensor
|
||||||
state: "on"
|
state: "on"
|
||||||
@ -633,7 +655,7 @@ action:
|
|||||||
target:
|
target:
|
||||||
entity_id: !input scene_on
|
entity_id: !input scene_on
|
||||||
- delay:
|
- delay:
|
||||||
milliseconds: 500
|
milliseconds: "{{ scene_repeat_delay_milliseconds }}"
|
||||||
|
|
||||||
- alias: "Double countdown timer when user interrupts the warning period."
|
- alias: "Double countdown timer when user interrupts the warning period."
|
||||||
service: input_number.set_value
|
service: input_number.set_value
|
||||||
@ -719,7 +741,7 @@ action:
|
|||||||
target:
|
target:
|
||||||
entity_id: !input scene_off
|
entity_id: !input scene_off
|
||||||
- delay:
|
- delay:
|
||||||
milliseconds: 500
|
milliseconds: "{{ scene_repeat_delay_milliseconds }}"
|
||||||
|
|
||||||
- alias: "Reset countdown timer after turning off lights."
|
- alias: "Reset countdown timer after turning off lights."
|
||||||
service: input_number.set_value
|
service: input_number.set_value
|
||||||
|
Loading…
Reference in New Issue
Block a user