Time Condition Bug: Changing the after value to a valid time results in error

I’ve been trying to get my time based conditions to work for the better part of a couple days now. I’ve read the documentation on the HA conditions and even searched through 10+ posts with similar topics.

I’m not sure if this is a bug in the UI or I’m completely missing the point. My goal is to set an automation based on weeknights to turn off after 3 minutes, when no motion is detected, between 5pm and 10pm on weeknights: Sunday - Thursday.

I’ll post the full YAML at the bottom but here are some screen shots of valid entries that work and then simply changing the “after” time to a still valid time, results in a red flag.

Here is a simple dummy test to prove im not losing my mind.:
9am to 10pm is valid

But yet once I change the after value to 5pm, it is no longer valid.

Full YAML:

alias: 'Kitchen: Motion Off Weeknights'
description: ''
trigger:
  - type: no_motion
    platform: device
    device_id: my.device.id
    entity_id: binary_sensor.g3_instant_motion
    domain: binary_sensor
    for:
      hours: 0
      minutes: 3
      seconds: 0
condition:
  - condition: time
    before: '22:00:00'
    after: '17:00:00'
    weekday:
      - mon
      - tue
      - thu
      - wed
      - sun
action:
  - service: script.switch_turn_off_kitchen_motion_light
    data: {}
mode: single

I can’t duplicate the error:

alias: test
description: ''
trigger:
  - platform: state
    entity_id:
      - binary_sensor.closet_pir_sensor
    to: 'on'
condition:
  - condition: time
    before: '22:00:00'
    after: '17:00:00'
    weekday:
      - mon
      - tue
      - wed
      - thu
      - sun
action:
  - service: switch.turn_on
    data: {}
    target:
      entity_id: switch.closet_pir_relay
mode: single

I also don’t see a trigger type of “motion” or “no_motion” in the GUI. Where is that coming from?

When you click the Test button, you’re checking if the current time is between 5:00 PM and 10:00 PM (and one of the listed days). When you performed the test, was the time within the specified range?

It’s expected for the Test button to report false if the test was performed at a time outside of the range.

1 Like

It was out of the range. I assumed the test was a validation on if it was a valid YAML configuration without syntax errors or something, not: “is this code valid at this very moment”. I feel like an idiot now.

Thanks for the clarification!

1 Like

The motion sensor was coming from my Unifi instant camera.

123 Taras informed me that it was throwing False due to the current time of day. I didn’t realize the test would throw an error due to current time.