Checking window covers postion in group atomation

Hi all,

i couldn’t find answer my question or couldn’t address it correctly.
I have a number of window covers automated with Shelly 2.5 - connected to HA.
All works fine, i created group of all covers to automate them i.e to close after sunset etc.
Problem is, sometimes, someone close or half close covers before sunset and when automation is being trigerred (i.e. to set covers to 30% after sunset) these already closed covers are moving to 30%. My goal is to keep them in the position as it is. Same thing applies to morning automation, when cover is already full open but automation move it to 50% after sunrise. The question is, can it be somehow validated by automation? I tried template, but i guess tempalte ‘state_attr’ does not apply to groups in this case (it make sense) and doesn’t care about one or two covers are already closed/open.

Example of one of my cover automation:

  - platform: sun
    event: sunset
    condition: template
    value_template: "{{ state_attr('cover.rolety', 'current_position') > 75 }}"
  - service: cover.set_cover_position
      entity_id: cover.rolety
      position: 75

Please format your code using the </> button. There could be errors lurking in there that we cannot see until properly formatted. See point 11 here:

If you can both read and write the position for each cover, then yes, you can do what you want with automations. You need to describe exactly what you’re trying to achieve, though.

Are you wanting to give a “group command” but have that only work on covers that are already in the “group position”, not manually altered? If so, how and when do the manually-altered covers re-synchronise with the group?

Thanks Troon,

To be more accurate, i want to group cover automation change cover position only for those where positon apply. I.e after sunset all covers set to 30% closure, but no action for those which are more or equal 30% closed beacuse they have been manually changed before sunset.

I know i can set automation for each cover comparing current postion, but question is can it be done for a group to avoid many automation scripts in overall setup.

value_template: "{{ state_attr('*group instead single cover*', 'current_position') > 30 }}"

This should give you a list of covers with current_position attribute greater than or equal to 30. Have a play in Developer Tools / Template:

{{ expand('group.my_covers')|selectattr('attributes.current_position', '>=', 30)|map(attribute='entity_id')|list }}

Here’s a screenshot of one of my groups being filtered like this, with only the three entities with a timestamp greater than 40000 being included in the final list:

Great hint! But it does’t find any entity for me even when covers are more than 30% closed.
Even if that will work, how to apply it into automation?

What is cover.rolety? Is it a cover group or an individual cover?

I have no experience with cover groups — you might need to create a generic group containing your covers.

Once that’s working, it should be easy to apply to an automation action:

Precisly, it is cover group created based on : Cover Group - Home Assistant

OK, let me play with it. Will come back in case any further questions :slight_smile: