Automation ignores time condition

I am trying to set up some automations with time conditions but when I click “TRIGGER” from the UI the action still takes place even when the condition is not met.
(I do wonder if this method of triggering ignores the conditions but I cannot check until I get home later)

I have tried:-

  - condition: state
    entity_id: sensor.garage_status
    state: closed
    for: 08:00:00

and

  - condition: state
    entity_id: sensor.garage_status
    state: closed
    for:
      hours: 8

Triggering from the interface fires the action regardless of conditions.

Thanks, I will be able to confirm / check this when I get home later.

Hi,

I have the following automation which seems to ignore my Time Conditions. Basically, I only want the script to be turned on in the following time slots and also only if the input_boolean.medchecker is off.

- id: finn_meds_counter
  alias: Finn Meds Counter
  hide_entity: true
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: binary_sensor.door_window_sensor_158d00019da6da
      to: 'on'
  condition:
    condition: or
    conditions:
      - condition: time
        after: '05:30:00'
        before: '06:45:00'
      - condition: time
        after: '11:45:00'
        before: '12:30:00'
      - condition: time
        after: '15:30:00'
        before: '16:30:00'
      - condition: time
        after: '21:30:00'
        before: '22:30:00'
      - condition: state
        entity_id: input_boolean.medchecker
        state: 'off'
  action:
  - service: script.turn_on
    entity_id: script.finn_meds_counter

Can anyone help debugging?

Thanks

SOLVED: Used combination of And/Or…

uiguy, could you please show us your final code using the and/or?

Here you go:

- id: finn_meds_counter
  alias: Finn Meds Counter
  hide_entity: true
  initial_state: 'on'
  trigger:
    - platform: state
      entity_id: binary_sensor.door_window_sensor_158d00019da6da
      to: 'on'
  condition:
    condition: and
    conditions:
      - condition: state
        entity_id: input_boolean.medchecker
        state: 'off'
      - condition: or
        conditions:
        - condition: time
          after: '05:30:00'
          before: '06:45:00'
        - condition: time
          after: '11:45:00'
          before: '12:30:00'
        - condition: time
          after: '15:30:00'
          before: '16:30:00'
        - condition: time
          after: '21:30:00'
          before: '22:30:00'
  action:
  - service: script.turn_on
    entity_id: script.finn_meds_counter

@anon43302295 - OMG, if this is correct you’ve just saved my sanity after two days of trial and testing and confusion…

“Triggering from the interface fires the action regardless of conditions.”

Seems like I can’t test properly until i’m at home in front of the PIR sensor… Bit daft that though I’d say, at least it’s an explanation. tks…

It allows people to easily test their actions. The assumption is that if people want to also test the conditions they’ll either:

  1. Add another trigger, such as an input_boolean
  2. Use Developer toolsStates and manually change the state of the trigger entity

I’d say wrong assumption. When I trigger an automation my thinking is that it tests that automation entirely, from start to finish if you like, am I wrong?

Dunno where I read it (it may have even been a post similar to the OP) but I found this early on and just accepted it.
As Tinkerer says add a input boolean (I always have a spare)

It’s just the landscape we work in

IMHO there should be two buttons (and matching services) . ‘Trigger now’ and ‘trigger if conditions are met’ (I’m not touting those as the actual interface texts but you get my point).

you could always add the conditions in the action block, and have the manual trigger from service incorporate these conditions just fine.

In fact, thats a great way to be able to use the last_triggered, which otherwise wouldn’t get set (it only sets when the action part is fired)

  action:
    - delay:
        seconds: 1
    - service: script.whatever_action
    - condition: template
      value_template: >
        {{is_state('input_boolean.notify_lights','on')}}
    - service: notify.notify
      data_template:
        message: >
         {{trigger.to_state.attributes.friendly_name}} changed from {{trigger.from_state.state}} to {{trigger.to_state.state}}

as a small example

I feel a feature request coming on (part of the pre-escent IO domain) in the non-too distant future :rofl:

It is actually one of the first things mentioned (in bold!) on the Troubleshooting Automations page in the HA docs.

Yeah, what can I say, I do sometimes read stuff :rofl:

Thanks for pointing out my senility :rofl: