Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
0f41bf3f6a | |||
9b9d5a3466 | |||
aa187ac3a2 | |||
9f143ffb9a | |||
baa226bcab | |||
c059a2773f | |||
acaf3518c2 | |||
c289fce42b |
@ -4,6 +4,8 @@
|
|||||||
### Blueprint definition
|
### Blueprint definition
|
||||||
########################
|
########################
|
||||||
|
|
||||||
|
mode: queued
|
||||||
|
max: 25
|
||||||
blueprint:
|
blueprint:
|
||||||
|
|
||||||
name: "Mike's Motion Activated Light"
|
name: "Mike's Motion Activated Light"
|
||||||
@ -41,9 +43,33 @@ blueprint:
|
|||||||
mode: box
|
mode: box
|
||||||
|
|
||||||
|
|
||||||
|
delay_seconds_multiplier:
|
||||||
|
name: "Delay seconds multiplier"
|
||||||
|
description: "When the off sequence gets interrupted by new motion, multiply the delay seconds by this number. A decent value might be 2."
|
||||||
|
default: 2.0
|
||||||
|
selector:
|
||||||
|
number:
|
||||||
|
min: 1.0
|
||||||
|
max: 1000.0
|
||||||
|
step: 0.1
|
||||||
|
mode: box
|
||||||
|
|
||||||
|
|
||||||
|
delay_seconds_max:
|
||||||
|
name: "Maximum delay seconds"
|
||||||
|
description: "The maximum delay during no motion before the motion-off sequence begins."
|
||||||
|
default: 3600
|
||||||
|
selector:
|
||||||
|
number:
|
||||||
|
min: 5
|
||||||
|
max: 3000000
|
||||||
|
step: 1
|
||||||
|
mode: box
|
||||||
|
|
||||||
|
|
||||||
notice_seconds:
|
notice_seconds:
|
||||||
name: "Notice seconds"
|
name: "Notice seconds"
|
||||||
description: "The number of seconds to wait in the Prep1 (Notice) scene."
|
description: "The number of seconds to wait in the Notice scene."
|
||||||
default: 15
|
default: 15
|
||||||
selector:
|
selector:
|
||||||
number:
|
number:
|
||||||
@ -55,7 +81,7 @@ blueprint:
|
|||||||
|
|
||||||
warning_seconds:
|
warning_seconds:
|
||||||
name: "Warning seconds"
|
name: "Warning seconds"
|
||||||
description: "The number of seconds to wait in the Prep2 (Warning) scene."
|
description: "The number of seconds to wait in the Warning scene."
|
||||||
default: 15
|
default: 15
|
||||||
selector:
|
selector:
|
||||||
number:
|
number:
|
||||||
@ -73,16 +99,16 @@ blueprint:
|
|||||||
domain: scene
|
domain: scene
|
||||||
|
|
||||||
|
|
||||||
scene_off_prep_1:
|
scene_notice:
|
||||||
name: "Off Prep Scene 1 (Notice)"
|
name: "Notice Scene"
|
||||||
description: "The first scene to activate when motion is no longer detected (notice phase)."
|
description: "The first scene to activate when motion is no longer detected (notice phase)."
|
||||||
selector:
|
selector:
|
||||||
entity:
|
entity:
|
||||||
domain: scene
|
domain: scene
|
||||||
|
|
||||||
|
|
||||||
scene_off_prep_2:
|
scene_warning:
|
||||||
name: "Off Prep Scene 2 (Warning)"
|
name: "Warning Scene"
|
||||||
description: "The second scene to activate when motion is no longer detected (warning phase)."
|
description: "The second scene to activate when motion is no longer detected (warning phase)."
|
||||||
selector:
|
selector:
|
||||||
entity:
|
entity:
|
||||||
@ -97,9 +123,55 @@ blueprint:
|
|||||||
domain: scene
|
domain: scene
|
||||||
|
|
||||||
|
|
||||||
on_just_before_off:
|
on_just_before_off_seconds:
|
||||||
name: "Use On scene just before Off scene."
|
name: "\"On\" just before \"Off\""
|
||||||
description: "Toggle this to \"on\" if you would like the \"On\" scene to trigger just before the \"Off\" scene. This is sometimes helpful to mitigate an issue where the \"On\" scene doesn't apply all colors and settings correctly from an \"Off\" state."
|
description: >
|
||||||
|
When the "Off" scene is about to be shown, you may wish to quickly show the "On" scene for a number of seconds just before.
|
||||||
|
This is sometimes helpful to mitigate an issue where the "On" scene doesn't apply all colors and settings correctly from an "Off" state.
|
||||||
|
Set this to a value greater than 0 to enable.
|
||||||
|
A value of 0 will disable this feature.
|
||||||
|
Note that sometimes, a value that is too short (e.g., 1) may also cause issues.
|
||||||
|
|
||||||
|
default: 1
|
||||||
|
selector:
|
||||||
|
number:
|
||||||
|
min: 1
|
||||||
|
max: 86400
|
||||||
|
step: 1
|
||||||
|
mode: box
|
||||||
|
|
||||||
|
|
||||||
|
enabled_helper:
|
||||||
|
name: "Enabled helper"
|
||||||
|
description: >
|
||||||
|
Helper variable that will control whether motion activation is enabled or disabled.
|
||||||
|
This will allow this blueprint to correctly select the "On" or "Off" scene, based on whether motion is currently detected when disabled.
|
||||||
|
An example would be a "Toggle" helper.
|
||||||
|
default: # Allows no selection
|
||||||
|
selector:
|
||||||
|
entity:
|
||||||
|
domain: input_boolean
|
||||||
|
|
||||||
|
|
||||||
|
disabled_scene:
|
||||||
|
name: "Disabled scene"
|
||||||
|
description: >
|
||||||
|
Choose the scene that will be activated when the "enabled_helper" is set to off.
|
||||||
|
In the "auto" mode, the "on" or "off" scene will be chosen based on whether motion is currently detected.
|
||||||
|
selector:
|
||||||
|
select:
|
||||||
|
options:
|
||||||
|
- "auto"
|
||||||
|
- "on"
|
||||||
|
- "off"
|
||||||
|
- "notice"
|
||||||
|
- "warning"
|
||||||
|
|
||||||
|
|
||||||
|
debug_mode:
|
||||||
|
name: "Debug mode."
|
||||||
|
description: "Enable debug mode, which increases logging."
|
||||||
|
default: false
|
||||||
selector:
|
selector:
|
||||||
boolean: {}
|
boolean: {}
|
||||||
|
|
||||||
@ -111,11 +183,20 @@ blueprint:
|
|||||||
variables:
|
variables:
|
||||||
|
|
||||||
motion_sensor: !input motion_sensor
|
motion_sensor: !input motion_sensor
|
||||||
delay_seconds: !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_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: !input on_just_before_off
|
on_just_before_off_seconds: !input on_just_before_off_seconds
|
||||||
|
enabled_helper: !input enabled_helper
|
||||||
|
disabled_scene: !input disabled_scene
|
||||||
|
debug_mode: !input debug_mode
|
||||||
|
|
||||||
|
|
||||||
|
trigger_variables:
|
||||||
|
enabled_helper: !input enabled_helper
|
||||||
|
|
||||||
|
|
||||||
############
|
############
|
||||||
@ -125,39 +206,216 @@ variables:
|
|||||||
trigger:
|
trigger:
|
||||||
|
|
||||||
- platform: state
|
- platform: state
|
||||||
|
id: Motion changed
|
||||||
entity_id:
|
entity_id:
|
||||||
- !input motion_sensor
|
- !input motion_sensor
|
||||||
to:
|
to:
|
||||||
- "on"
|
- "on"
|
||||||
- "off"
|
- "off"
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
id: "Enabled helper is on"
|
||||||
|
value_template: "{{ (enabled_helper != None) and is_state( enabled_helper, 'on' ) }}"
|
||||||
|
|
||||||
|
- platform: template
|
||||||
|
id: "Enabled helper is off"
|
||||||
|
value_template: "{{ (enabled_helper != None) and is_state( enabled_helper, 'off' ) }}"
|
||||||
|
|
||||||
|
|
||||||
###########
|
###########
|
||||||
### Actions
|
### Actions
|
||||||
###########
|
###########
|
||||||
|
|
||||||
action:
|
action:
|
||||||
|
|
||||||
|
# Action #0
|
||||||
|
- alias: "Debug log whether the enabled_helper was set"
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ debug_mode == true }}"
|
||||||
|
then:
|
||||||
|
- if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ not enabled_helper == None }}"
|
||||||
|
then:
|
||||||
- service: logbook.log
|
- service: logbook.log
|
||||||
data:
|
data:
|
||||||
name: "First log"
|
name: "Enabled helper"
|
||||||
message: "Motion automation has started. Delay counter is: {{ states[delay_seconds].state }}"
|
message: "Enabled helper is: {{ enabled_helper }}"
|
||||||
|
else:
|
||||||
|
- service: logbook.log
|
||||||
|
data:
|
||||||
|
name: "Enabled helper"
|
||||||
|
message: "Enabled helper is not set."
|
||||||
|
|
||||||
- alias: "Debug log the on_just_before_off bool"
|
|
||||||
enabled: false
|
# Action #1
|
||||||
|
- alias: "Debug log the enabled_helper name"
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ debug_mode == true }}"
|
||||||
|
then:
|
||||||
|
- service: logbook.log
|
||||||
|
data:
|
||||||
|
name: "Enabled helper"
|
||||||
|
message: "Enabled helper name is: {{ enabled_helper }}"
|
||||||
|
|
||||||
|
# Action #2
|
||||||
|
- alias: "Debug log the current delay_seconds value"
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ debug_mode == true }}"
|
||||||
|
then:
|
||||||
|
- service: logbook.log
|
||||||
|
data:
|
||||||
|
name: "Delay seconds"
|
||||||
|
message: "Delay seconds is: {{ states[delay_seconds_helper].state }}"
|
||||||
|
|
||||||
|
# Action #3
|
||||||
|
- alias: "Debug log the on_just_before_off_seconds value"
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ debug_mode == true }}"
|
||||||
|
then:
|
||||||
service: logbook.log
|
service: logbook.log
|
||||||
data:
|
data:
|
||||||
name: "Debug: On just before off?"
|
name: "Debug: On just before off seconds"
|
||||||
message: "On just before off is: {{ on_just_before_off }} "
|
message: "On just before off is: {{ on_just_before_off_seconds }} "
|
||||||
|
|
||||||
|
|
||||||
|
# Take actions based on whether the "Enabled helper" was just toggled on or off
|
||||||
|
# Action #4
|
||||||
|
- if:
|
||||||
|
- condition: trigger
|
||||||
|
id:
|
||||||
|
- Enabled helper is on
|
||||||
|
- Enabled helper is off
|
||||||
|
then:
|
||||||
|
|
||||||
|
# Debug log
|
||||||
|
- alias: "Debug log - Enabled Helper On/Off"
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ debug_mode == true }}"
|
||||||
|
then:
|
||||||
|
- service: logbook.log
|
||||||
|
data:
|
||||||
|
name: "Debug: Trigger"
|
||||||
|
message: "Enabled helper was toggled, and has triggered this automation"
|
||||||
|
- alias: "Debug log - Disabled scene"
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ debug_mode == true }}"
|
||||||
|
then:
|
||||||
|
- service: logbook.log
|
||||||
|
data:
|
||||||
|
name: "Debug: Disabled scene"
|
||||||
|
message: "Disabled scene is currently set to: {{ disabled_scene }}"
|
||||||
|
|
||||||
|
|
||||||
|
# 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.
|
||||||
|
- alias: "auto mode: Activate ON scene, if motion is currently detected, otherwise activate the OFF scene"
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ disabled_scene == 'auto' or is_state( enabled_helper, 'on' ) }}"
|
||||||
|
then:
|
||||||
|
- if:
|
||||||
|
- condition: state
|
||||||
|
entity_id: !input motion_sensor
|
||||||
|
state: "on"
|
||||||
|
then:
|
||||||
|
- parallel:
|
||||||
|
- alias: "Activate the ON scene"
|
||||||
|
service: scene.turn_on
|
||||||
|
target:
|
||||||
|
entity_id: !input scene_on
|
||||||
|
else:
|
||||||
|
- parallel:
|
||||||
|
- alias: "Activate the OFF scene"
|
||||||
|
service: scene.turn_on
|
||||||
|
target:
|
||||||
|
entity_id: !input scene_off
|
||||||
|
- stop: ""
|
||||||
|
|
||||||
|
# In ON mode, just activate the ON scene
|
||||||
|
- alias: "on mode: just activate the ON scene"
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ disabled_scene == 'on' }}"
|
||||||
|
then:
|
||||||
|
- parallel:
|
||||||
|
- service: scene.turn_on
|
||||||
|
target:
|
||||||
|
entity_id: !input scene_on
|
||||||
|
- stop: ""
|
||||||
|
|
||||||
|
# In OFF mode, just activate the OF scene
|
||||||
|
- alias: "off mode: just activate the ON scene"
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ disabled_scene == 'off' }}"
|
||||||
|
then:
|
||||||
|
- parallel:
|
||||||
|
- service: scene.turn_on
|
||||||
|
target:
|
||||||
|
entity_id: !input scene_off
|
||||||
|
- stop: ""
|
||||||
|
|
||||||
|
# In notice mode, just activate the NOTICE scene
|
||||||
|
- alias: "notice mode: just activate the NOTICE scene"
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ disabled_scene == 'notice' }}"
|
||||||
|
then:
|
||||||
|
- parallel:
|
||||||
|
- service: scene.turn_on
|
||||||
|
target:
|
||||||
|
entity_id: !input scene_notice
|
||||||
|
- stop: ""
|
||||||
|
|
||||||
|
# In warning mode, just activate the WARNING scene
|
||||||
|
- alias: "warning mode: just activate the WARNING scene"
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ disabled_scene == 'warning' }}"
|
||||||
|
then:
|
||||||
|
- parallel:
|
||||||
|
- service: scene.turn_on
|
||||||
|
target:
|
||||||
|
entity_id: !input scene_warning
|
||||||
|
- stop: ""
|
||||||
|
|
||||||
|
# Don't do anything after processing the enabled_helper triggers
|
||||||
|
- stop: "Done handling enabled helper"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# Take actions based on whether Motion is detected
|
||||||
|
- alias: "Refuse to do anything if the enabled-helper says we're OFF."
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ enabled_helper != None }}"
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ not is_state( enabled_helper, 'on' ) }}"
|
||||||
|
then:
|
||||||
|
stop: "Refusing to continue because the enabled-helper is OFF."
|
||||||
|
|
||||||
- if:
|
- if:
|
||||||
- condition: state
|
- condition: state
|
||||||
entity_id: !input motion_sensor
|
entity_id: !input motion_sensor
|
||||||
state: "on"
|
state: "on"
|
||||||
|
|
||||||
# Take actions based on Motion being detected!
|
|
||||||
|
# Motion is detected
|
||||||
then:
|
then:
|
||||||
|
|
||||||
- alias: "Log that motion was detected."
|
- alias: "Debug Log that motion was detected."
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ debug_mode == true }}"
|
||||||
|
then:
|
||||||
service: logbook.log
|
service: logbook.log
|
||||||
data:
|
data:
|
||||||
name: "Motion On"
|
name: "Motion On"
|
||||||
@ -170,10 +428,14 @@ action:
|
|||||||
entity_id: !input scene_on
|
entity_id: !input scene_on
|
||||||
|
|
||||||
|
|
||||||
# Take actions based on Motion being undetected
|
# Motion is not detected
|
||||||
else:
|
else:
|
||||||
|
|
||||||
- alias: "Log that the motion-off sequence will run, due to motion no longer detected."
|
- alias: "Debug Log that the motion-off sequence will run, due to motion no longer detected."
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ debug_mode == true }}"
|
||||||
|
then:
|
||||||
service: logbook.log
|
service: logbook.log
|
||||||
data:
|
data:
|
||||||
name: "Motion Off"
|
name: "Motion Off"
|
||||||
@ -183,7 +445,7 @@ 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].state }}"
|
timeout: "{{ states[delay_seconds_helper].state }}"
|
||||||
- if:
|
- if:
|
||||||
- condition: state
|
- condition: state
|
||||||
entity_id: !input motion_sensor
|
entity_id: !input motion_sensor
|
||||||
@ -191,6 +453,10 @@ action:
|
|||||||
then:
|
then:
|
||||||
- stop: "Motion detected again during initial delay."
|
- stop: "Motion detected again during initial delay."
|
||||||
- alias: "Log that the initial delay has finished."
|
- alias: "Log that the initial delay has finished."
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ debug_mode == true }}"
|
||||||
|
then:
|
||||||
service: logbook.log
|
service: logbook.log
|
||||||
data:
|
data:
|
||||||
name: "Motion Off"
|
name: "Motion Off"
|
||||||
@ -200,15 +466,19 @@ action:
|
|||||||
|
|
||||||
# Notice period, where the notice scene is shown
|
# Notice period, where the notice scene is shown
|
||||||
- alias: "Log that the notice period has begun."
|
- alias: "Log that the notice period has begun."
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ debug_mode == true }}"
|
||||||
|
then:
|
||||||
service: logbook.log
|
service: logbook.log
|
||||||
data:
|
data:
|
||||||
name: "Begin notice period"
|
name: "Begin notice period"
|
||||||
message: "Begin notice period; Waiting while motion is still off."
|
message: "Begin notice period; Waiting while motion is still off."
|
||||||
- parallel:
|
- parallel:
|
||||||
- alias: "Activate Scene: Off Prep 1 (Notice)"
|
- alias: "Activate Scene: Notice"
|
||||||
service: scene.turn_on
|
service: scene.turn_on
|
||||||
target:
|
target:
|
||||||
entity_id: !input scene_off_prep_1
|
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' }}"
|
||||||
timeout: "{{ notice_seconds }}"
|
timeout: "{{ notice_seconds }}"
|
||||||
@ -222,12 +492,42 @@ action:
|
|||||||
service: scene.turn_on
|
service: scene.turn_on
|
||||||
target:
|
target:
|
||||||
entity_id: !input scene_on
|
entity_id: !input scene_on
|
||||||
- alias: "Double countdown timer when user interrupts the notice period."
|
- alias: "Increase countdown timer when user interrupts the notice period."
|
||||||
service: input_number.set_value
|
service: input_number.set_value
|
||||||
data:
|
data:
|
||||||
entity_id: !input delay_seconds_helper
|
entity_id: !input delay_seconds_helper
|
||||||
value: "{{ states[delay_seconds].state | int * 2 }}"
|
value: "{{ states[delay_seconds_helper].state | int * delay_seconds_multiplier }}"
|
||||||
|
- alias: "Limit delay seconds to its defined maximum"
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ states[delay_seconds_helper].state | int > delay_seconds_max | int }}"
|
||||||
|
then:
|
||||||
|
- service: input_number.set_value
|
||||||
|
data:
|
||||||
|
entity_id: !input delay_seconds_helper
|
||||||
|
value: "{{ delay_seconds_max | int }}"
|
||||||
|
- if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ debug_mode == true }}"
|
||||||
|
then:
|
||||||
|
- service: logbook.log
|
||||||
|
data:
|
||||||
|
name: "Limiting delay seconds"
|
||||||
|
message: "Delay limited to max: {{ states[delay_seconds_helper].state }}"
|
||||||
|
- alias: "Log new delay"
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ debug_mode == true }}"
|
||||||
|
then:
|
||||||
|
- service: logbook.log
|
||||||
|
data:
|
||||||
|
name: "New delay"
|
||||||
|
message: "New delay is {{ states[delay_seconds_helper].state }} seconds"
|
||||||
- stop: "Motion detected during notice period."
|
- stop: "Motion detected during notice period."
|
||||||
|
- if:
|
||||||
|
condition: template
|
||||||
|
value_template: "{{ debug_mode == true }}"
|
||||||
|
then:
|
||||||
- service: logbook.log
|
- service: logbook.log
|
||||||
data:
|
data:
|
||||||
name: "Notice period finished."
|
name: "Notice period finished."
|
||||||
@ -236,15 +536,19 @@ action:
|
|||||||
|
|
||||||
# Warning period, just before the light turns off. The warning scene is shown.
|
# Warning period, just before the light turns off. The warning scene is shown.
|
||||||
- alias: "Log that the warning period has begun."
|
- alias: "Log that the warning period has begun."
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ debug_mode == true }}"
|
||||||
|
then:
|
||||||
service: logbook.log
|
service: logbook.log
|
||||||
data:
|
data:
|
||||||
name: "Begin warning period"
|
name: "Begin warning period"
|
||||||
message: "Begin warning period; Waiting while motion is still off."
|
message: "Begin warning period; Waiting while motion is still off."
|
||||||
- parallel:
|
- parallel:
|
||||||
- alias: "Activate Scene: Off Prep 2 (Warning)"
|
- alias: "Activate Scene: Warning"
|
||||||
service: scene.turn_on
|
service: scene.turn_on
|
||||||
target:
|
target:
|
||||||
entity_id: !input scene_off_prep_2
|
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' }}"
|
||||||
timeout: "{{ warning_seconds }}"
|
timeout: "{{ warning_seconds }}"
|
||||||
@ -262,8 +566,38 @@ action:
|
|||||||
service: input_number.set_value
|
service: input_number.set_value
|
||||||
data:
|
data:
|
||||||
entity_id: !input delay_seconds_helper
|
entity_id: !input delay_seconds_helper
|
||||||
value: "{{ states[delay_seconds].state | int * 2 }}"
|
value: "{{ states[delay_seconds_helper].state | int * delay_seconds_multiplier }}"
|
||||||
|
- alias: "Limit delay seconds to its defined maximum"
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ states[delay_seconds_helper].state | int > delay_seconds_max | int }}"
|
||||||
|
then:
|
||||||
|
- service: input_number.set_value
|
||||||
|
data:
|
||||||
|
entity_id: !input delay_seconds_helper
|
||||||
|
value: "{{ delay_seconds_max | int }}"
|
||||||
|
- if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ debug_mode == true }}"
|
||||||
|
then:
|
||||||
|
- service: logbook.log
|
||||||
|
data:
|
||||||
|
name: "Limiting delay seconds"
|
||||||
|
message: "Delay limited to max: {{ states[delay_seconds_helper].state }}"
|
||||||
|
- alias: "Log new delay seconds"
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ debug_mode == true }}"
|
||||||
|
then:
|
||||||
|
- service: logbook.log
|
||||||
|
data:
|
||||||
|
name: "New delay seconds"
|
||||||
|
message: "New delay is {{ states[delay_seconds_helper].state }} seconds."
|
||||||
- stop: "Motion detected during the warning period."
|
- stop: "Motion detected during the warning period."
|
||||||
|
- if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ debug_mode == true }}"
|
||||||
|
then:
|
||||||
- service: logbook.log
|
- service: logbook.log
|
||||||
data:
|
data:
|
||||||
name: "Warning period finished."
|
name: "Warning period finished."
|
||||||
@ -275,20 +609,32 @@ action:
|
|||||||
# Maybe turn on the "On" scene just before the "Off" scene, if the user enabled this option
|
# Maybe turn on the "On" scene just before the "Off" scene, if the user enabled this option
|
||||||
- if:
|
- if:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ on_just_before_off == true }}"
|
value_template: "{{ on_just_before_off_seconds > 0 }}"
|
||||||
|
then:
|
||||||
|
- alias: "Log the number of on-before-off seconds"
|
||||||
|
if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ debug_mode == true }}"
|
||||||
then:
|
then:
|
||||||
- alias: "Do a debug log"
|
|
||||||
enabled: false
|
|
||||||
service: logbook.log
|
service: logbook.log
|
||||||
data:
|
data:
|
||||||
name: "DEBUG: Will turn on before off?"
|
name: "On-Before-Off seconds"
|
||||||
message: "Yes, will turn on just before off!"
|
message: "Will turn on for {{ on_just_before_off_seconds }} seconds before off."
|
||||||
- service: scene.turn_on
|
- service: scene.turn_on
|
||||||
target:
|
target:
|
||||||
entity_id: !input scene_on
|
entity_id: !input scene_on
|
||||||
- alias: "Wait a second to set the \"On\" scene."
|
- alias: "Wait a second to set the \"On\" scene."
|
||||||
delay:
|
delay:
|
||||||
seconds: 1
|
seconds: "{{ on_just_before_off_seconds }}"
|
||||||
|
else:
|
||||||
|
- if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ debug_mode == true }}"
|
||||||
|
then:
|
||||||
|
- service: logbook.log
|
||||||
|
data:
|
||||||
|
name: "Won't run on-before-off"
|
||||||
|
message: "Won't run on-before-off because seconds was less than 1"
|
||||||
|
|
||||||
- parallel:
|
- parallel:
|
||||||
- alias: "Activate Scene: Off (Done)"
|
- alias: "Activate Scene: Off (Done)"
|
||||||
@ -302,6 +648,10 @@ action:
|
|||||||
entity_id: !input delay_seconds_helper
|
entity_id: !input delay_seconds_helper
|
||||||
value: "{{ delay_seconds_default }}"
|
value: "{{ delay_seconds_default }}"
|
||||||
|
|
||||||
|
- if:
|
||||||
|
- condition: template
|
||||||
|
value_template: "{{ debug_mode == true }}"
|
||||||
|
then:
|
||||||
- service: logbook.log
|
- service: logbook.log
|
||||||
data:
|
data:
|
||||||
name: "Turning off light, due to motion off."
|
name: "Turning off light, due to motion off."
|
||||||
|
Reference in New Issue
Block a user