From 690922d7597f1e4e604e855d40612e9f29d9b726 Mon Sep 17 00:00:00 2001 From: ttrabatt Date: Fri, 31 Jan 2025 23:57:13 +0100 Subject: [PATCH] motion-light-new OK --- automations.yaml | 13 +---- .../homeassistant/motion-light-new.yaml | 48 +++++++++---------- 2 files changed, 25 insertions(+), 36 deletions(-) diff --git a/automations.yaml b/automations.yaml index 1b74a89..17f9102 100644 --- a/automations.yaml +++ b/automations.yaml @@ -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: diff --git a/blueprints/automation/homeassistant/motion-light-new.yaml b/blueprints/automation/homeassistant/motion-light-new.yaml index 0aee6af..082e100 100644 --- a/blueprints/automation/homeassistant/motion-light-new.yaml +++ b/blueprints/automation/homeassistant/motion-light-new.yaml @@ -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