Upgrades might be working:

* Specify max delay
* Specify delay multiplier
* Specify off-before-on seconds
* Specify debug mode logging
This commit is contained in:
mike 2023-11-15 05:53:03 -08:00
parent c289fce42b
commit acaf3518c2

View File

@ -16,7 +16,7 @@ blueprint:
description: "Entity ID of the motion sensor"
selector:
entity:
domain: binary_sensor
# domain: binary_sensor
# for some reason, using a device_class of motion_sensor ends up hiding the actual motion sensors
# device_class: motion_sensor
@ -49,7 +49,7 @@ blueprint:
number:
min: 1.0
max: 1000.0
step: 1.0
step: 0.1
mode: box
@ -122,8 +122,15 @@ blueprint:
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."
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
@ -135,9 +142,11 @@ blueprint:
debug_mode:
name: "Debug mode."
description: "Enable debug mode, which increases logging."
default: false
selector:
boolean: {}
#############
### Variables
#############
@ -151,7 +160,7 @@ variables:
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
on_just_before_off_seconds: !input on_just_before_off_seconds
debug_mode: !input debug_mode
@ -267,6 +276,23 @@ action:
data:
entity_id: !input delay_seconds_helper
value: "{{ states[delay_seconds].state | int * delay_seconds_multiplier }}"
- alias: "Limit delay seconds to its defined maximum"
if:
- condition: template
value_template: "{{ states[delay_seconds].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].state }}"
- alias: "Log new delay"
if:
- condition: template
@ -312,6 +338,23 @@ action:
data:
entity_id: !input delay_seconds_helper
value: "{{ states[delay_seconds].state | int * delay_seconds_multiplier }}"
- alias: "Limit delay seconds to its defined maximum"
if:
- condition: template
value_template: "{{ states[delay_seconds].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].state }}"
- alias: "Log new delay seconds"
if:
- condition: template
@ -320,7 +363,7 @@ action:
- service: logbook.log
data:
name: "New delay seconds"
message: "New delay is {{ states[delay_seconds] }} seconds."
message: "New delay is {{ states[delay_seconds].state }} seconds."
- stop: "Motion detected during the warning period."
- service: logbook.log
data: