From 6ff83b7acca705bbeca565783eb9c14129118f81 Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Thu, 13 Jun 2024 05:41:46 +0400 Subject: Allow some delay for Aqara sensors to propogate luminance after motion started (in motion_switch blueprint). Use luminance of presence sensor in kitchen automation --- automations.yaml | 4 ++-- blueprints/automation/motion/motion_switch.yaml | 16 ++++++++++++++-- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/automations.yaml b/automations.yaml index f661b33..97244a2 100644 --- a/automations.yaml +++ b/automations.yaml @@ -992,8 +992,8 @@ - switch.kitchen_ledlights motion_entity: binary_sensor.motions_kitchen illumination_test: sensor - illuminance_entity: sensor.kitchen_motions_illuminance_lux - lux_threshold: 80 + illuminance_entity: sensor.kitchen_presence_illuminance_lux + lux_threshold: 40 - id: '1673037015865' alias: 'Motions: Night Light' description: '' diff --git a/blueprints/automation/motion/motion_switch.yaml b/blueprints/automation/motion/motion_switch.yaml index 67e62b6..dd4111e 100644 --- a/blueprints/automation/motion/motion_switch.yaml +++ b/blueprints/automation/motion/motion_switch.yaml @@ -188,8 +188,9 @@ action: conditions: - condition: template value_template: '{{ test == "sensor" }}' - - condition: template - value_template: '{{ (states(illuminance_entity) | float) < lux_threshold }}' +# This will be checked inside to allow short wait +# - condition: template +# value_template: '{{ (states(illuminance_entity) | float) < lux_threshold }}' - condition: and conditions: - condition: template @@ -224,6 +225,17 @@ action: seconds: 2 continue_on_timeout: false +# On motion sensors, illuminance is updated only on motion. We need to give some time to propagate + - if: + - condition: template + value_template: '{{ test == "sensor" }}' + - condition: template + value_template: '{{ (states(illuminance_entity) | float) >= lux_threshold }}' + then: + - wait_template: '{{ (states(illuminance_entity) | float) < lux_threshold }}' + timeout: '00:00:02' # Timeout after 1 minute + continue_on_timeout: false + - choose: [] default: !input "on_click" - service: switch.turn_on -- cgit v1.2.3