I have an automation that triggers a light with a motion sensor. Turning the light on and off works fine but i want to stop the light turning on when the alarm is turned on.
The light is now still being turned on when the alarm is turned on.
I have the automation with condition set up like this:
- id: '1564403943875'
alias: Bureau werktafels sensor verlichting aan
trigger:
- entity_id: binary_sensor.sensor_bureau
from: 'off'
platform: state
to: 'on'
condition:
- condition: state
entity_id: sensor.bureau_partitie_status
state: '0'
action:
- data:
entity_id: light.bureau_werktafels
service: light.turn_on
- id: '1564403985849'
alias: Bureau werktafels sensor verlichting uit
trigger:
- entity_id: binary_sensor.sensor_bureau
from: 'on'
platform: state
to: 'off'
condition: []
action:
- data:
entity_id: light.bureau_werktafels
service: light.turn_off
sensor.bureau_partitie_status is the (knx) alarm partition state, this i 0 when turned off and 1 when turned on.
My thought is to only allow the light.turn_on to happen when the sensor.bureau_partitie_status is 0.
The condition part configured is not working now.
- id: '1564403943875'
alias: Bureau werktafels sensor verlichting aan
trigger:
platform: state
entity_id: binary_sensor.sensor_bureau
# from: 'off' # not necessary since it is a binary sensor
to: 'on'
condition:
condition: template
value_template: >
{{is_state('sensor.bureau_partitie_status','0')}}
action:
service: light.turn_on
entity_id: light.bureau_werktafels
@finity The automation switches the light on and off, it just ignores the condition.
@Infineghost I have it setup with numeric state now, i THINK it works with some basic tests, but i’ll have to check this evening. Strange thing is i did try numeric state before without result. And also i use this sensor in another automation to turn of sonos players and that works fine!
this would either mean the condition evaluates to ‘true’ or the automation doesn’t use the condition. The latter would only be probable if the syntax would be incorrect, but then again you also would see an error.
If the condition is ‘true’, and this is unexpected to you, then you should reevaluate the condition itself.
So, if you enter:
{{is_state('sensor.bureau_partitie_status','0')}}
in the template page, what is the result
and what does this result in: {{states('sensor.bureau_partitie_status')}}
You may need to remove the quotation marks from around the state entry:
state: 0
Maybe forcing it to a string is causing issues.
However it doesn’t make sense that the condition is always evaluated to ‘true’ if there is a problem in the condition. Almost every issue with data types should cause the condition to always be false, not always true.
Ok, so an update…
The automation as it is now with numeric_state is working i think but i overlooked something.
The motion sensor is also providing a constant light setup. So i have the ON/OFF binary sensor in HA with the condition in the automation preventing it from turning on. But it then sends brightness percentages to another knx address and that is also turning on the light i guess.
So i basically have to break the direct connection between the sensor brightness level and the lights and also pass it by HA.
But i am not sure how to configure the automation so that when the alarm is on nothing passes, and when the alarm is off it basically allows the brightness level to pass without altering.
If i understand you correctly, you have another automation running which turns the light on as well?.
If that’s the case, you could change that automation with the condition that your alarm is “not armed” so all the time you’re at home thus the state " not armed" your light will go on. If you’re away thus “armed” your light wont go on.
If the numeric state was your answer, mark that as post as the answer, you do that by selecting the three dots under the post and the select the check box. By doing this you can help other people which are searching for the same answer.
Sorry if i’m not clear in explaining. It’s not so easy in a foreign language
Basically setup is as follows:
KNX motion and light sensor providing:
switching on/on address
brightness level for the light
When motion is detected it actually send out a ON signal on the switching address and immediately after that it starts sending out brightness percentage values to regulate the light intensity.
I had only read the first switching address into HA and the automation in my post. The second brightness address is coupled directly with the lights through KNX.
This brightness address is also turning on the lights despite the switching ON address blocked by my HA automation.
So i still have to prevent the brightness values being sent to the lights when the alarm is ON.
This means i have to also read in the brightness address from the sensor and break the direct knx connection between them.
But how do i forward the brightness value from KNX sensor to the light address?
Most knx motion sensors provide communication objects to lock their state (either on, off or current). Just use this with a new group address instead of proxying knx telegrams through HA automations.
(I don’t know HA automations but have some experience with knx)