Compare commits

..

No commits in common. "master" and "v2.1.2" have entirely different histories.

View File

@ -197,23 +197,22 @@ blueprint:
variables: variables:
motion_sensor: !input motion_sensor motion_sensor: !input motion_sensor
delay_seconds_helper: !input delay_seconds_helper delay_seconds_helper: !input delay_seconds_helper
delay_seconds_default: !input delay_seconds_default delay_seconds_default: !input delay_seconds_default
delay_seconds_multiplier: !input delay_seconds_multiplier delay_seconds_multiplier: !input delay_seconds_multiplier
delay_seconds_max: !input delay_seconds_max delay_seconds_max: !input delay_seconds_max
notice_seconds: !input notice_seconds notice_seconds: !input notice_seconds
warning_seconds: !input warning_seconds warning_seconds: !input warning_seconds
on_just_before_off_seconds: !input on_just_before_off_seconds on_just_before_off_seconds: !input on_just_before_off_seconds
enabled_helper: !input enabled_helper enabled_helper: !input enabled_helper
disabled_scene: !input disabled_scene disabled_scene: !input disabled_scene
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
############ ############
@ -312,17 +311,11 @@ 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" - alias: "Reset countdown timer when enabled helper is switched OFF."
if: service: input_number.set_value
- condition: trigger data:
id: entity_id: !input delay_seconds_helper
- Enabled Helper is off value: "{{ delay_seconds_default }}"
then:
- alias: "Reset countdown timer when enabled helper is switched OFF."
service: input_number.set_value
data:
entity_id: !input delay_seconds_helper
value: "{{ delay_seconds_default }}"
# In "auto" mode, activate the ON or OFF scene based on whether motion is currently detected # In "auto" mode, activate the ON or OFF scene based on whether motion is currently detected
# Also use "auto" mode if motion activation is ENABLED. # Also use "auto" mode if motion activation is ENABLED.
@ -337,30 +330,18 @@ action:
state: "on" state: "on"
then: then:
- alias: "Activate the ON scene" - alias: "Activate the ON scene"
repeat: service: scene.turn_on
count: "{{ scene_repeat_count }}" target:
sequence: entity_id: !input scene_on
- service: scene.turn_on
target:
entity_id: !input scene_on
- delay:
milliseconds: "{{ scene_repeat_delay_milliseconds }}"
else: else:
- alias: "Activate the OFF scene" - alias: "Activate the OFF scene"
repeat: service: scene.turn_on
count: "{{ scene_repeat_count }}" target:
sequence: entity_id: !input scene_off
- service: scene.turn_on - stop: ""
target:
entity_id: !input scene_off
- delay:
milliseconds: "{{ scene_repeat_delay_milliseconds }}"
- stop: "Enabled helper was on or auto mode was on; Determined scene to activate based on current motion."
# At this point, the enabled helper is assumed to be OFF # In ON mode, just activate the ON scene
- 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' }}"
@ -372,11 +353,11 @@ action:
target: target:
entity_id: !input scene_on entity_id: !input scene_on
- delay: - delay:
milliseconds: "{{ scene_repeat_delay_milliseconds }}" milliseconds: 500
- stop: "Enabled helper is off and disabled scene was ON; Set ON scene" - stop: ""
# In disabled_scene::OFF mode, just activate the OFF scene # In OFF mode, just activate the OFF scene
- alias: "disabled_scene::off mode: just activate the OFF scene" - alias: "off mode: just activate the ON scene"
if: if:
- condition: template - condition: template
value_template: "{{ disabled_scene == 'off' }}" value_template: "{{ disabled_scene == 'off' }}"
@ -388,11 +369,11 @@ action:
target: target:
entity_id: !input scene_off entity_id: !input scene_off
- delay: - delay:
milliseconds: "{{ scene_repeat_delay_milliseconds }}" milliseconds: 500
- stop: "Enabled helper is off and disabled scene was OFF; Set OFF scene" - stop: ""
# In disabled_scene::notice mode, just activate the NOTICE scene # In notice mode, just activate the NOTICE scene
- alias: "disabled_scene::notice mode: just activate the NOTICE scene" - alias: "notice mode: just activate the NOTICE scene"
if: if:
- condition: template - condition: template
value_template: "{{ disabled_scene == 'notice' }}" value_template: "{{ disabled_scene == 'notice' }}"
@ -404,11 +385,11 @@ action:
target: target:
entity_id: !input scene_notice entity_id: !input scene_notice
- delay: - delay:
milliseconds: "{{ scene_repeat_delay_milliseconds }}" milliseconds: 500
- stop: "Enabled helper is off and disabled scene was NOTICE; Set NOTICE scene" - stop: ""
# In disabled_scene::warning mode, just activate the WARNING scene # In warning mode, just activate the WARNING scene
- alias: "disabed_scene::warning mode: just activate the WARNING scene" - alias: "warning mode: just activate the WARNING scene"
if: if:
- condition: template - condition: template
value_template: "{{ disabled_scene == 'warning' }}" value_template: "{{ disabled_scene == 'warning' }}"
@ -420,8 +401,8 @@ action:
target: target:
entity_id: !input scene_warning entity_id: !input scene_warning
- delay: - delay:
milliseconds: "{{ scene_repeat_delay_milliseconds }}" milliseconds: 500
- stop: "Enabled helper is off and disabled scene was WATNING; Set WARNING scene" - stop: ""
# 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"
@ -467,7 +448,7 @@ action:
target: target:
entity_id: !input scene_on entity_id: !input scene_on
- delay: - delay:
milliseconds: "{{ scene_repeat_delay_milliseconds }}" milliseconds: 500
# Motion is not detected # Motion is not detected
@ -486,8 +467,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' or (enabled_helper != None and is_state(enabled_helper, 'off') ) }}" 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" - alias: "Quit now if the enabled-helper went OFF"
if: if:
@ -496,10 +477,9 @@ action:
- condition: template - condition: template
value_template: "{{ is_state( enabled_helper, 'off' ) }}" value_template: "{{ is_state( enabled_helper, 'off' ) }}"
then: then:
stop: "Interrupted initial delay because the enabled helper turned OFF." stop: "Quitting early because the enabled-helper went OFF."
- alias: "Motion detected again during initial delay; Interrupt initial delay" - if:
if:
- condition: state - condition: state
entity_id: !input motion_sensor entity_id: !input motion_sensor
state: "on" state: "on"
@ -536,7 +516,7 @@ action:
target: target:
entity_id: !input scene_notice entity_id: !input scene_notice
- delay: - delay:
milliseconds: "{{ scene_repeat_delay_milliseconds }}" milliseconds: 500
- 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') ) }}"
@ -549,14 +529,13 @@ action:
- condition: template - condition: template
value_template: "{{ is_state( enabled_helper, 'off' ) }}" value_template: "{{ is_state( enabled_helper, 'off' ) }}"
then: then:
stop: "Interrupting NOTICE period because the enabled-helper went OFF." stop: "Quitting early because the enabled-helper went OFF."
- alias: "If motion interrupted the NOTICE period, activate the ON scene" - if:
if: - condition: state
- condition: state entity_id: !input motion_sensor
entity_id: !input motion_sensor state: "on"
state: "on"
then: then:
- alias: "Activate Scene: On" - alias: "Activate Scene: On"
@ -625,7 +604,7 @@ action:
target: target:
entity_id: !input scene_warning entity_id: !input scene_warning
- delay: - delay:
milliseconds: "{{ scene_repeat_delay_milliseconds }}" milliseconds: 500
- 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') ) }}"
@ -638,13 +617,12 @@ action:
- condition: template - condition: template
value_template: "{{ is_state( enabled_helper, 'off' ) }}" value_template: "{{ is_state( enabled_helper, 'off' ) }}"
then: then:
stop: "Interrupting the WARNING sequence because the enabled-helper went OFF." stop: "Quitting early because the enabled-helper went OFF."
- alias: "If motion interrupts the WARNING sequence, just activate the ON scene" - if:
if: - condition: state
- condition: state entity_id: !input motion_sensor
entity_id: !input motion_sensor state: "on"
state: "on"
then: then:
- alias: "Activate Scene: On" - alias: "Activate Scene: On"
@ -655,7 +633,7 @@ action:
target: target:
entity_id: !input scene_on entity_id: !input scene_on
- delay: - delay:
milliseconds: "{{ scene_repeat_delay_milliseconds }}" milliseconds: 500
- 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
@ -741,7 +719,7 @@ action:
target: target:
entity_id: !input scene_off entity_id: !input scene_off
- delay: - delay:
milliseconds: "{{ scene_repeat_delay_milliseconds }}" milliseconds: 500
- 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