sec_touch: research multiple listeners per property ID / duplicate poll IDs
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 35/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Attiva
- Stack tecnologico
- cpp
- Ambito
- embedded-iot
Direzione di ricerca
Read components/sec_touch/sec_touch.h and components/sec_touch/sec_touch.cpp, especially the listener maps and register_* functions, then trace the example registration in components/sec_touch/switch/sec_touch_summer_ventilation_switch.cpp. Compare the proposed options for duplicate listeners and poll IDs, including RAM and flash costs and whether register_fan needs the same rule. Done means choosing and implementing a consistent policy, with duplicates handled as intended.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Problem
Property listeners in sec_touch hold one callback per property ID, and registration does not de-duplicate the poll ID lists.
- The listener maps are
std::map<int, UpdateCallbackListener>:recursive_update_listenersandmanual_update_listeners(sec_touch.h#L78-L84). PR #20 adds a third one,string_update_listeners(std::map<int, StringUpdateCallbackListener>), with the same pattern. - Each
register_*function (sec_touch.cpp#L295-L311, plusregister_global_setting_string_listenerin PR #20) doesmap[property_id] = std::move(listener)and thenpush_back(property_id)ontofan_level_property_ids_,fan_label_property_ids_orglobal_setting_property_ids_.
When two entities register for the same property ID:
- The second listener silently replaces the first. The first entity never gets updates.
- The ID appears twice in the poll list, so it is requested twice per update cycle.
An int listener and a string listener on the same ID live in separate maps, so both fire. That is intended and not part of this issue.
This is a pre-existing pattern on main, not something PR #20 introduced. It came up while reviewing that PR.
Reproduction
switch:
- platform: sec_touch
name: "Summer ventilation A"
- platform: sec_touch
name: "Summer ventilation B"
Both switches register SUMMER_VENTILATION_PROPERTY_ID via register_global_setting_recursive_listener (sec_touch_summer_ventilation_switch.cpp#L17). Only "B" gets state updates, and the ID is polled twice. With PR #20, two sensor: - platform: sec_touch entries that each set clock_drift hit the same issue on the date/clock IDs.
Open questions
- Is more than one entity per property ID a realistic use case at all (for example a second entity with different filters or a different name), or is it always a config mistake?
- Which option fits?
- Multiple listeners per ID:
std::multimaporstd::map<int, std::vector<Listener>>, plus de-duplicated ID lists. - De-duplicate the ID lists only: fixes the double poll but keeps last-wins listeners.
- Reject duplicates in Python config validation with a clear error. This fails at compile time and needs no runtime cost.
- Log a warning on re-registration: the cheapest change, but it only shows up in the device logs.
- Multiple listeners per ID:
- What does each option cost in ESP RAM and flash? A vector per map entry adds heap allocations per property. Today's configs have a small, fixed number of IDs.
- Should the same rule apply to
register_fan/fans_(also keyed by level ID)?
- Lingua principale
- C++
- Stelle
- 8
- Fork
- 4
- Merge medio
- 15h 58m
- PR unite (30g)
- 5
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di distante/esphome-components
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
Sniffer: hub message tap with raw strings and scan outcomeForse già presa @distante l’ha presa oggi. Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 53/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
-
Sniffer: HTML pageAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 55/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
Tutte le issue di distante/esphome-components
Issue simili
-
Needs: Author Feedback Needs: Repro
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
react/react-native#60059 · 1 commento ·
I maintainer di solito rispondono entro 2 giorni
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
petercorke/robotics-toolbox-python#943 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
area:build bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 90/100
NatronGitHub/openfx-arena#71 ·
I maintainer di solito rispondono entro 1 giorno
-
upstream-blocked
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
ROCm/FastFlowLM#1057 ·
I maintainer di solito rispondono entro 1 giorno