rstrouse / ESPSomfy-RTS-HA

Control your somfy shades in Home Assistant
The Unlicense
134 stars 9 forks source link

EntityID list in group #16

Closed Pulpyyyy closed 1 year ago

Pulpyyyy commented 1 year ago

Hello,

ESPSomfy-RTS group mechanism is working fine and you did a good job. I'm just missing a feature : image As you can see cover.volets_salon does have an extra entity_id attribute with the cover's ID list when defined as cover group in HA yaml config.

cover:
  - platform: group
    name: "volets_salon"
    entities:
      - cover.volet_salon_allee
      - cover.volet_salon_rue

ID list is already available in ESPSomfy-RTS UI image

May this be added as a new feature ?

Many thanks

rstrouse commented 1 year ago

Hmmm... You are using the group platform for this. By design, native motor groups are a standalone entity (single remote channel) in the somfy world. I'll have to do some reading to see what the group platform gives us. I certainly do not want it reflecting commands or manipulating the state of the grouped entities.

Pulpyyyy commented 1 year ago

I do agree. Managing the state of a group is useless. HA does calculate a mean or something, and it's inaccurate. But having the ids allow me to retreive individual states. For example :

{%- macro allstates(group) %}
  {% set all = expand(group|lower) -%}
  {% set positions = all | map(attribute='attributes.current_position')|list-%}
  {% set moving = all | selectattr('state', 'in',  ['opening','closing'])|list|count -%}
  {% set open = positions | reject("!=",100) |list |count -%}
  {% set closed = positions | reject("!=",0) |list |count -%}
  {% set other = positions|list|count - open - closed - moving -%}
  Fermés={{ closed }} Partiels={{ other }} Ouverts={{ open }} {% if moving >0 -%}Actifs={{ moving }}{% endif %}
{%- endmacro %}

Used in a card image

rstrouse commented 1 year ago

Would a state variable with all of the group members fill the bill?

Pulpyyyy commented 1 year ago

A state ? An entity attribute will be consistant with the default HA mechanism in HA may be better image

rstrouse commented 1 year ago

As it turns out those are extra_state_attributes. Like everything in HA it involved digging into the CoverGroup to get a full picture of it. There really is no standard but I chose to set the extra attributes as entity_id for an array of string ids mapped to the entity_id.

I will post v2.0.2 with the changes shortly. image

EDIT: v2.0.2 posted

Pulpyyyy commented 1 year ago

I have to dig a bit with the ha expand function as it does not manage entity_id the same way with both 'group' image The HA group seems recursive, not the rts one

rstrouse commented 1 year ago

Ok so I too have a shovel and did some digging. There is some voodoo that is going on with expand where it doesn't quite perform from the list of ids. Anyhow if you update to v2.0.3 it will act like a CoverGroup. Unfortunately, it also has some weird position rules although I managed to get it to not disable buttons with the state.

rstrouse commented 1 year ago

BTW your template should look like this for defined groups from the backend.

{% set group = 'cover.volets_salon' -%}
{% set rts = expand(state_attr(group|lower, 'entity_id')) -%}
{{ rts }}
Pulpyyyy commented 1 year ago

Perfect ! Thanks for the well

rstrouse commented 1 year ago

If you have sun sensors on any of the shades in your group the system also includes a sun sensor now as of v2.1.0. I really don't like the CoverGroup so at some point I have plans to offload all of this onto the ESP if I can, but for now it will allow you to select a position however awful it is.

I am going to close this. Let me know if you have any other issues.