I’m creating an automation for my KNX system to disable my alarm when motion is detected in the hallway between 6hr-11hr AM
Trigger is a motion sensor which goes from off>on.
As conditions i have an “and” condition with :
1/ Motion has to be “off” state during at least 4 hours
2/ The time has to be between 6 hr and 11 hr.
Action is “1” “send value to the knx bus”
alias: Auto Alarm UIT
description: ""
trigger:
- platform: state
entity_id:
- binary_sensor.lasersensors_trap
from: "off"
to: "on"
for:
hours: 0
minutes: 0
seconds: 0
condition:
- condition: and
conditions:
- condition: state
entity_id: binary_sensor.lasersensors_trap
state: "off"
for:
hours: 4
minutes: 0
seconds: 0
- condition: time
after: "06:00:00"
before: "11:00:00"
action:
- service: knx.send
data:
address: 7/1/1
response: false
payload: 1
mode: single
When checking traces, I think the problem is with the 1st condition. (Also, if I remove the 1st condition, the automation works)
The conditions pass when I test, but when triggered the state of the sensor changes to “on” and therefore doesn’t pass the AND test ? I think ?
Then I thought I had to setup an “AND” logic for 2 triggers, but that’s not possible I think ?
I’d also like to expand with additional sensors that have to be on, so motion is detected in a path from the bedroom to downstairs. This way the alarm can go off in this scenario.
You could split it to two automations. One enabling/disabling the alarm → turning on/off the second automation. By daytime and/or the 4-hour-no-motion triggger.
The second is the alarm itself triggered by whatever you have in mind.
Have a look at
Every automation is an entity, thus has an entity_id.
It provides, amongst others, services automation.turn_on and automation.turn_off.
So you don’t need to pass anything to the second automation, but call the service to turn on/off the whole automation in the first.
All you need is to know the entity_id of the second automation in the first one.