Condition Time automation help please

Hi I have read up, but still can’t understand why my conditions won’t pass when I test them

alias: 'Zone: Away from Home'
description: ''
trigger:
  - platform: state
    entity_id: group.brad_and_lauren
    to: not_home
    for:
      hours: 0
      minutes: 2
      seconds: 0
condition:
  - condition: time
    after: '09:00:00'
    before: '17:00:00'
    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun
action:
  - service: script.lights_turn_off_all_lights
    data: {}
  - service: script.ac_dogs_ac_zone
    data: {}
  - service: script.vacuum_start_vacuums
    data: {}
  - service: media_player.turn_off
    data: {}
    target:
      entity_id:
        - media_player.void_lounge_sonos_5
        - media_player.dining_room_sonos_5
  - service: notify.mobile_app_brad_s_phone
    data:
      message: '[Zone Automation] Away From Home'
mode: single

This is redundant:

    weekday:
      - mon
      - tue
      - wed
      - thu
      - fri
      - sat
      - sun

All days is the default. Use the automation tracer to see why your automation is not working:

That didn’t really help me mate. Doesn’t explain why the condition is not passing.

So you don’t see anything like this for the time condition when you check it:

Executed: 8 April 2022, 20:00:00
Result:

after:
  __type: <class 'datetime.time'>
  isoformat: '07:30:00'
now_time:
  __type: <class 'datetime.time'>
  isoformat: '20:00:00.014886'
before:
  __type: <class 'datetime.time'>
  isoformat: '22:30:00'
result: true

What tab would that be under when in trace??

Click on the step and it is in Step Details.

Says
This node was not executed and so no further trace information is available.

So it never triggers?

I just tried again and nothing

This is my code.

I read it the condition as 'if away or its after 9 or before 5 then send notification??

alias: 'Zone: Away from Home'
description: ''
trigger:
  - platform: state
    to: not_home
    for:
      hours: 0
      minutes: 2
      seconds: 0
    entity_id: group.brad_and_lauren
condition:
  - condition: or
    conditions:
      - condition: time
        after: input_datetime.after_9am
  - condition: or
    conditions:
      - condition: time
        before: input_datetime.before_5pm
action:
  - service: notify.mobile_app_brad_s_phone
    data:
      message: '[Zone Automation] Away From Home'
mode: single

So what you posted wasn’t your code?

Come on. How are we supposed to help when you do that?

Your conditions are misconfigured. Should be:

condition:
  - condition: or
    conditions:
      - condition: time
        after: input_datetime.after_9am
      - condition: time
        before: input_datetime.before_5pm

I have been trying to figure it out

That’s the updated code that’s all.

I tried that code and didn’t work…

How would you do.this automation?? I must be doing something wrong

Yes, you are triggering the automation manually. That skips the conditions.

Ok, so I just need to wait?

Use the trigger automation service in the developer tools services page. And turn off the skip conditions switch.

1 Like

Ok thanks, another thing learnt again Tom!