motion-light-new OK

This commit is contained in:
2025-01-31 23:57:13 +01:00
parent 96d71410fa
commit 690922d759
2 changed files with 25 additions and 36 deletions

View File

@@ -217,18 +217,7 @@
payload: "double"
value_template: "{{ value_json['action'] }}"
id: Pulsante1-double
# - domain: mqtt
# # device_id: 0b221729867cef10dcb428820c082f79
# type: action
# subtype: single
# trigger: device
# id: Pulsante1-single
# - domain: mqtt
# device_id: 0b221729867cef10dcb428820c082f79
# type: action
# subtype: double
# trigger: device
# id: Pulsante1-double
conditions: []
actions:
- choose:

View File

@@ -35,13 +35,6 @@ blueprint:
max: 300
unit_of_measurement: seconds
trigger_variables:
_light_target: !input light_target
# motion_entity1_var:
# entity_id: !input motion_entity1
# motion_entity2_var:
# entity_id: !input motion_entity2
#
# If motion is detected within the delay,
# we restart the script.
mode: restart
@@ -69,8 +62,11 @@ triggers:
to: "off"
id: motion_entity2_off
# {% set light_target_var = 'light.test_lamp1' %}
# {{ is_state(light_target_var, 'on') }}
variables:
light_target_var: !input light_target
motion_entity1_var: !input motion_entity1
motion_entity2_var: !input motion_entity2
actions:
- choose:
- conditions:
@@ -79,13 +75,18 @@ actions:
- motion_entity1_on
- motion_entity2_on
sequence:
- if:
- condition: template
value_template: "{{ states( 'light.test_lamp1' ) == 'off' }}"
then:
- alias: "Turn on the light"
action: light.turn_on
target: !input light_target
# POSSIBILE baco, dovrebbe essere come di seguito ma la condizione dell'IF non funziona con le variabili qui ma e' ok nella validazione del templating
# - if:
# - condition: template
# value_template: "{{ states( light_target_var) == 'off' }}"
# then:
# - alias: "Turn on the light"
# action: light.turn_on
# target: !input light_target
- alias: "Turn on the light"
action: light.turn_on
target: !input light_target
- conditions:
- condition: trigger
@@ -97,16 +98,15 @@ actions:
- alias: "None of motion sensor are detected"
condition: not
conditions:
# - condition: template
# value_template: "{{ is_state('binary_sensor.presenza_alta_scala_mansarda_occupancy', 'on') }}"
# - condition: template
# value_template: "{{ is_state('binary_sensor.presenza_bassa_scala_mansarda_occupancy', 'on') }}"
- condition: template
value_template: "{{ is_state('binary_sensor.presenza_alta_scala_mansarda_occupancy', 'on') }}"
value_template: "{{ is_state(motion_entity1_var, 'on') }}"
- condition: template
value_template: "{{ is_state('binary_sensor.presenza_bassa_scala_mansarda_occupancy', 'on') }}"
#- condition: state
# entity_id: !input motion_entity1
# state: true
#- condition: state
# entity_id: !input motion_entity2
# state: true
value_template: "{{ is_state(motion_entity2_var, 'on') }}"
then:
- alias: "Wait for delay set before turn off"
delay: !input no_motion_wait