Work
This commit is contained in:
parent
16db7d752b
commit
c289fce42b
@ -6,7 +6,7 @@
|
||||
|
||||
blueprint:
|
||||
|
||||
name: "Mike's Motion Activated Light"
|
||||
name: "Mike's Motion Activated Light - WORK"
|
||||
description: "Turn lights on or off based on motion, plus an increasing delay when motion is continuously detected."
|
||||
domain: automation
|
||||
input:
|
||||
@ -41,6 +41,30 @@ blueprint:
|
||||
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: 1.0
|
||||
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:
|
||||
name: "Notice seconds"
|
||||
description: "The number of seconds to wait in the Prep1 (Notice) scene."
|
||||
@ -97,25 +121,38 @@ blueprint:
|
||||
domain: scene
|
||||
|
||||
|
||||
on_just_before_off:
|
||||
name: "Use On scene just before Off scene."
|
||||
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."
|
||||
on_just_before_off_seconds:
|
||||
name: "Use \"On\" scene just before \"Off\" scene"
|
||||
description: "Set this to a value greater than 0 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. Sometimes a value that is too short (e.g., 1) may also cause issues."
|
||||
selector:
|
||||
number:
|
||||
min: 1
|
||||
max: 86400
|
||||
step: 1
|
||||
mode: box
|
||||
|
||||
|
||||
debug_mode:
|
||||
name: "Debug mode."
|
||||
description: "Enable debug mode, which increases logging."
|
||||
selector:
|
||||
boolean: {}
|
||||
|
||||
|
||||
#############
|
||||
### Variables
|
||||
#############
|
||||
|
||||
variables:
|
||||
|
||||
motion_sensor: !input motion_sensor
|
||||
delay_seconds: !input delay_seconds_helper
|
||||
delay_seconds_default: !input delay_seconds_default
|
||||
notice_seconds: !input notice_seconds
|
||||
warning_seconds: !input warning_seconds
|
||||
on_just_before_off: !input on_just_before_off
|
||||
motion_sensor: !input motion_sensor
|
||||
delay_seconds: !input delay_seconds_helper
|
||||
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
|
||||
warning_seconds: !input warning_seconds
|
||||
on_just_before_off_seconds: !input on_just_before_off
|
||||
debug_mode: !input debug_mode
|
||||
|
||||
|
||||
############
|
||||
@ -142,12 +179,15 @@ action:
|
||||
name: "First log"
|
||||
message: "Motion automation has started. Delay counter is: {{ states[delay_seconds].state }}"
|
||||
|
||||
- alias: "Debug log the on_just_before_off bool"
|
||||
enabled: false
|
||||
service: logbook.log
|
||||
data:
|
||||
name: "Debug: On just before off?"
|
||||
message: "On just before off is: {{ on_just_before_off }} "
|
||||
- alias: "Debug log the on_just_before_off_seconds value"
|
||||
if:
|
||||
- condition: template
|
||||
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 }} "
|
||||
|
||||
- if:
|
||||
- condition: state
|
||||
@ -180,7 +220,7 @@ action:
|
||||
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"
|
||||
wait_template: "{{ states[motion_sensor].state == 'on' }}"
|
||||
timeout: "{{ states[delay_seconds].state }}"
|
||||
@ -222,11 +262,20 @@ action:
|
||||
service: scene.turn_on
|
||||
target:
|
||||
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
|
||||
data:
|
||||
entity_id: !input delay_seconds_helper
|
||||
value: "{{ states[delay_seconds].state | int * 2 }}"
|
||||
value: "{{ states[delay_seconds].state | int * delay_seconds_multiplier }}"
|
||||
- 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].state }} seconds"
|
||||
- stop: "Motion detected during notice period."
|
||||
- service: logbook.log
|
||||
data:
|
||||
@ -262,7 +311,16 @@ action:
|
||||
service: input_number.set_value
|
||||
data:
|
||||
entity_id: !input delay_seconds_helper
|
||||
value: "{{ states[delay_seconds].state | int * 2 }}"
|
||||
value: "{{ states[delay_seconds].state | int * delay_seconds_multiplier }}"
|
||||
- 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] }} seconds."
|
||||
- stop: "Motion detected during the warning period."
|
||||
- service: logbook.log
|
||||
data:
|
||||
@ -275,20 +333,32 @@ action:
|
||||
# Maybe turn on the "On" scene just before the "Off" scene, if the user enabled this option
|
||||
- if:
|
||||
- condition: template
|
||||
value_template: "{{ on_just_before_off == true }}"
|
||||
value_template: "{{ on_just_before_off_seconds > 0 }}"
|
||||
then:
|
||||
- alias: "Do a debug log"
|
||||
enabled: false
|
||||
service: logbook.log
|
||||
data:
|
||||
name: "DEBUG: Will turn on before off?"
|
||||
message: "Yes, will turn on just before off!"
|
||||
- alias: "Log the number of on-before-off seconds"
|
||||
if:
|
||||
- condition: template
|
||||
value_template: "{{ debug_mode == true }}"
|
||||
then:
|
||||
service: logbook.log
|
||||
data:
|
||||
name: "On-Before-Off seconds"
|
||||
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: 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:
|
||||
- alias: "Activate Scene: Off (Done)"
|
||||
|
Loading…
Reference in New Issue
Block a user