Disable many switches in script

Hi, I’m trying to run such script:

rolety_stop:
  alias: Rolety - Stop
  sequence:
    - service: homeassistant.turn_off
      data: {}
      entity_id: switch.rol_1_dol
    - service: homeassistant.turn_off
      data: {}
      entity_id: switch.rol_1_gora
    - service: homeassistant.turn_off
      data: {}
      entity_id: switch.rol_2_dol
    - service: homeassistant.turn_off
      data: {}
      entity_id: switch.rol_2_gora
    - service: homeassistant.turn_off
      data: {}
      entity_id: switch.rol_3_dol
    - service: homeassistant.turn_off
      data: {}
      entity_id: switch.rol_3_gora

    - service: homeassistant.turn_off
      data: {}
      entity_id: switch.rol_4_dol
    - service: homeassistant.turn_off
      data: {}
      entity_id: switch.rol_4_gora
  mode: single

But it works only for first entity. Next are not changing state. What’s wrong here?

Not an answer to your question but you could group them and just switch off the group.

Does it work if you put a small delay between each step in the sequence ?

rolety_stop:
  alias: Rolety - Stop
  sequence:
    - service: homeassistant.turn_off
      data: {}
      entity_id: switch.rol_1_dol
    - delay: '00:00:02'
    - service: homeassistant.turn_off
      data: {}
      entity_id: switch.rol_1_gora

nope, same behaviour

Same issue when using groups. Might it be related to integration which I use - satel_integra? Switches are configured as switchable_output.

What kind of switch is it?
Is it a normal switch then you should perhaps use switch.turn_off service?

I beliuve it normal switch, more details here: https://www.home-assistant.io/integrations/satel_integra/

I tried with switch.turn_off, but with same results - only first switch was turned off.

So what happens if you switch them off in a different order?

Always is switched the first one from first sequence. Next are ignored.

Are there any errors in the log?

nope, maybe I have to increase verbosity? also I don’t see anything suspicious in journal, just script started and finished.

Try increasing the delay to 5 seconds.

Ok, longer delay helped. But it’s not resolving my case. I’m trying to control window curtains. There are 8 switchable_outputs which have to be stopped at one time when I will run ‘Stop all’ script.

Looks like bug in satel_integra module?

What are the chances ?!
Same issue, same day, same integration :thinking:

Hi,

I have a script that works fine for me.
Mayby this can help.

i_m_back:
alias: I m Back
description: Turns on hallway lights, Disarm The Alarm
sequence:

  • alias: Turn Alarm Off
    data:
    code: !secret AlarmCode
    entity_id: alarm_control_panel.home_alarm
    service: alarm_control_panel.alarm_disarm
  • alias: Hallway lights on
    service: light.turn_on
    data:
    brightness: 50
    entity_id: light.hallway_light_2
  • alias: Acer On
    entity_id: switch.power_acer
    service: switch.turn_on
  • condition: state
    entity_id: sun.sun
    state: ‘below_horizon’
  • alias: KeukenLed acer On
    entity_id: switch.on_off_plug_in_unit_2
    service: switch.turn_on

Reported here: https://github.com/home-assistant/core/issues/42111

2 Likes

I thought you had no luck with a 2 second delay?

In the issue you have a 0.5 second delay required:

(at least 00:00:00.5)

.

Probably I missed some things during tests, finally 0.5 works fine, 0.4 and 0.3 randomly works, < 0.3 works as no delay.

1 Like

It sounds like the integration might be using a restful command to control the switches and the API can only receive one command at a time. I had the same issue when setting up controls for my Yamaha amplifier. However in that case a 1 second delay between successive commands was no issue.

Would this type of command work with a gate motor switch as well?

I have an electronic gate virtual switch directly under the live feed of my front gate for opening and closing while viewing who’s at the gate. However, I have had a scenario, where someone in the household presses the button (Probably unintentionally) during the night, which is a problem as there is a manual lock on the gate which gets locked after everyone is home. The issue is that when the button is pressed and the gate is locked, it causes major problems in the morning unlocking the lock, because the gate has shifted open slightly, and the lock cant be accessed, or should I say, can get accessed but almost impossible.

Also would this snippet go into “Automations” or some other part of HA, as I have only just recently set it up, and thus far, I only have the gate on it, and the cameras (So, very new to all of this).

The Virtual switch is just called “ewelink_virtual_switch” (Haven’t dipped my toes into the proverbial water too deep yet to put the ESPHome firmware on it yet)

Also, would the code look something like this…

rolety_stop:
  alias: Rolety - Stop
  sequence:
    - service: homeassistant.turn_off
      data: {}
      entity_id: ewelink_virtual_switch

Or does this code switch off HA as well?

Apologies for all the noob questions, but your post is actually the very first post I have found that even remotely addresses my problem in the slightest as far as my searches have gone.

Thanks for the reply, if any :+1: