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
feat: event-driven HA Discovery refresh on Network created
C-Gate emits async system events on the command port (response code 742)
when a network finishes loading, e.g.:
20260504-193110.569 742 //PROJECT/254 c2211b00-... Network created
type=cni address=192.168.0.100:10001
Previously these lines were dropped — _parseCommandResponseLine split on
the first hyphen, which landed in the timestamp, producing a non-3-digit
"code" and a "Skipping non-response line" debug log. Worse: even after a
timestamp strip, hyphens in payload UUIDs would derail the hyphen-first
split and mis-parse codes mid-payload.
Three coordinated changes:
1) commandResponseProcessor parser: strip a leading C-Gate timestamp
prefix, then anchor the response code to positions 0-2 (rejecting
anything where char 3 is a digit, which would mean the "code" was
part of a longer number). The validity range is widened from 1xx-6xx
to 1xx-9xx so async system events (7xx/8xx) and job lifecycle
events (9xx) route correctly. Canonical "CCC-DATA"/"CCC DATA" lines
parse identically.
2) commandResponseProcessor routing: case 742 ("Network created") is
detected by message text and parsed for the network id, then
forwarded to haDiscovery.handleNetworkCreated().
3) HaDiscovery.handleNetworkCreated(): gates by the same scope rules
as trigger() — if ha_discovery_networks is configured, only those
networks refresh; otherwise any network through. Calls
queueTreeRequest() which de-duplicates against pending requests
and cancels any pending v1.8.1 retry timer, so a Network created
event mid-backoff just short-circuits the wait.
Net effect: the discovery delay on cold starts collapses from
2-30+ seconds (v1.8.1 retry backoff) to whatever C-Gate takes to
finish loading the network and emit the 742 event — typically ~2s.
Retry remains as defence in depth.
Bumps to 1.8.5.
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.8.5] - 2026-05-04
9
+
10
+
### Added
11
+
-**Event-driven HA Discovery refresh**: when a network finishes loading in C-Gate (async system event 742, "Network created"), HA Discovery now refreshes the network's tree the moment it becomes available, instead of waiting for the v1.8.1 retry backoff to fire. This eliminates the discovery delay on cold starts where C-Gate initialises a few seconds after opening its TCP port. The retry remains as belt-and-braces.
12
+
13
+
### Changed
14
+
-**Command response parser hardening**: the parser now recognises C-Gate's timestamp-prefixed async event lines (e.g. `20260504-193110.569 742 //PROJECT/254 ... Network created ...`) by stripping the leading timestamp before parsing. The parser also pins response codes to positions 0-2 of the line, eliminating mis-parses caused by hyphens elsewhere in the payload (UUIDs, etc.). Validity range expanded from 1xx-6xx to 1xx-9xx so 7xx/8xx async events route correctly. Behaviour for canonical lines like `200-OK` is unchanged.
0 commit comments