Do a series of actions when HA send a command

For example, I want to make an LED blink for 10 seconds, stay on for 5 seconds, then turn it off.

My question is how can I send such a command? If I utilize a template switch as follows, I can only do these actions when the switch switches from off to on. If the switch is on already, it won’t repeat the actions again.

switch:
  - platform: template
    on_turn_on:
      - light.turn_on:
          id: led
          brightness: 100%
          red: 100%
          green: 0
          blue: 0
          effect: Pulse
      - delay: 10s
      - light.turn_on: 
          id: led
          brightness: 100%
          red: 100%
          green: 0
          blue: 0
          effect: None
      - delay: 5s
      - light.turn_off: led

Have a read about User Defined Services:

1 Like