Need help with automation condition

Hello,

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.

Thanks for any help!

if i’m not mistaken you should use numeric state, due to the facts its a number and not a state. But i don’t know how your sensor is build up.

  condition:
  - below: '1'
    condition: numeric_state
    entity_id: sensor.bureau_partitie_status

try:

 condition:
   - condition: template
     value_template: >
       {{is_state('sensor.bureau_partitie_status','0')}}

while you’re at it, make it a bit more readable:

- 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

What does that mean?

are you getting errors in the log?

If not, then does the automation always work or does it never work?

It doesn’t make any difference in this case. A state can also be a number and a number an also be a state. It depends on how the sensor is set up.

That’s what I say. It depends on how the sensor is build.

The numeric value does work for me though

@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!

I’ll post an update when i have more results!

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… :slight_smile:
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 :slight_smile:

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?

I hope this is a bit clear now.

I’ve no experience with any KNX sensor, so i can’t help you with that. If its an automation i could help you.

If i’m not mistaken you’re Dutch?. Send me an PM in Dutch language, maybe i can help you further when you explain it in your mother language.

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)

I know but I I’m using that object for another purpose already!