Turn scene on twice to account for laggy networks
Also quoted some things and improved logging a bit.
This commit is contained in:
parent
7b37258f22
commit
045e87fe73
@ -1,5 +1,9 @@
|
|||||||
|
|
||||||
|
|
||||||
|
########################
|
||||||
|
### Blueprint definition
|
||||||
|
########################
|
||||||
|
|
||||||
blueprint:
|
blueprint:
|
||||||
|
|
||||||
name: "Mike's Motion Activated Light"
|
name: "Mike's Motion Activated Light"
|
||||||
@ -8,22 +12,22 @@ blueprint:
|
|||||||
input:
|
input:
|
||||||
|
|
||||||
motion_sensor:
|
motion_sensor:
|
||||||
name: Motion Sensor
|
name: "Motion Sensor"
|
||||||
description: Entity ID of the motion sensor
|
description: "Entity ID of the motion sensor"
|
||||||
selector:
|
selector:
|
||||||
entity:
|
entity:
|
||||||
domain: binary_sensor
|
domain: binary_sensor
|
||||||
|
|
||||||
delay_seconds_helper:
|
delay_seconds_helper:
|
||||||
name: Delay seconds (helper)
|
name: "Delay seconds (helper)"
|
||||||
description: The delay before the motion-off sequence will be initiated. Must be a helper so it can persist across activations.
|
description: "The delay before the motion-off sequence will be initiated. Must be a helper so it can persist across activations."
|
||||||
selector:
|
selector:
|
||||||
entity:
|
entity:
|
||||||
domain: input_number
|
domain: input_number
|
||||||
|
|
||||||
delay_seconds_default:
|
delay_seconds_default:
|
||||||
name: Default delay seconds
|
name: "Default delay seconds"
|
||||||
description: The default delay before the motion-off sequence begins. Will be used to reset the running delay.
|
description: "The default delay before the motion-off sequence begins. Will be used to reset the running delay."
|
||||||
default: 30
|
default: 30
|
||||||
selector:
|
selector:
|
||||||
number:
|
number:
|
||||||
@ -33,7 +37,7 @@ blueprint:
|
|||||||
mode: box
|
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 Prep1 (Notice) scene."
|
||||||
default: 15
|
default: 15
|
||||||
selector:
|
selector:
|
||||||
@ -44,7 +48,7 @@ blueprint:
|
|||||||
mode: box
|
mode: box
|
||||||
|
|
||||||
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 Prep2 (Warning) scene."
|
||||||
default: 15
|
default: 15
|
||||||
selector:
|
selector:
|
||||||
@ -55,33 +59,38 @@ blueprint:
|
|||||||
mode: box
|
mode: box
|
||||||
|
|
||||||
scene_on:
|
scene_on:
|
||||||
name: On Scene
|
name: "On Scene"
|
||||||
description: The scene to activate when motion is detected
|
description: "The scene to activate when motion is detected"
|
||||||
selector:
|
selector:
|
||||||
entity:
|
entity:
|
||||||
domain: scene
|
domain: scene
|
||||||
|
|
||||||
scene_off_prep_1:
|
scene_off_prep_1:
|
||||||
name: Off Prep Scene 1 (Notice)
|
name: "Off Prep Scene 1 (Notice)"
|
||||||
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_off_prep_2:
|
||||||
name: Off Prep Scene 2 (Warning)
|
name: "Off Prep Scene 2 (Warning)"
|
||||||
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:
|
||||||
domain: scene
|
domain: scene
|
||||||
|
|
||||||
scene_off:
|
scene_off:
|
||||||
name: Off Scene
|
name: "Off Scene"
|
||||||
description: "The scene to activate when the user has failed to produce motion, and the light should be considered \"off\"."
|
description: "The scene to activate when the user has failed to produce motion, and the light should be considered \"off\"."
|
||||||
selector:
|
selector:
|
||||||
entity:
|
entity:
|
||||||
domain: scene
|
domain: scene
|
||||||
|
|
||||||
|
|
||||||
|
#############
|
||||||
|
### Variables
|
||||||
|
#############
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
|
|
||||||
motion_sensor: !input motion_sensor
|
motion_sensor: !input motion_sensor
|
||||||
@ -90,6 +99,10 @@ variables:
|
|||||||
notice_seconds: !input notice_seconds
|
notice_seconds: !input notice_seconds
|
||||||
warning_seconds: !input warning_seconds
|
warning_seconds: !input warning_seconds
|
||||||
|
|
||||||
|
############
|
||||||
|
### Triggers
|
||||||
|
############
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
|
|
||||||
- platform: state
|
- platform: state
|
||||||
@ -99,12 +112,16 @@ trigger:
|
|||||||
- "on"
|
- "on"
|
||||||
- "off"
|
- "off"
|
||||||
|
|
||||||
|
###########
|
||||||
|
### Actions
|
||||||
|
###########
|
||||||
|
|
||||||
action:
|
action:
|
||||||
|
|
||||||
- service: logbook.log
|
- service: logbook.log
|
||||||
data:
|
data:
|
||||||
name: First log
|
name: "First log"
|
||||||
message: "Test Poop Blueprint has started. Motion delay counter is: {{ states[delay_seconds].state }}"
|
message: "Motion automation has started. Delay counter is: {{ states[delay_seconds].state }}"
|
||||||
|
|
||||||
- if:
|
- if:
|
||||||
- condition: state
|
- condition: state
|
||||||
@ -114,28 +131,35 @@ action:
|
|||||||
# Take actions based on Motion being detected!
|
# Take actions based on Motion being detected!
|
||||||
then:
|
then:
|
||||||
|
|
||||||
- alias: Trying to log the motion state
|
- alias: "Log that motion was detected."
|
||||||
service: logbook.log
|
service: logbook.log
|
||||||
data:
|
data:
|
||||||
name: Motion On
|
name: "Motion On"
|
||||||
message: Motion Detected
|
message: "Motion was detected."
|
||||||
|
|
||||||
- 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
|
||||||
|
- delay:
|
||||||
|
seconds: 1
|
||||||
|
- alias: "Activate the ON scene again, after a delay (to help laggy setups)"
|
||||||
|
service: scene.turn_on
|
||||||
|
target:
|
||||||
|
entity_id: !input scene_on
|
||||||
|
|
||||||
|
|
||||||
# Take actions based on Motion being undetected
|
# Take actions based on Motion being undetected
|
||||||
else:
|
else:
|
||||||
|
|
||||||
- alias: Announce motion-off sequence
|
- alias: "Log that the motion-off sequence will run, due to motion no longer detected."
|
||||||
service: logbook.log
|
service: logbook.log
|
||||||
data:
|
data:
|
||||||
name: Motion Off
|
name: "Motion Off"
|
||||||
message: Initiating motion-off sequence.
|
message: "Initiating motion-off sequence, because motion no longer detected."
|
||||||
|
|
||||||
|
|
||||||
- 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].state }}"
|
||||||
- if:
|
- if:
|
||||||
@ -143,14 +167,20 @@ action:
|
|||||||
entity_id: !input motion_sensor
|
entity_id: !input motion_sensor
|
||||||
state: "on"
|
state: "on"
|
||||||
then:
|
then:
|
||||||
- stop: "Motion detected during initial delay."
|
- stop: "Motion detected again during initial delay."
|
||||||
- service: logbook.log
|
- alias: "Log that the initial delay has finished."
|
||||||
|
service: logbook.log
|
||||||
data:
|
data:
|
||||||
name: Motion Off
|
name: "Motion Off"
|
||||||
message: Finished initial no-motion delay
|
message: "Finished initial no-motion delay"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
- alias: "Log that the notice period has begun."
|
||||||
|
service: logbook.log
|
||||||
|
data:
|
||||||
|
name: "Begin notice period"
|
||||||
|
message: "Begin notice period; Waiting while motion is still off."
|
||||||
- alias: "Activate Scene: Off Prep 1 (Notice)"
|
- alias: "Activate Scene: Off Prep 1 (Notice)"
|
||||||
service: scene.turn_on
|
service: scene.turn_on
|
||||||
target:
|
target:
|
||||||
@ -175,9 +205,14 @@ action:
|
|||||||
- stop: "Motion detected during notice period."
|
- stop: "Motion detected during notice period."
|
||||||
- service: logbook.log
|
- service: logbook.log
|
||||||
data:
|
data:
|
||||||
name: Motion Off
|
name: "Notice period finished."
|
||||||
message: Finished notice delay
|
message: "Notice period has finished (motion is still off)."
|
||||||
|
|
||||||
|
- alias: "Log that the warning period has begun."
|
||||||
|
service: logbook.log
|
||||||
|
data:
|
||||||
|
name: "Begin warning period"
|
||||||
|
message: "Begin warning period; Waiting while motion is still off."
|
||||||
- alias: "Activate Scene: Off Prep 2 (Warning)"
|
- alias: "Activate Scene: Off Prep 2 (Warning)"
|
||||||
service: scene.turn_on
|
service: scene.turn_on
|
||||||
target:
|
target:
|
||||||
@ -202,15 +237,16 @@ action:
|
|||||||
- stop: "Motion detected during the warning period."
|
- stop: "Motion detected during the warning period."
|
||||||
- service: logbook.log
|
- service: logbook.log
|
||||||
data:
|
data:
|
||||||
name: Motion Off
|
name: "Warning period finished."
|
||||||
message: Finished warning delay
|
message: "Warning period has finished and motion is still off."
|
||||||
|
|
||||||
|
|
||||||
- alias: "Activate Scene: Off (Done)"
|
- alias: "Activate Scene: Off (Done)"
|
||||||
service: scene.turn_on
|
service: scene.turn_on
|
||||||
target:
|
target:
|
||||||
entity_id: !input scene_off
|
entity_id: !input scene_off
|
||||||
|
|
||||||
- alias: "Reset countdown timer after turning on lights."
|
- alias: "Reset countdown timer after turning off lights."
|
||||||
service: input_number.set_value
|
service: input_number.set_value
|
||||||
data:
|
data:
|
||||||
entity_id: !input delay_seconds_helper
|
entity_id: !input delay_seconds_helper
|
||||||
@ -218,8 +254,8 @@ action:
|
|||||||
|
|
||||||
- service: logbook.log
|
- service: logbook.log
|
||||||
data:
|
data:
|
||||||
name: Motion Off
|
name: "Turning off light, due to motion off."
|
||||||
message: Activated off-scene and reset delay.
|
message: "Activated off-scene and reset delay."
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user