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'
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.