Switch toggle

Hi all, in my configuration I have a LED configured like a switch.
The idea is toggle the led as far as the alarm panel is in arming state…
I am not able to do this…

Many thanks

It would be best if you post your automation yaml for this automation. It is nearly impossible to provide input unless you do this or show what you have tried.

Thanks

Thanks for your reply, you’re right…

alias: allarme box inserimento
description: ''
trigger:
  - platform: state
    entity_id: alarm_control_panel.allarme_box
    to: arming
condition: []
action:
  - service: switch.turn_on
    entity_id: switch.led_stato
    data:
      flash: short
mode: single

I need something like this, the led must flash as long as the alarm is in “arming” state…

Can you try this?

alias: Allarme Box Inserimento
description: ''
mode: single
trigger:
  - platform: state
    entity_id: alarm_control_panel.allarme_box
    to: arming
condition: []
action:
  - repeat:
      while:
        - condition: state
          entity_id: alarm_control_panel.allarme_box
          state: arming
      sequence:
        - service: switch.turn_on
          target:
            entity_id: switch.led_stato
          data:
            flash: short
        - delay:
            hours: 0
            minutes: 0
            seconds: 2
            milliseconds: 0

It uses repeat while function in which the sequence will be run as long as the condition evaluate to true. You can find more about it in Repeat a Group of Actions.

Many thanks, two questions:
-flash works with switch also or only with lights?
-delay: it stops the global code for 2 seconds or the global code continue to run and goes back to the flash command each 2 seconds?

Thanks

  1. Flash is available for light, according to Light Service Data.
  2. The delay delays 2 seconds before re-evaluating the while condition.

so, I need to convert the switch in to light…

I don’t know about flash for switch. When you run it, does it not work?
As an alternative, you can do this-

      sequence:
        - service: switch.turn_on
          target:
            entity_id: switch.led_stato
        - delay:
            hours: 0
            minutes: 0
            seconds: 1
            milliseconds: 0
        - service: switch.turn_off
          target:
            entity_id: switch.led_stato
        - delay:
            hours: 0
            minutes: 0
            seconds: 1
            milliseconds: 0

Many thanks, it works!