Compare commits
15 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
832a71380f | ||
|
7626c05ad2 | ||
|
98849314e3 | ||
|
716cf3f1b1 | ||
|
b18f09094b | ||
|
fa6bb40bc5 | ||
|
d2e97b133b | ||
|
508e3e37e9 | ||
|
09c41900b2 | ||
|
0702a851ff | ||
|
2277d37989 | ||
|
82a3508b87 | ||
|
4615be6cee | ||
|
9daf98c604 | ||
|
76d8721a7c |
@ -25,4 +25,13 @@ The automation also obeys a toggle helper to enable/disable motion activation. T
|
|||||||
|
|
||||||
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.
|
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.
|
||||||
|
|
||||||
|
## Disclaimer
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
|
||||||
|
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||||
|
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||||
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
|
By using this software you agree to the disclaimer.
|
||||||
|
|
||||||
|
@ -138,22 +138,22 @@ blueprint:
|
|||||||
mode: box
|
mode: box
|
||||||
|
|
||||||
|
|
||||||
# on_just_before_off_seconds:
|
on_just_before_off_seconds:
|
||||||
# name: "\"On\" just before \"Off\""
|
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 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.
|
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.
|
Set this to a value greater than 0 to enable.
|
||||||
# A value of 0 will disable this feature.
|
A value of 0 will disable this feature.
|
||||||
# Note that sometimes, a value that is too short (e.g., 1) may also cause issues.
|
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: 86400
|
||||||
# step: 1
|
step: 0.1
|
||||||
# mode: box
|
mode: box
|
||||||
|
|
||||||
|
|
||||||
enabled_helper:
|
enabled_helper:
|
||||||
@ -197,22 +197,23 @@ 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
|
||||||
|
|
||||||
|
|
||||||
############
|
############
|
||||||
@ -278,11 +279,11 @@ 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 }}"
|
||||||
|
|
||||||
# - alias: "Debug log the on_just_before_off_seconds value"
|
- alias: "Debug log the on_just_before_off_seconds value"
|
||||||
# service: logbook.log
|
service: logbook.log
|
||||||
# data:
|
data:
|
||||||
# name: "Debug: On just before off seconds"
|
name: "Debug: On just before off seconds"
|
||||||
# message: "On just before off is: {{ 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 #1
|
# Action #1
|
||||||
@ -309,6 +310,20 @@ action:
|
|||||||
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 }}"
|
||||||
|
|
||||||
|
# If the enabled helper is OFF, we should start by resetting
|
||||||
|
# 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."
|
||||||
|
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.
|
||||||
- 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"
|
||||||
@ -322,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:
|
||||||
target:
|
count: "{{ scene_repeat_count }}"
|
||||||
entity_id: !input scene_on
|
sequence:
|
||||||
|
- 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"
|
||||||
service: scene.turn_on
|
repeat:
|
||||||
target:
|
count: "{{ scene_repeat_count }}"
|
||||||
entity_id: !input scene_off
|
sequence:
|
||||||
- stop: ""
|
- service: scene.turn_on
|
||||||
|
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."
|
||||||
|
|
||||||
# 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' }}"
|
||||||
@ -345,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' }}"
|
||||||
@ -361,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' }}"
|
||||||
@ -377,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' }}"
|
||||||
@ -393,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"
|
||||||
@ -440,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
|
||||||
@ -459,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:
|
||||||
@ -469,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"
|
||||||
@ -508,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') ) }}"
|
||||||
@ -521,13 +549,14 @@ 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"
|
||||||
- condition: state
|
if:
|
||||||
entity_id: !input motion_sensor
|
- condition: state
|
||||||
state: "on"
|
entity_id: !input motion_sensor
|
||||||
|
state: "on"
|
||||||
then:
|
then:
|
||||||
|
|
||||||
- alias: "Activate Scene: On"
|
- alias: "Activate Scene: On"
|
||||||
@ -596,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') ) }}"
|
||||||
@ -609,12 +638,13 @@ 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"
|
||||||
- condition: state
|
if:
|
||||||
entity_id: !input motion_sensor
|
- condition: state
|
||||||
state: "on"
|
entity_id: !input motion_sensor
|
||||||
|
state: "on"
|
||||||
then:
|
then:
|
||||||
|
|
||||||
- alias: "Activate Scene: On"
|
- alias: "Activate Scene: On"
|
||||||
@ -625,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
|
||||||
@ -674,34 +704,34 @@ 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
|
- 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: "{{ on_just_before_off_seconds }}"
|
seconds: "{{ on_just_before_off_seconds }}"
|
||||||
# else:
|
else:
|
||||||
# - 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: "Won't run on-before-off"
|
name: "Won't run on-before-off"
|
||||||
# message: "Won't run on-before-off because seconds was less than 1"
|
message: "Won't run on-before-off because seconds was less than 1"
|
||||||
|
|
||||||
- alias: "Activate Scene: Off (Done)"
|
- alias: "Activate Scene: Off (Done)"
|
||||||
repeat:
|
repeat:
|
||||||
@ -711,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