Add repetitions to Timer component

Add the ability to specify how many times a timer should run (default is repetitions: 1).

In the following example, the timer is configured to run ten times. When started, it will run for a duration of 30 seconds, fire a timer.finished event, then automatically restart itself (and repeat this behavior for a total of ten times).

timer:
  test:
    duration: '00:00:30'
    repetitions: 10

All existing timer services continue to work as they currently do, providing start, pause, cancel, and finish.

The timer.start service should be enhanced to support repetitions as an optional parameter.

Attribute    Optional  Description
-----------  --------  ---------------------------------------------------------
entity_id    no        Name of the entity to take action, e.g., timer.timer0.
duration     yes       Duration in seconds or 00:00:00 until the timer finishes.
repetitions  yes       Number of times the timer should run (default is 1).

This request permits a timer to trigger an automation for a given number of repetitions without the automation having to manage the timer’s repetition count (using a counter value). The optional repetitions parameter allows the timer to manage itself.

Applications:

In the following examples, an automation can dynamically set a timer’s duration and repetitions and start/pause/cancel/finish the timer there by providing complete control over the timer’s operation.

  • Send a notification, play an announcement, or toggle a light X times every Y seconds (repetitions: X, duration: Y).

  • Ramp a light’s brightness or a media_player’s volume in 5 steps of 10% every 3 seconds (repetitions: 5, duration: 3).