[Feature request]: Average group members' states instead of last modification winning

Aperta
#33,633 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
42/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
backend

Direzione di ricerca

The request concerns how Zigbee group light states are calculated; it names no source files or tests. Start by tracing the code that derives group state from member updates and compare it with the light group behavior described in the issue. Done means deciding the averaging rules and opt-in/default behavior, then reporting the requested values for devices that are on.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Is your feature request related to a problem? Please describe

Since #31663, Home Assistant can auto-discover group members and display it like it's own helper groups, which is amazing. This mostly removes the need for defining helpers on the HA side. However, this also means that the group states are more important than before, as HA displays the values it gets from zigbee2mqtt instead of calculating them itself.

Instead of averaging those values (brightness, hue, color temp), Z2M takes the "last modification wins" approach (other than off state, which is more sophisticated, and is the precedent for what I'm after here), and assigns the last changed members' state as the group state. This is not what the frontends (HA, Ikea, Apple Home, etc.) usually do, and is rather unexpected.

Describe the solution you'd like

It would be neat if z2m used the same-ish rules that home assistant uses when calculating the various values for its group helpers for lights. This means:

  • mean of brightness
  • mean color temperature (it would have to be decided whether to average mireds directly or convert to kelvin first, then average, then convert back, but that's minor IMO)
  • mean for xy color
  • circular mean for hue

taken over the devices that are on. (There are probably some edge cases here, happy to think them through and discuss then before jumping into the implementation if we decide to go ahead with this feature.)

Describe alternatives you've considered

Not changing anything in Z2M leaves two options in HA, both of which I consider workarounds:

  • Don't use zigbee groups but use HA group helpers. This is not great as it leads to popcorning, increases network traffic, etc.
  • Create template lights for each Z2M group that calculate the "correct" averages but forward group commands to the underlying zigbee group directly. It's not too bad with #31663 in hand, but still one extra helper per zigbee group, and they have to be kept sync over the two services.
Additional context

Here's a depiction of what the group reports when I set bulb 1 first and bulb 2 next. I'd expect the group slider to be in the middle.

Image

I'd be more than happy to take a stab at implementing this feature after discussing some of the bigger open questions (e.g., is it opt-in or the new default/only behavior) if you agree that it would be nice to have.

Current Z2M version: 2.14.3. Behavior on dev should be the same based on looking at the code.

Lingua principale
TypeScript
Stelle
15.8k
Fork
2.1k
Merge medio
1g 6h
PR unite (30g)
38

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Koenkk/zigbee2mqtt

Tutte le issue di Koenkk/zigbee2mqtt

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.