Automation conditions not working anymore

Hi!

For some time now, i dont know when it starded. My alarm coditons are ignored. eg if i turn of wakeup light boolean the light is turned on anyway.

this has wokred before, i cant se the problem now.

- id: '1542056657777'
  alias: Tv4morgonvardagsrum
  trigger:
platform: template
value_template: '{{ states.sensor.time.state == states.sensor.alarm_time.state
  }}'
  condition:
  - condition: and
conditions:
- condition: or
  conditions:
  - condition: and
    conditions:
    - condition: state
      entity_id: input_boolean.alarmweekday
      state: 'on'
    - condition: time
      weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
  - condition: state
    entity_id: input_boolean.alarmweekday
    state: 'off'
  - condition: state
entity_id: group.home_booleans
state: 'on'
  - condition: state
entity_id: input_boolean.tv4alarm
state: 'on'
  action:
data:
  entity_id: script.1542923241474
service: script.turn_on

Any ideas?

You probably need to add initial_state: true, and then restart, assuming you want the automations available upon start.

I must have missed this breaking change too at some point and just corrected it.

Hi!

This is the other way around.

When I set Boolean tv4 to off the automation still triggers.

I doubt anyone would be able to help you until you correctly format your code. There is no way that the way the code you posted above is like that in your config.

What? It is that way.

If you edit via the UI it format like that and there is no errors in the config test.

All automations done that way are like that.
I have like 40 automations, I have 3 with sudden problems

The comment is around indenting whitespace. The indentations make no sense at all. If this is exactly how it is specified then that is your problem right there.

I dont understand what you mean. I have like i said around 40 automations. they are all build up like this and are working. i have built them via the UI. i have 5 automations via the alarmclock and 3 are suddenly taking the boolean value on even if its off. eg coffie machine in the morning ā€œoffā€ and the coffie automation triggers anyway. This is exact code worked before!!!

What you are talking about is not the issue here.

FYI:

You may be right about that but instead of being argumentative about what we are saying try to at least understand it.

YAML is very whitespace sensitive. That whitespacing includes indentation. and the indentation is especially important when you have mixed and & or conditions

take the following properly formatted example:

- alias: example automation
  trigger:
    - platform : state
      entity_id: whatever_1
      to: 'on'
    - platform : state
      entity_id: whatever_2
      to: 'on'
  condition:
    condition: and
      conditions:
        - condition: state
          entity_id: whatever_3
          state: 'off'
        - condition: state
          entity_id: whatever_4
          state: 'off'
        - condition: or
          conditions:
            - condition: state
              entity_id: whatever_5
              state: 'off'
            - condition: state
              entity_id: whatever_6
              state: 'off'
  action:
    - service: whatever
      entity_id: whatever_7

now look at yours.

I really hope you see the difference now. If I copy and paste your code from above into my config in exactly the same way you have it posted I will get errors!

and besides that aspect just look at the conditionsā€¦

This:

  condition:
    condition: and
      conditions:
        - condition: state
          entity_id: whatever_3
          state: 'off'
        - condition: state
          entity_id: whatever_4
          state: 'off'
        - condition: or
          conditions:
            - condition: state
              entity_id: whatever_5
              state: 'off'
            - condition: state
              entity_id: whatever_6
              state: 'off'

is different than this:

  condition:
    condition: and
      conditions:
        - condition: state
          entity_id: whatever_3
          state: 'off'
        - condition: state
          entity_id: whatever_4
          state: 'off'
        - condition: or
          conditions:
            - condition: state
              entity_id: whatever_5
              state: 'off'
        - condition: state
          entity_id: whatever_6
          state: 'off'

because the indentation of the last condition is moved to align with the ā€˜andā€™ block not the ā€˜orā€™ block.

Soā€¦if you want us to help you we need to see your code exactly the way it is in your configuration. And what you have posted is not that or you would have errors.

and if you really looked at the linked post then youā€™ll also see that it didnā€™t re-format their code to the way you have yours posted. It still maintained proper indentation. So that link was a completely non-related issue.

1 Like

I see the problem with the UI generated content, yours looks more ā€˜messed upā€™ than the other example. Is there a method to fix it? It is impossible to see what is under your or block vs the and block

Just a guess, but it seems like based ONLY on the order of your conditions that input_boolean.tv4alarm is an or condition, so it could still fire when off.

Hi!

Thank you for your explanation. I found the error and it was another automation with a miss typing. so the one i showed you wasnt the error. all spaces, ā€œandā€ and ā€œorā€ are in the correct possistion. i have tripple checked this as well.