After a reorganization of lightening, all of the Sonoff Basic I had are now defined as switches (they used to be defined as lights).
This brought it the issue of a group being toggled by going though all entries separately and toggling their state. This means that if I have switches A B and C, and A and B are off of but C is on, toggling the group will yield A-on, B-on, C-off.
When searching for solutions, I found this brilliant identical question from the past (How to access a card toggle as an entity?) - it happens to be mine :). The answer was "create a light group). But I have switches.
Toggle service call toggles individual devices in group also addresses this and the answer is “this is by design”. I wanted to have a confirmation before jumping into coding a “toggle for a group of switches” (that would check if any of the switches are on and then go though the list of entities) - this is quite surprising because the switch does exist from Loveralce (so I do not understand why not porting this to services, as the logic already exists)
I had exactly that but reverted back to switches as switches because the light switch integration disables the possibility to manage devices via the frontend
If so, this requires I believe a static definition for each group (I do not know automations in HA, I use AppDaemon). I have quite a lot of dynamism in my automations and keeping track of one entry per group would quickly be unmaintainable.
All this if i correctly understood the solution of course (if not I would be glad to learn how to make it a template for all groups of switches)
What do you mean with this? That you can’t add/remove entities to the group and the automation will take it into consideration? The template from petro doesn’t care about the members of the group, it loops through all entities of the group.
I have about 20 groups so each of them would require a specific entry such as the one in the . Each time I add (or remove) a group I need to update that list.
Now, I have plenty of (wall) switches that send a message which is the interpreted to switch on, off or toggle an entity (single entity, list of entities or group). So the trigger section of the automation gets complicated as well.
In AppDaemon I have a YAML file that defines which actions are expected for each (wall) switch
and each time they send a message as part of the event attributes (single for instance), the relevant function gets called. Before, when my switch was mapped to light via the switch platform I could just toggle and it worked. Now I have to use a function that analyzes the current state.
Still, this is just one function, common to all groups.