Condition in automation not evaluated

is seems i have issues with conditions in automation, my current condition is not evaluated.

- id: '1596233374824'
  alias: Kommer hjem "PÃ…"
  description: Bortebryter på "Enkelklikk"
  trigger:
  - event_data:
      entity_id: zwave.yttergang_dimmer
      scene_id: 26
    event_type: zwave.scene_activated
    platform: event
  - entity_id: group.allpersons
    platform: state
    to: home
  condition:
  - condition: state
    entity_id: light.kjkken_dimmer_level
    state: 'off'
  action:
  - data: {}
    service: script.lys_dag_pa
  mode: single

How did you check wheter is has been evaluated or not?

I did test with the state of the evaluated condition. And it is not evaluated

Did you execute the automation manually or did you wait for a trigger?

I don’t even know what that means.
Did you reformat it to test in the template editor ?

It does not matter. In this case i did turn off the light in the condition to the state off, i then triggerd the rule manualy in automation section and i did trigger it with the switch also set up as a trigger.

It is testen all possible ways, and it does NOT work. I have also tried with different entitys for condition, and different ways off evaluate it, same result it is ignored

Executing an automation in the automation section ignores the triggers and bypasses the conditions.
It basically jumps straight to the action.
That’s what Burning was getting at.

That is not the case here, it is ignored when it is triggerd with the zwave scene id also. goes straight to actions and execute

Evaluating conditions with template works, i will stick with that

What does that mean?

Are you saying that this works:

  condition:
  - condition: template
    value_template: "{{ states('light.kjkken_dimmer_level') == 'off' }}"

but this does not work?

  condition:
  - condition: state
    entity_id: light.kjkken_dimmer_level
    state: 'off'

They’re equivalent so they should both work. If they don’t then there’s a problem elsewhere.

No, i evaluate condition in the action template,

I’ve never heard of an ‘action template’. Do you mean the automation’s action contains a condition?

To help us understand what works for you, please post an example.

If you read here: https://www.home-assistant.io/docs/configuration/templating/ you can se some examples on how to use template.

You can evaluate variables/entitys with for example if function, this would be a condition. If that do that.

You can achive same result. And it would be evaluated in all cases, if you run the automation manual or anything else.

{% if is_state('device_tracker.paulus', 'home') %}
  Ha, Paulus is home!
{% else %}
  Paulus is at {{ states('device_tracker.paulus') }}.
{% endif %}

This is a function that is conditional

I think Taras probably already knows this page of the docs by heart :wink:

Please show us your code that works for you. I don’t see any issue with the current code and don’t see a reason why it should not work.

1 Like

Wow !

I stand in awe, you, @Burningstone and I have learnt something today.!

(did that sarcasm come out okay.???)

1 Like

And what do you do when the light is not off? You always need an else, this means you need to use a dummy service or something similar for the else part and you make this whole thing way more complicated than it needs to be.

Ok, from the beginning:

You have this code in your automations:

- id: '1596233374824'
  alias: Kommer hjem "PÃ…"
  description: Bortebryter på "Enkelklikk"
  trigger:
  - event_data:
      entity_id: zwave.yttergang_dimmer
      scene_id: 26
    event_type: zwave.scene_activated
    platform: event
  - entity_id: group.allpersons
    platform: state
    to: home
  condition:
  - condition: state
    entity_id: light.kjkken_dimmer_level
    state: 'off'
  action:
  - data: {}
    service: script.lys_dag_pa
  mode: single

Under Configuration -> Automations the automation is enabled.

Under Developer Tools -> Template the below results in “True”:

{{ states("light.kjkken_dimmer_level") == "off" }}

Then you press the z-wave button and then the script.lys_dag_pa still gets executed??

Do you have any other automations that call this script?

Question: Where does the documentation use your term ‘action template’?
Answer: Nowhere because it’s a term you invented.

The words ‘condition’, ‘function’, ‘template’, ‘action’, etc all have specific meanings in Home Assistant. However, you appear to be using them in different ways and that makes it difficult to understand your replies.

Please post an example of your automation, the version that works for you, so that we can understand what you refer to as an ‘action template’.

I suspect you mean you are using a template within the automation’s action either within a condition or a service_template.

Probably, but the problem here is not how i have solved the issue, the issue is that the condition in automation is NOT working.

I have multiple scripts and multiple automations that call eachother yes. And yes, ther is a else involved.

I think we leave it here, probably very vice to update ha docs on cavitys running manual automations that conditions is not evaluated. So next persons dont need to elaborate about life choices here.

It is documented that manually triggering an automation will skip the automation’s trigger and condition and only execute its action.

It won’t work if the automation is executed manually. Otherwise, it will work unless you made some other mistake.

Please show how you solved the issue, I can’t believe that a template worked but the condition in your automation did not work.

You mean like this:

1 Like

Finding relevant documentation on this site is extremly difficult. I suggest you move vital information out of the troubleshooting guide and in to the automation section.