Time_trigger every 195 seconds -- why does it trigger every minute?

I would like my automation to trigger every 3 minutes an 15 seconds. Why does it trigger every minute according to the log? What is wrong here?

- alias: 'Kleurtemperatuur automatisch'
  trigger:
    - platform: time_pattern
      seconds: '/195'   # every 3 minutes and 15 secs
    - platform: state   # a light in the list has turned on 
      entity_id: light.woonkamer_plafond, light.keukentafel, light.woonkamer_trio1, light.woonkamer_trio2, light.woonkamer_trio3
      to: 'on'
  condition:
    condition: and
    conditions:
    - condition: state  # at least one of the lights in the group is turned on
      entity_id: group.colortemplights
      state: 'on'
    - condition: template  # trying to prevent flooding the Tradfri bulbs with calls
      value_template: "{{ as_timestamp(now()) - as_timestamp(state_attr('automation.kleurtemperatuur_automatisch','last_triggered')) > 10 }}"
  action:
    - delay:
        seconds: 4
    - service: light.turn_on
      data_template:
        entity_id: "{{ states | selectattr('entity_id', 'in', state_attr('group.colortemplights', 'entity_id')) | selectattr('state', 'equalto', 'on') | map(attribute='entity_id') | join(', ')}}"
        color_temp: "{{ states('sensor.colortemperature') }}"
        transition: 3

try adding from off to on for the light so it only sees the change

    - platform: state   # a light in the list has turned on 
      entity_id: light.woonkamer_plafond, light.keukentafel, light.woonkamer_trio1, light.woonkamer_trio2, light.woonkamer_trio3
      from: 'off'
      to: 'on'

That shouldn’t matter as far as I know? In general you don’t have to specify two states. I think the problem is in the time_pattern, experimenting now :slight_smile:

Edit: this seems to work, first impression:

  trigger:
    - platform: time_pattern
      minutes: '/3'
      seconds: 15

sorry I see… maybe the seconds can’t go over 60?

can you try just

minutes: '/3'

just to see if it works?

  trigger:
    - platform: time_pattern
      minutes: '/3'
      seconds: 15

This works. @Bartem Thanks for your help!

That seems like a bug to me. I’d think I should be able to designate as many seconds as I want. Maybe not, since it’s a Pattern?

Actually I think I remember another topic describing the same thing. I proposed a change to the documentation.

If you look at the time_pattern documentation, it says

With the time pattern trigger, you can match if the hour, minute or second of the current time matches a specific value. You can prefix the value with a / to match whenever the value is divisible by that number. You can specify * to match any value.

So seconds: '/195' should match whenever the seconds (0-59) is divisible by 195, which doesn’t really make much sense, but I’m guessing it triggers when seconds is 0 since that would give 0/195 = 0.

minutes: '/3'
seconds: 15

Should then match whenever minutes is divisible by 3 (0, 3, 6, 9, etc.) and seconds is equal to 15. Therefore, it should trigger at 0:15, 3:15, 6:15, 9:15, etc. regardless of the hour. So, I think in that case it shouldn’t be triggering every 195 seconds but rather every 3 minutes (180 seconds) at the 15 second mark.

2 Likes

Thanks, great explanation.