motion_light rewritten (no permanence between two motion sensor)

This commit is contained in:
2024-11-06 21:18:18 +01:00
parent 437553f5ec
commit 126df51438
3 changed files with 123 additions and 119 deletions

View File

@@ -45,6 +45,49 @@ blueprint:
trigger_variables:
use_sun: !input sun_condition
triggers:
- trigger: state
entity_id:
- !input motion_entity_up
- !input motion_entity_down
to: "on"
id: motion-detected
- trigger: state
entity_id:
- !input motion_entity_up
- !input motion_entity_down
to: "off"
for:
hours: 0
minutes: 0
seconds: !input no_motion_wait
conditions:
- condition: sun
after: sunset
after_offset: "-01:00:00"
before: sunrise
before_offset: "+01:00:00"
actions:
- if:
- condition: trigger
id:
- motion-detected
then:
- action: light.turn_on
target: !input light_target
data: {}
else:
- action: light.turn_off
metadata: {}
data:
transition: 10
target: !input light_target
mode: single
######################## Save Esperimenti ##############################
# local_condition:
# mode: single
# sequence:
@@ -65,50 +108,55 @@ trigger_variables:
# sequence:
# data: []
#################### Original single sensor motion detector ###########
# If motion is detected within the delay,
# we restart the script.
mode: restart
max_exceeded: silent
triggers:
- trigger: state
entity_id: !input motion_entity_down
from: "off"
to: "on"
- trigger: state
entity_id: !input motion_entity_up
from: "off"
to: "on"
# {% if states( use_sun ) %}
conditions:
- condition: sun
after: sunset
after_offset: "-01:00:00"
before: sunrise
before_offset: "+01:00:00"
# {% endif %}
# conditions: "{{ local_conditions }}"
actions:
- alias: "Turn on the light"
action: light.turn_on
target: !input light_target
- alias: "Wait until there is no motion from up device"
wait_for_trigger:
trigger: state
entity_id: !input motion_entity_up
from: "on"
to: "off"
- alias: "Wait until there is no motion from dow device"
wait_for_trigger:
trigger: state
entity_id: !input motion_entity_down
from: "on"
to: "off"
- alias: "Wait the number of seconds that has been set"
delay: !input no_motion_wait
- alias: "Turn off the light"
action: light.turn_off
target: !input light_target
# mode: restart
# max_exceeded: silent
#
# triggers:
# - trigger: state
# entity_id: !input motion_entity_down
# id: motion_entity_down_id
# from: "off"
# to: "on"
# - trigger: state
# entity_id: !input motion_entity_up
# id: motion_entity_up_id
# from: "off"
# to: "on"
#
# # {% if states( use_sun ) %}
# conditions:
# - condition: sun
# after: sunset
# after_offset: "-01:00:00"
# before: sunrise
# before_offset: "+01:00:00"
# # {% endif %}
#
# # conditions: "{{ local_conditions }}"
#
# actions:
# - alias: "Turn on the light"
# action: light.turn_on
# target: !input light_target
# - alias: "Wait until there is no motion from up device"
# wait_for_trigger:
# trigger: state
# id: trigger_alto
# entity_id: !input motion_entity_up
# from: "on"
# to: "off"
# - alias: "Wait until there is no motion from dow device"
# wait_for_trigger:
# trigger: state
# id: trigger_basso
# entity_id: !input motion_entity_down
# from: "on"
# to: "off"
# - alias: "Wait the number of seconds that has been set"
# delay: !input no_motion_wait
# - alias: "Turn off the light"
# action: light.turn_off
# target: !input light_target