Need to set the state of several switches without triggering

Hi there!

I am a newbie, I started my Home assistant project 2 months ago.

I am using HA as a remote to send UDP command to a group of interactive video players in order to trigger events on them.

I have made some switches that toggle an event on or off.
My code for three switches is as follow:

  - platform: command_line
    switches:
      niche_all_sw:
        command_on: printf NITON|nc -w 1 -u -b 192.168.1.255 5000
        command_off: printf NITOFF|nc -w 1 -u -b 192.168.1.255 5000
        unique_id: niche_all_sw
      niche_haut_sw:
        command_on: printf NIHON|nc -w 1 -u -b 192.168.1.255 5000
        command_off: printf NIHOFF|nc -w 1 -u -b 192.168.1.255 5000
        unique_id: niche_haut_sw
      niche_bas_sw:
        command_on: printf NIBON|nc -w 1 -u -b 192.168.1.255 5000
        command_off: printf NIBOFF|nc -w 1 -u -b 192.168.1.255 5000
        unique_id: niche_bas_sw

So far so good.

I also have a switch to trigger off all the events above which code is as follow:

  - platform: command_line
    switches:
      blackout_sw:
        command_on: printf BK|nc -w 1 -u -b 192.168.1.255 5000
        command_off: printf BK|nc -w 1 -u -b 192.168.1.255 5000
        unique_id: blackout_sw

This switch is switching off all events whatever its state instantly.
But it doesn’t set the state of the other switches to off.

So I tried another way to do this by creating a group of the three switches and an associated helper.
I also tried to trigger a scene with the three switches.

In both cases it works, all switches turn to off and their states are set to off.
The only issue with both methods is that it sets off the switches sequentially and I loose the instant switch off effect I need.

So I was wondering if there was a way for me to set the state off the switches to off without triggering them.

Any ideas?

You need either to define the command_state or the value_template so that it can tell the state of those.

If you want to use the value_template then you’re going to need some way of tracking the (assumed) state - such as an input_boolean that you turn on and off with the light.