Compare commits
6 Commits
Author | SHA1 | Date | |
---|---|---|---|
610acdc1c4 | |||
1771b154e0 | |||
65a542484d | |||
914b9f7449 | |||
467fcd30e3 | |||
2cab185ac6 |
28
README.md
Normal file
28
README.md
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
|
||||||
|
# Mike's Motion Activated Scenes
|
||||||
|
|
||||||
|
by Mike Peralta
|
||||||
|
|
||||||
|
This is another "motion activated light" automation blueprint for [Home Assistant](https://www.home-assistant.io/).
|
||||||
|
It uses scenes rather than toggling to allow for robust behavior and attempts to adjust its delay dynamically based on activity.
|
||||||
|
|
||||||
|
It features several stages after motion is no longer detected:
|
||||||
|
|
||||||
|
* Initial delay (nothing happens)
|
||||||
|
|
||||||
|
* Notice: Configurable scene + delay
|
||||||
|
|
||||||
|
* Warning: Configurable scene + delay
|
||||||
|
|
||||||
|
* Off
|
||||||
|
|
||||||
|
The initial delay starts off at a user configured number of seconds. Each time the user interrupts the off-sequence with motion,
|
||||||
|
the delay gets multiplied by a user configured multiplier, with a user configurable limit.
|
||||||
|
When the user allows the off-sequence to complete (the off-scene activates), the delay resets to the user configured baseline.
|
||||||
|
This allows a room to stay on longer when there is frequent activity, but shorter when activity is infrequent.
|
||||||
|
|
||||||
|
The automation also obeys a toggle helper to enable/disable motion activation. The user can configure which scene to use when when disabled.
|
||||||
|
|
||||||
|
This automation can retry a scene multiple times in a row to help overcome buggy/slow networks or lights that fail to set brightness/color correctly when first turned on.
|
||||||
|
|
||||||
|
|
@ -122,30 +122,45 @@ blueprint:
|
|||||||
entity:
|
entity:
|
||||||
domain: scene
|
domain: scene
|
||||||
|
|
||||||
|
scene_repeat_count:
|
||||||
on_just_before_off_seconds:
|
name: "Scene repeat/retry count"
|
||||||
name: "\"On\" just before \"Off\""
|
|
||||||
description: >
|
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.
|
When activating a scene, try this many times in a row.
|
||||||
This is sometimes helpful to mitigate an issue where the "On" scene doesn't apply all colors and settings correctly from an "Off" state.
|
This is sometimes useful when the network seems buggy or laggy,
|
||||||
Set this to a value greater than 0 to enable.
|
or for certain lights that fail to correctly apply brightness/color when first turning on.
|
||||||
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
|
default: 1
|
||||||
selector:
|
selector:
|
||||||
number:
|
number:
|
||||||
min: 1
|
min: 1
|
||||||
max: 86400
|
max: 60
|
||||||
step: 1
|
step: 1
|
||||||
mode: box
|
mode: box
|
||||||
|
|
||||||
|
|
||||||
|
# on_just_before_off_seconds:
|
||||||
|
# name: "\"On\" just before \"Off\""
|
||||||
|
# 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:
|
enabled_helper:
|
||||||
name: "Enabled helper"
|
name: "Enabled helper"
|
||||||
description: >
|
description: >
|
||||||
Helper variable that will control whether motion activation is enabled or disabled.
|
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.
|
This will allow the automation to correctly select the "On" or "Off" scene, based on whether motion is currently detected when disabled.
|
||||||
An example would be a "Toggle" helper.
|
An example would be a "Toggle" helper.
|
||||||
default: # Allows no selection
|
default: # Allows no selection
|
||||||
selector:
|
selector:
|
||||||
@ -189,11 +204,12 @@ variables:
|
|||||||
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
|
||||||
|
|
||||||
trigger_variables:
|
trigger_variables:
|
||||||
enabled_helper: !input enabled_helper
|
enabled_helper: !input enabled_helper
|
||||||
@ -229,12 +245,14 @@ trigger:
|
|||||||
action:
|
action:
|
||||||
|
|
||||||
# Action #0
|
# Action #0
|
||||||
- alias: "Debug log whether the enabled_helper was set"
|
- alias: "Initial debug logging"
|
||||||
if:
|
if:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ debug_mode == true }}"
|
value_template: "{{ debug_mode == true }}"
|
||||||
then:
|
then:
|
||||||
- if:
|
|
||||||
|
- alias: "Debug log whether the enabled_helper was set"
|
||||||
|
if:
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ not enabled_helper == None }}"
|
value_template: "{{ not enabled_helper == None }}"
|
||||||
then:
|
then:
|
||||||
@ -248,45 +266,26 @@ action:
|
|||||||
name: "Enabled helper"
|
name: "Enabled helper"
|
||||||
message: "Enabled helper is not set."
|
message: "Enabled helper is not set."
|
||||||
|
|
||||||
|
|
||||||
# Action #1
|
|
||||||
- alias: "Debug log the enabled_helper name"
|
- alias: "Debug log the enabled_helper name"
|
||||||
if:
|
service: logbook.log
|
||||||
- condition: template
|
|
||||||
value_template: "{{ debug_mode == true }}"
|
|
||||||
then:
|
|
||||||
- service: logbook.log
|
|
||||||
data:
|
data:
|
||||||
name: "Enabled helper"
|
name: "Enabled helper"
|
||||||
message: "Enabled helper name is: {{ enabled_helper }}"
|
message: "Enabled helper name is: {{ enabled_helper }}"
|
||||||
|
|
||||||
|
|
||||||
# Action #2
|
|
||||||
- alias: "Debug log the current delay_seconds value"
|
- alias: "Debug log the current delay_seconds value"
|
||||||
if:
|
service: logbook.log
|
||||||
- condition: template
|
|
||||||
value_template: "{{ debug_mode == true }}"
|
|
||||||
then:
|
|
||||||
- service: logbook.log
|
|
||||||
data:
|
data:
|
||||||
name: "Delay seconds"
|
name: "Delay seconds"
|
||||||
message: "Delay seconds is: {{ states[delay_seconds_helper].state }}"
|
message: "Delay seconds is: {{ states[delay_seconds_helper].state }}"
|
||||||
|
|
||||||
|
# - alias: "Debug log the on_just_before_off_seconds value"
|
||||||
# Action #3
|
# service: logbook.log
|
||||||
- alias: "Debug log the on_just_before_off_seconds value"
|
# data:
|
||||||
if:
|
# name: "Debug: On just before off seconds"
|
||||||
- condition: template
|
# message: "On just before off is: {{ on_just_before_off_seconds }} "
|
||||||
value_template: "{{ debug_mode == true }}"
|
|
||||||
then:
|
|
||||||
service: logbook.log
|
|
||||||
data:
|
|
||||||
name: "Debug: On just before off seconds"
|
|
||||||
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
|
# Take actions based on whether the "Enabled helper" was just toggled on or off
|
||||||
# Action #4
|
# Action #1
|
||||||
- if:
|
- if:
|
||||||
- condition: trigger
|
- condition: trigger
|
||||||
id:
|
id:
|
||||||
@ -295,26 +294,21 @@ action:
|
|||||||
then:
|
then:
|
||||||
|
|
||||||
# Debug log
|
# Debug log
|
||||||
- alias: "Debug log - Enabled Helper On/Off"
|
- if:
|
||||||
if:
|
|
||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ debug_mode == true }}"
|
value_template: "{{ debug_mode == true }}"
|
||||||
then:
|
then:
|
||||||
- service: logbook.log
|
- alias: "Debug log that the enabled helper is toggled"
|
||||||
|
service: logbook.log
|
||||||
data:
|
data:
|
||||||
name: "Debug: Trigger"
|
name: "Debug: Trigger"
|
||||||
message: "Enabled helper was toggled, and has triggered this automation"
|
message: "Enabled helper was toggled, and has triggered this automation"
|
||||||
- alias: "Debug log - Disabled scene"
|
- alias: "Debug log the disabled scene"
|
||||||
if:
|
service: logbook.log
|
||||||
- condition: template
|
|
||||||
value_template: "{{ debug_mode == true }}"
|
|
||||||
then:
|
|
||||||
- service: logbook.log
|
|
||||||
data:
|
data:
|
||||||
name: "Debug: Disabled scene"
|
name: "Debug: Disabled scene"
|
||||||
message: "Disabled scene is currently set to: {{ 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
|
# 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.
|
||||||
- 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"
|
||||||
@ -327,13 +321,11 @@ action:
|
|||||||
entity_id: !input motion_sensor
|
entity_id: !input motion_sensor
|
||||||
state: "on"
|
state: "on"
|
||||||
then:
|
then:
|
||||||
- parallel:
|
|
||||||
- alias: "Activate the ON scene"
|
- alias: "Activate the ON scene"
|
||||||
service: scene.turn_on
|
service: scene.turn_on
|
||||||
target:
|
target:
|
||||||
entity_id: !input scene_on
|
entity_id: !input scene_on
|
||||||
else:
|
else:
|
||||||
- parallel:
|
|
||||||
- alias: "Activate the OFF scene"
|
- alias: "Activate the OFF scene"
|
||||||
service: scene.turn_on
|
service: scene.turn_on
|
||||||
target:
|
target:
|
||||||
@ -346,22 +338,30 @@ action:
|
|||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ disabled_scene == 'on' }}"
|
value_template: "{{ disabled_scene == 'on' }}"
|
||||||
then:
|
then:
|
||||||
- parallel:
|
- repeat:
|
||||||
|
count: "{{ scene_repeat_count }}"
|
||||||
|
sequence:
|
||||||
- service: scene.turn_on
|
- service: scene.turn_on
|
||||||
target:
|
target:
|
||||||
entity_id: !input scene_on
|
entity_id: !input scene_on
|
||||||
|
- delay:
|
||||||
|
milliseconds: 500
|
||||||
- stop: ""
|
- stop: ""
|
||||||
|
|
||||||
# In OFF mode, just activate the OF scene
|
# In OFF mode, just activate the OFF scene
|
||||||
- alias: "off mode: just activate the ON 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' }}"
|
||||||
then:
|
then:
|
||||||
- parallel:
|
- repeat:
|
||||||
|
count: "{{ scene_repeat_count }}"
|
||||||
|
sequence:
|
||||||
- service: scene.turn_on
|
- service: scene.turn_on
|
||||||
target:
|
target:
|
||||||
entity_id: !input scene_off
|
entity_id: !input scene_off
|
||||||
|
- delay:
|
||||||
|
milliseconds: 500
|
||||||
- stop: ""
|
- stop: ""
|
||||||
|
|
||||||
# In notice mode, just activate the NOTICE scene
|
# In notice mode, just activate the NOTICE scene
|
||||||
@ -370,10 +370,14 @@ action:
|
|||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ disabled_scene == 'notice' }}"
|
value_template: "{{ disabled_scene == 'notice' }}"
|
||||||
then:
|
then:
|
||||||
- parallel:
|
- repeat:
|
||||||
|
count: "{{ scene_repeat_count }}"
|
||||||
|
sequence:
|
||||||
- service: scene.turn_on
|
- service: scene.turn_on
|
||||||
target:
|
target:
|
||||||
entity_id: !input scene_notice
|
entity_id: !input scene_notice
|
||||||
|
- delay:
|
||||||
|
milliseconds: 500
|
||||||
- stop: ""
|
- stop: ""
|
||||||
|
|
||||||
# In warning mode, just activate the WARNING scene
|
# In warning mode, just activate the WARNING scene
|
||||||
@ -382,10 +386,14 @@ action:
|
|||||||
- condition: template
|
- condition: template
|
||||||
value_template: "{{ disabled_scene == 'warning' }}"
|
value_template: "{{ disabled_scene == 'warning' }}"
|
||||||
then:
|
then:
|
||||||
- parallel:
|
- repeat:
|
||||||
|
count: "{{ scene_repeat_count }}"
|
||||||
|
sequence:
|
||||||
- service: scene.turn_on
|
- service: scene.turn_on
|
||||||
target:
|
target:
|
||||||
entity_id: !input scene_warning
|
entity_id: !input scene_warning
|
||||||
|
- delay:
|
||||||
|
milliseconds: 500
|
||||||
- stop: ""
|
- stop: ""
|
||||||
|
|
||||||
# Don't do anything after processing the enabled_helper triggers
|
# Don't do anything after processing the enabled_helper triggers
|
||||||
@ -395,6 +403,7 @@ action:
|
|||||||
|
|
||||||
|
|
||||||
# Take actions based on whether Motion is detected
|
# Take actions based on whether Motion is detected
|
||||||
|
# Action #2
|
||||||
- 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
|
||||||
@ -423,16 +432,21 @@ action:
|
|||||||
name: "Motion On"
|
name: "Motion On"
|
||||||
message: "Motion was detected."
|
message: "Motion was detected."
|
||||||
|
|
||||||
- parallel:
|
|
||||||
- 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: 500
|
||||||
|
|
||||||
|
|
||||||
# Motion is not detected
|
# Motion is not detected
|
||||||
else:
|
else:
|
||||||
|
|
||||||
|
# Debug log
|
||||||
- alias: "Debug 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:
|
if:
|
||||||
- condition: template
|
- condition: template
|
||||||
@ -443,7 +457,6 @@ action:
|
|||||||
name: "Motion Off"
|
name: "Motion Off"
|
||||||
message: "Initiating motion-off sequence, because motion no longer detected."
|
message: "Initiating motion-off sequence, because motion no longer detected."
|
||||||
|
|
||||||
|
|
||||||
# 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' }}"
|
||||||
@ -486,11 +499,17 @@ action:
|
|||||||
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:
|
|
||||||
- alias: "Activate Scene: Notice"
|
- alias: "Activate Scene: Notice"
|
||||||
service: scene.turn_on
|
repeat:
|
||||||
|
count: "{{ scene_repeat_count }}"
|
||||||
|
sequence:
|
||||||
|
- service: scene.turn_on
|
||||||
target:
|
target:
|
||||||
entity_id: !input scene_notice
|
entity_id: !input scene_notice
|
||||||
|
- delay:
|
||||||
|
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') ) }}"
|
||||||
timeout: "{{ notice_seconds }}"
|
timeout: "{{ notice_seconds }}"
|
||||||
@ -510,11 +529,12 @@ action:
|
|||||||
entity_id: !input motion_sensor
|
entity_id: !input motion_sensor
|
||||||
state: "on"
|
state: "on"
|
||||||
then:
|
then:
|
||||||
- parallel:
|
|
||||||
- alias: "Activate Scene: On"
|
- alias: "Activate Scene: On"
|
||||||
service: scene.turn_on
|
service: scene.turn_on
|
||||||
target:
|
target:
|
||||||
entity_id: !input scene_on
|
entity_id: !input scene_on
|
||||||
|
|
||||||
- alias: "Increase 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:
|
||||||
@ -567,16 +587,21 @@ action:
|
|||||||
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:
|
|
||||||
- alias: "Activate Scene: Warning"
|
- alias: "Activate Scene: Warning"
|
||||||
service: scene.turn_on
|
repeat:
|
||||||
|
count: "{{ scene_repeat_count }}"
|
||||||
|
sequence:
|
||||||
|
- service: scene.turn_on
|
||||||
target:
|
target:
|
||||||
entity_id: !input scene_warning
|
entity_id: !input scene_warning
|
||||||
|
- delay:
|
||||||
|
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') ) }}"
|
||||||
timeout: "{{ warning_seconds }}"
|
timeout: "{{ warning_seconds }}"
|
||||||
|
|
||||||
|
|
||||||
- alias: "Quit now if the enabled-helper went OFF"
|
- alias: "Quit now if the enabled-helper went OFF"
|
||||||
if:
|
if:
|
||||||
- condition: template
|
- condition: template
|
||||||
@ -586,23 +611,28 @@ action:
|
|||||||
then:
|
then:
|
||||||
stop: "Quitting early because the enabled-helper went OFF."
|
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
|
||||||
state: "on"
|
state: "on"
|
||||||
then:
|
then:
|
||||||
- parallel:
|
|
||||||
- alias: "Activate Scene: On"
|
- alias: "Activate Scene: On"
|
||||||
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: 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
|
||||||
data:
|
data:
|
||||||
entity_id: !input delay_seconds_helper
|
entity_id: !input delay_seconds_helper
|
||||||
value: "{{ states[delay_seconds_helper].state | int * delay_seconds_multiplier }}"
|
value: "{{ states[delay_seconds_helper].state | int * delay_seconds_multiplier }}"
|
||||||
|
|
||||||
- alias: "Limit delay seconds to its defined maximum"
|
- alias: "Limit delay seconds to its defined maximum"
|
||||||
if:
|
if:
|
||||||
- condition: template
|
- condition: template
|
||||||
@ -620,6 +650,7 @@ action:
|
|||||||
data:
|
data:
|
||||||
name: "Limiting delay seconds"
|
name: "Limiting delay seconds"
|
||||||
message: "Delay limited to max: {{ states[delay_seconds_helper].state }}"
|
message: "Delay limited to max: {{ states[delay_seconds_helper].state }}"
|
||||||
|
|
||||||
- alias: "Log new delay seconds"
|
- alias: "Log new delay seconds"
|
||||||
if:
|
if:
|
||||||
- condition: template
|
- condition: template
|
||||||
@ -643,40 +674,44 @@ action:
|
|||||||
# Finally, we decide to actually turn off the lights with the "Off" scene.
|
# Finally, we decide to actually turn off the lights with the "Off" scene.
|
||||||
|
|
||||||
# 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_seconds > 0 }}"
|
# value_template: "{{ on_just_before_off_seconds > 0 }}"
|
||||||
then:
|
# then:
|
||||||
- alias: "Log the number of on-before-off seconds"
|
# - alias: "Log the number of on-before-off seconds"
|
||||||
if:
|
# if:
|
||||||
- condition: template
|
# - condition: template
|
||||||
value_template: "{{ debug_mode == true }}"
|
# value_template: "{{ debug_mode == true }}"
|
||||||
then:
|
# then:
|
||||||
service: logbook.log
|
# service: logbook.log
|
||||||
data:
|
# data:
|
||||||
name: "On-Before-Off seconds"
|
# name: "On-Before-Off seconds"
|
||||||
message: "Will turn on for {{ on_just_before_off_seconds }} seconds before off."
|
# message: "Will turn on for {{ on_just_before_off_seconds }} seconds before off."
|
||||||
|
# - service: scene.turn_on
|
||||||
|
# target:
|
||||||
|
# entity_id: !input scene_on
|
||||||
|
# - alias: "Wait a second to set the \"On\" scene."
|
||||||
|
# delay:
|
||||||
|
# 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"
|
||||||
|
|
||||||
|
- alias: "Activate Scene: Off (Done)"
|
||||||
|
repeat:
|
||||||
|
count: "{{ scene_repeat_count }}"
|
||||||
|
sequence:
|
||||||
- service: scene.turn_on
|
- service: scene.turn_on
|
||||||
target:
|
|
||||||
entity_id: !input scene_on
|
|
||||||
- alias: "Wait a second to set the \"On\" scene."
|
|
||||||
delay:
|
|
||||||
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:
|
|
||||||
- alias: "Activate Scene: Off (Done)"
|
|
||||||
service: scene.turn_on
|
|
||||||
target:
|
target:
|
||||||
entity_id: !input scene_off
|
entity_id: !input scene_off
|
||||||
|
- delay:
|
||||||
|
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
|
Reference in New Issue
Block a user