Automation with time pattern unexpected behaviour - not starting at specified time

I attempted to set up an automation with a time pattern as Hours: /3 and starting at 23:00. It did not trigger. Does this mean it will only trigger after 3 hours from 23:00? So at 2am it will proceed with the actions? I thought it would action at 23:00 and then trigger in another 3 hours. Didn’t seem to be the case.

- id: '1588816839483'
  alias: Heating upstairs on every 2.5 hours
  description: ''
  trigger:
  - hours: /3
    platform: time_pattern
  condition:
  - after: '23:00'
    before: '17:00'
    condition: time
  action:
  - data: {}
    entity_id: switch.sonoff_10008ffb6a
    service: switch.turn_on
  - delay: 00:30
  - data: {}
    entity_id: switch.sonoff_10008ffb6a
    service: switch.turn_off

Now I have it modified so it checks every minute and turns on a switch with a delay, switches off and another delay of 2 hours 45 mins.
I’m sure this is not the correct way but before it was not working. These appears long wnded but does seem to work.

Any advice would be appreciated. I’ve a discussion about this before but encountered these issues.

- id: '1588816839483'
  alias: Heating bedroom on
  description: ''
  trigger:
  - at: '23:00'
    platform: time
  - minutes: /1
    platform: time_pattern
  condition:
  - after: '23:00'
    before: 17:00
    condition: time
  action:
  - data: {}
    entity_id: switch.sonoff_10008ffb6a
    service: switch.turn_on
  - delay: 00:30
  - data: {}
    entity_id: switch.sonoff_10008ffb6a
    service: switch.turn_off
  - delay: 02:45

I dont believe you have control over what 3 hour period it starts at. It might be 3 hours from HA start?

/3 means divisible by three with no remainder. So 3, 6, 9, 12, 15, 18, 21, 0.

1 Like

You could use multiple time triggers and define the specific times manually.

1 Like

Thanks for the quick replies guys.

I’ll have a further look at creating multiple triggers in the same script

Something like this? Would this trigger at the specified times? Could take out the condition or need to amend that?

- id: '1588816839483'
  alias: Heating bedroom on every 3 hours
  description: ''
  trigger:
  - at: '23:00'
    platform: time
  - at: 02:00
    platform: time
  - at: 05:00
    platform: time
  condition:
  - after: '23:00'
    before: 08:00
    condition: time
  action:
  - data: {}
    entity_id: switch.sonoff_10008ffb6a
    service: switch.turn_on
  - delay: 00:30
  - data: {}
    entity_id: switch.sonoff_10008ffb6a
    service: switch.turn_off

With the triggers at those specific times you can probably delete the conditions, but having said that, it’s belt and braces just in case you add a 16:00 trigger without thinking
:man_shrugging:

This may not trigger at 23:00.

  trigger:
  - at: '23:00'
.
.
.
  condition:
  - after: '23:00'

Try after 22:59 to be safe.

1 Like

According to pnbruckner (aka God, though he won’t like that ! :rofl: )
After 23:00 actually means => 23:00 and before 17:00 means =< 17:00

Edit: Admittedly this only applies to - time platform trigger and the space is limited hence ‘after’ rather than ‘at or after’ (a bit of a clumsy mouthful, but English is a poor medium to concisely describe these things)

1 Like

Yep. And yes, you can remove the condition.

1 Like

That’s good to know.
I use SQL daily and always use >= if I was to start at 23:00.
I’ll see tonight at 23:00!