You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: emit labels-changed from save() so Web UI edits reach HA Discovery
User reported: editing labels in the Web UI and clicking Save did NOT
update device names in Home Assistant. Root cause traced to LabelLoader:
- save() wrote the file + updated internal state, but never emitted
labels-changed
- The only emit site was _onFileChanged (the fs.watch callback) at
labelLoader.js:315
- The watcher correctly suppresses its own callback for SELF_WRITE_GRACE_MS
(1000ms) after each save() to prevent re-processing our own write
(labelLoader.js:184)
- Net effect: for in-process saves (PUT /api/labels, PATCH /api/labels,
POST /api/labels/import) the event was silently swallowed
- The bridgeInitializationService listener that calls
haDiscovery.updateLabels + trigger() therefore never ran, and HA never
saw the updated discovery configs
save() now emits labels-changed directly with the full getLabelData()
payload. The watcher's grace period is still correct - it prevents the
file-event path from double-firing.
Same fix automatically covers areas, type_overrides, entity_ids, and
exclude - they all flow through the single save() codepath, and
getLabelData() includes all five sections.
Audit of other label-lifecycle paths found no further bugs: only one
labels-changed subscriber (the bridge), only two emit sites (save and
the watcher callback), no other code paths mutate internal Maps without
going through save() or _onFileChanged.
Tests: new regression for save()-emits-once, new test confirming areas
and the other sections are in the emit payload. The pre-existing
"should not emit when file is written by save() within grace period"
test was codifying the bug; rewritten to assert exactly-once instead.
1256/1256 pass.
Copy file name to clipboardExpand all lines: homeassistant-addon/CHANGELOG.md
+8Lines changed: 8 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -5,6 +5,14 @@ All notable changes to the C-Gate Web Bridge Home Assistant add-on will be docum
5
5
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
8
+
## [1.9.3] - 2026-05-27
9
+
10
+
### Fixed
11
+
12
+
-**Editing labels (or areas / type overrides / entity IDs / exclusions) via the Web UI did not update Home Assistant device names**. `LabelLoader.save()` wrote the file and updated internal state but never emitted `labels-changed` directly. The only emit site was the `fs.watch` callback, which is gated by a 1000ms self-write grace period to prevent double-processing - so for in-process saves (PUT/PATCH `/api/labels`, POST `/api/labels/import`), the event was silently suppressed. The downstream listener that re-triggers HA Discovery therefore never fired, and HA never saw the updated entity configs.
13
+
-`save()` now emits `labels-changed` directly with the full `getLabelData()` payload (labels, areas, typeOverrides, entityIds, exclude). The file-watcher path still correctly suppresses the resulting fs event within the grace window, so there's no double-fire.
14
+
- The same fix automatically covers areas, type overrides, entity IDs, and the exclude list - all flow through the single `save()` codepath.
0 commit comments