From c2f023d80c08b635363039c5b0ffe4a511b2cc23 Mon Sep 17 00:00:00 2001 From: ttrabatt Date: Sat, 2 Nov 2024 00:51:54 +0100 Subject: [PATCH] Dual Sensor motion light template, first commit --- .HA_VERSION | 2 +- automations.yaml | 10 +++ .../homeassistant/motion_light_dual.yaml | 89 +++++++++++++++++++ 3 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 blueprints/automation/homeassistant/motion_light_dual.yaml diff --git a/.HA_VERSION b/.HA_VERSION index 65620ba..eaa15bf 100644 --- a/.HA_VERSION +++ b/.HA_VERSION @@ -1 +1 @@ -2024.10.3 \ No newline at end of file +2024.10.4 \ No newline at end of file diff --git a/automations.yaml b/automations.yaml index ee89bd3..0b32263 100644 --- a/automations.yaml +++ b/automations.yaml @@ -64,3 +64,13 @@ window_sensor: binary_sensor.soggiornopt_finestrasud_contact climate_target: climate.soggiornopt_termosifonesud ext_temp_limit: 17 +- id: '1730504030103' + alias: test-dual-motion + description: '' + use_blueprint: + path: homeassistant/motion_light_dual.yaml + input: + light_target: + device_id: 702137a6f2c17b89fdb0598f7003743c + motion_entity_down: binary_sensor.presenza_bassa_scala_mansarda_occupancy + motion_entity_up: binary_sensor.presenza_alta_scala_mansarda_occupancy diff --git a/blueprints/automation/homeassistant/motion_light_dual.yaml b/blueprints/automation/homeassistant/motion_light_dual.yaml new file mode 100644 index 0000000..b88943f --- /dev/null +++ b/blueprints/automation/homeassistant/motion_light_dual.yaml @@ -0,0 +1,89 @@ +blueprint: + name: Dual Sensor Motion-activated Light Customised with selectable condition after sunset and before sunrise + description: Turn on a light when motion is detected. + domain: automation + # source_url: https://github.com/home-assistant/core/blob/dev/homeassistant/components/automation/blueprints/motion_light.yaml + author: Home Assistant Rewised by Tiziano Trabattoni + input: + motion_entity_down: + name: Motion Sensor (Sensore Basso) + description: Sensore parte bassa della scala + selector: + entity: + filter: + device_class: motion + domain: binary_sensor + motion_entity_up: + name: Motion Sensor (Sensore Alto) + description: Sensore parte alta della scala + selector: + entity: + filter: + device_class: motion + domain: binary_sensor + light_target: + name: Light + selector: + target: + entity: + domain: light + sun_condition: + name: Sun_driven + description: Controlled by sunrise and sunset + default: on + selector: + boolean: + no_motion_wait: + name: Wait time + description: Time to leave the light on after last motion is detected. + default: 120 + selector: + number: + min: 0 + max: 3600 + unit_of_measurement: seconds + +# 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" + +conditions: + # {% if %} + - condition: sun + after: sunset + after_offset: "-01:00:00" + before: sunrise + before_offset: "+01:00:00" + +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