Problem with Presense in an Automation

Can anyone see why this automation isn’t working? I am sure it’s the trigger

  - id: lizhome'
    alias: Liz at Home
    trigger:
    - at: '00:00:00'
      platform: time
    - entity_id: person.liz
      from: 'not_home'
      platform: state
      to: 'home'
      for: '00:01:00'
    condition:
    - condition: or
      conditions:
      - condition: and
        conditions:
        - condition: state
          entity_id: input_boolean.lizhome
          state: 'on'        
        - condition: template
          value_template: "{{ now().strftime('%H:%M') < '18:30' and now().weekday() == 1 }}"
    - condition: template
      value_template: "{{ now().strftime('%H:%M') == '00:00' and now().weekday() == 2 }}"
    action:
    - service: input_boolean.turn_off
      entity_id: input_boolean.lizhome
    - data:
        message: Liz is at Home now. Liz Home is Off.
      service: notify.david_ios_notify
    mode: single

When my wife is home it is supposed to turn the input_boolean off. This is because she works in the office only on Tuesday only. So I want it to turn off at 00:00:00 on Wednesday if it has not already been triggered on Tues before 18:30. The input boolean is a condition for other automations.

This should have fired yesterday (and the week before) but didn’t. The person.liz seems to be fai=rly responsive and not the cause of this.
image
The input_boolean was ON at that time…

I just don’t see what I am missing here.
Last_triggered is 2 weeks ago for the automation which corresponds to when I added the person trigger…

There may be something amiss with your conditions. There is only one condition in the or block.

I think the last one has to be indented a bit more, like this:

    condition:
    - condition: or
      conditions:
      - condition: and
        conditions:
        - condition: state
          entity_id: input_boolean.lizhome
          state: 'on'        
        - condition: template
          value_template: "{{ now().strftime('%H:%M') < '18:30' and now().weekday() == 1 }}"
      - condition: template
        value_template: "{{ now().strftime('%H:%M') == '00:00' and now().weekday() == 2 }}"

So it can happen on weekday 1 or 2, not weekday 1 and 2 (impossible).

1 Like

I want the state and the weekday 1 to both be true OR the second one to be true.
So I started with or, then the 2 conditions as an and and the third condition was under the original OR I thought…

But I think you might be right and that one needs to be at same indent level…
I even checked it after I made it in the automation GUI and it looked ok… but I bet you are right…

Screenshot_2020-11-11 Home Assistant Community

1 Like

Gotcha…

1 Like