Dynamic cover groups?

I’m trying to dynamically manage a cover group. I’m able to use the group.set service to manage members of a group, but it’s just a generic group, while I’d like it to be a cover group.

My use case is that I have an automation that closes the shades based on the sun’s position (using a boolean_sensor to indicate if the window is in sun). I’d like to be able to dynamically add and remove shades from two cover groups: sunny shades and shady shades. This would allow me to use Google Assistant (my primary means of manually controlling my shades) to open/close all shades that are currently in sun or currently in shade. (“Hey Google, open the shady shades.”)

Anyone know if this is possible, or have any alternatives to this approach?

I’m a NodeRed person so I think that way, but currently at home crook as a dog so apologies if this is not quite lucid…

Set up a Boolean helper for each shade. That will be shaded or sunny, 1 or 0, whatever you like. Those are fed by the sensor you already have set up.

Also set up four Booleans “Open Shady Shades” “Close Shady Shades”, “Open Sunny Shades” and “Close Sunny Shades”.

Set up four automations in Google. When you say open or close the shady shades it will trigger the Boolean listed above to go to ON.

Now to individually control the curtains have State Node checking the status of those four Booleans and looking for a change.

Your Open Shady Shades Boolean has just changed state based on your command to GH.

Your State Node detects this and sends a command to a Current State Node of which you have one set up for each shade. If the Current State Node for the Kitchen Shade says it is shady based on the Boolean for that shade, it will pass on the signal to open the curtain. If it is not, it will not so there will be no change.

The State Node will send the same command off to all the other Shades via their Current State Node.

Once the commands have gone through you will need to reset the Booleans that you have used to trigger it (“Open Shady Shades” “Close Shady Shades”, “Open Sunny Shades” and “Open Sunny Shades”.) back to OFF.

I use a Wait Node off the State Node set for 5 seconds, this feeds into a Call Service Node to reset the State Node back to OFF.

You will need one flow for each of the Google command Booleans, and they will each feed to each o the curtains.

Its not the neatest, but it should work, and I am sure it could be trimmed back a bit or done using Templates.

Do you really need dynamic groups? Maybe there’s an easier way to get what you want. Easiest but least elegant would be to create 4 scripts in HA. The first, for example, would be to close all the shady blinds. It would simply be a bunch of “if” statements: if blind 1 is shady, close it. If blind 2 is shady, close it. Repeat ad naseum for each blind, and then duplicate the script for “open shady blinds” and “close sunny blinds” and “open sunny blinds”.

Wow thanks for the detailed response! I’m not completely following, and I think I’d like to keep this all within Home Assistant, but this might give me some ideas. Also, hope you feel better soon!

I guess the rationale behind using groups was so they could be treaded as covers and get all the good stuff that comes along with that. Your suggestion does seem like a good workaround, though, so thanks!

You could try some complicated cover template, but you’ll have to think about how you want it to appear. For example, if you have some shaded blinds closed and some shaded blinds open, what state do you want that to be? Or if all blinds are in the sun, what state should your shady blinds (consisting of zero blinds) be?

In the example below, if all blinds are in the sun, shady blinds will be “open”. If there are some shady blinds open and some closed, the position of shady_blinds will be “50”. You’d still need to write a script to open and close the blinds, but that should be relatively simple.

cover:
  - platform: template
    covers:
      shady_blinds:
        device_class: blind
        friendly_name: "Shady Blinds"
        unique_id: shady_blinds_template
        position_template: >-
          {% if (
            ((is_state('boolean_sensor.blind_1_in_sun', 'off') 
            and is_state('cover.blind_1', 'open'))
            or is_state('boolean_sensor.blind_1_in_sun', 'on'))
            and
            ((is_state('boolean_sensor.blind_2_in_sun', 'off') 
            and is_state('cover.blind_2', 'open'))
            or is_state('boolean_sensor.blind_2_in_sun', 'on'))
            and
            ((is_state('boolean_sensor.blind_3_in_sun', 'off') 
            and is_state('cover.blind_3', 'open'))
            or is_state('boolean_sensor.blind_3_in_sun', 'on'))
            ) %}
            100
          {% elif (
            ((is_state('boolean_sensor.blind_1_in_sun', 'off') 
            and is_state('cover.blind_1', 'closed'))
            or is_state('boolean_sensor.blind_1_in_sun', 'on'))
            and
            ((is_state('boolean_sensor.blind_2_in_sun', 'off') 
            and is_state('cover.blind_2', 'closed'))
            or is_state('boolean_sensor.blind_2_in_sun', 'on'))
            and
            ((is_state('boolean_sensor.blind_3_in_sun', 'off') 
            and is_state('cover.blind_3', 'closed'))
            or is_state('boolean_sensor.blind_3_in_sun', 'on'))
            ) %}
            0
          {% else %}
            50
          {% endif %}
        open_cover:
          - service: script.open_shady_blinds
        close_cover:
          - service: script.close_shady_blinds

Node Red is an add on that is available in HA. Its well though out and used by a lot of people.

Basically it is a flow chart. I find it easier to use than making automations in HA.

It is a bit of a learning curve but there are a lot of resources on line. I would recommend the YouTube channel the Hook Up.

He is big into HA, CCTV, curtains and all automation stuff and he is a pleasure to watch.
I find Node Red easier for automations as it suits the way my mind works.

Have a look, it is a bit to learn but once you start on it automations are so much easier to code.