Repository navigation
feat(zigbee): add USB/serial OpenZigBee gateway support (BTicino 3578 / Legrand 088328) (#233) - #956
GreenGrassBlueOcean wants to merge 23 commits into
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
4530e00 to
3c1d4ab
Compare
…/release-2.0.2 + master + #956)
|
@gdluck what do you think of this pr and the corresponding ownd pr? Do you maybe have time to do an audit so that i can polish it a bit more |
|
Do you somehow have a firmware available? |
Unfortunately no — we checked across all usual vendor channels and confirmed none was ever published:
Also the device is not for sale anymore somewhere on ebay or new... |
|
Full line-by-line, function-by-function audit of (Companion Merge / Rebase Blockers (
|
3c1d4ab to
3197fea
Compare
…y, YAML, and 3578 WHO 14 audit findings
…agnostics, trace, and CI audit findings
…, session, and config flow audit findings
…sensor, binary_sensor, and button audit findings
|
Rebased
Verification ( |
…ad count, and refresh timeout
…y, YAML, and 3578 WHO 14 audit findings
…agnostics, trace, and CI audit findings
…, session, and config flow audit findings
…sensor, binary_sensor, and button audit findings
…h 2.1.0b3 docs/notes
…est_who14_cover_scope
…cle privacy after v2.0.2 master rebase (#233)
3197fea to
6691aec
Compare
What is the problem
USB-based OpenZigBee gateways (BTicino
3578/ Legrand088328, MyHOME_Play / MyHOME Radio) are not supported natively inMyHOME(2.0.x), and live hardware testing on a physicalLegrand 3578(fw 1.2.3) in #233 (#7087437805,#7088211437) plus@mvalla's2.1.0b2report and follow-up2.1.0b3protocol/runtime audits surfaced key protocol, UX, lifecycle, and privacy requirements:#9addressing in2.0.x:MyHOMEonly configured TCP/IP gateways, while OpenZigBee#9suffixes (<ADDR><UNIT>#9,0#00#9,0#<UNIT>#9,0#9,#<G>#9) overlap syntactically with wired SCS addresses (*4*1*012#9##,*4*1*1#9##,*22*1*2#9##,*1*1*#9##) and Area 10 (100#9).DIM 66ACKs,*#*6##radio BUSY,≤ 1/sRF broadcast pacing,35 soffline scan windows, &WHO=13lifecycle onfw 1.2.3: Multi-gang switches emit<DIM 66><*#*1##>per unit (01, then+32.5 ms02), unpowered/floating 503-box actuators emit*#13*<ADDR>00#9*66*<INDEX>##+*#*0##(1.23 s), busy RF channels return*#*6##, leaving Supervisor disabled during per-indexDIM 66scans risks dropping unsolicited RF state frames, RF broadcasts (*13*66*##/*13*65*##) require≤ 1/spacing, andWHO=13leave (WHAT 34,*13*34*<ADDR>00#9##), empty-WHERE*13*22/33/34*##indications, mid-scanWHAT 33joins, non-WHAT 33power-on recoveries, and runtimeDIM 66device-type upgrades must keep availability, Supervisor mode, and platform entities consistent.DIMENSION 1NACK, coarseWHAT 2..10quantization, authoritative switchWHAT 0/1vsWHAT 32motion keepalive,WHO 2 DIM 11without#001, & unsupported wired-SCS features:3578 fw 1.2.3NACKsWHO 1 DIMENSION 1(*#1*WHERE#9*1##→*#*0##in16.8 ms), physical+/-button presses emit level-less*1*1*WHERE#9##frames, coarseWHAT 2..10Supervisor echoes (1/5/10/20/30/40/50/60/75/100%) overwrite fine Home Assistant brightness percentages (e.g.32%snapped to30%) unless retained within the matching coarse bucket,WHAT 32is a toggle/motion keepalive rather than an authoritative switch state (WHAT 0/1), ZigBee calibrated shutter positioning (WHO 2 DIM 11) omits SCS#001priority (*#2*<WHERE>#9*#11*<LEVEL>##), and wired-SCS features (WHO 14actuator locks,sync_timeclock writes,DIM 2/DIM 6, flash,DIM 5/7) are unsupported on3578.2.394 sonline echo,10.85 sjoin lag), non-blockingsweep_bus, & live UI device deletion: Unplugged unicast commands return local UART*#*1##in20 mswith no RF echo, whereas healthy online Supervisor echoes can take2.394 s; additionally, deleting a ZigBee or SCS device in the Home Assistant Device Registry left cached runtime discovery/inventory state that prevented Sweep Bus from re-discovering the device without reloading the integration, and synchronousmyhome.sweep_buscalls risked exceeding WebSocket timeouts during35 sZigBee scans.[TX]/[RX]) without suppressing< 1 sserial signaling frames (*#*1##/*#*0##/*#*6##) in the Lovelace Bus Monitor card, empty-WHEREcoordinatorDIM 16needed isolation from device/SCS identity frames, and 8-octet EUI-64 + 32-bit ZigBee<ADDR>+/dev/serial/by-path/scrubbing needed uniform coverage across logs,BusMonitor,diagnostics,services.py/websocket.py,trace_recorder, andanonymize_plant_fixture.py.Ref #233 (kept open while
@mvallavalidates2.1.0b3on physical hardware).What is the solution
Rebase onto
master(v2.0.2@558b674c3), Packaging & PairedOWNd==2.1.0b3Dependency (custom_components/myhome/manifest.json,custom_components/myhome/const.py,pyproject.toml,.github/release-notes/2.1.0b3.md):23linear commits,0merge commits) ontomaster(v2.0.2@558b674c3), paired with companion PR OpenWebNet-HA/OWNd#183 (2.1.0b3@ff710d915), preserving allv2.0.2hardening (#1055–#1070, including#1062bind_entity_lifecyclerename re-attachment with_unsub_by_unique_idcleanup,#1065@require_adminWS gates and subentry-delete reload, and#1068WHO=1light_lux:/light_motion:router isolation with ZigBee#9address.whererouting)."after_dependencies": [..., "usb"]and"loggers": ["OWNd"]while intentionally keeping generic Silicon LabsCP210210c4:ea60out ofmanifest.json["usb"]hotplug auto-discovery so ZHA/Z-Wave/ESPHome sticks never trigger false discovery prompts.3578(WHO 14startup/reconnect resync andCONF_REAPPLY_ACTUATOR_LOCKS,sync_timeclock writes,DIM 2/DIM 6,FLASH, and ZigBee broadcast addresses underlight:viaGeneral(allow_zigbee=False)).Context-Gated ZigBee
#9Core Addressing & Coordinator Identity Isolation (custom_components/myhome/where_grammar.py,custom_components/myhome/discovery.py,custom_components/myhome/identity.py,custom_components/myhome/validate.py,custom_components/myhome/actuator_lock.py,custom_components/myhome/device_health.py):parse_zigbee_where,parse_zigbee_group_where,is_zigbee_where, andeffective_message_where(..., address_family=...)preserving#9/0#<UNIT>#9/#<G>#9on contextlessWHO 1/2/13commands whenaddress_family == "zigbee"while maintaining 100% TCP/SCS wire-frame equivalence (*4*1*012#9##,*1*1*#9##,11#4#09,100#9)._sync_serial_transport_firmwareand isolates empty-WHEREcoordinatorDIM 16updates from device frames and wired SCSDIM 15identity frames.Shared Serial Runtime,
*#*6##BUSY +≤ 1/sRF Pacing, Wire Debug Logging, &ZigbeeInventoryManager(custom_components/myhome/gateway_serial.py,custom_components/myhome/zigbee_inventory.py,custom_components/myhome/gateway.py,custom_components/myhome/gateway_sessions.py):SharedSerialRuntimeshares oneAsyncSerialTransport(auto_restore_supervisor=False) across event/command adapters with zero-reprobe preflight handoff, reconnect-safe refcounting (hold_when_reconnecting=True),*#*6##radio BUSY retry support (busy_retry=True500 ms+0.5 sinventory retry without falseUnavailable),≤ 1/sRF broadcast pacing (_pace_rf_broadcastacross*13*66*##and*13*65*##), and hardware-serial-scrubbedlog_idwire[TX]/[RX]debug logging.ZigbeeInventoryManagerrestores*13*66*##Supervisor mode immediately after*13*65*##+DIM 67(before per-indexDIM 66queries so Supervisor stays active across offline timeouts) as well as on empty-WHERE*13*22*##/*13*33*##gateway indications, mid-scanWHAT 33joins, and power-on recoveries; usesPRODUCT_INFO_TIMEOUT = 35 swith<ADDR>verification and direct*#13*<ADDR>00#9*66##fallback on index shifts; passively enriches cold nodes onDIM 66while guarding local-DBDIM 73replies; polls all non-00multi-gang units beforemark_unreachable; marks nodes offline onWHO=13leave (WHAT 34); and prunes battery-only controls (257, 266, 274, 512).UI Device Deletion, Non-Blocking
sweep_bus, & RuntimeDIM 66Entity Recreation (custom_components/myhome/__init__.py,custom_components/myhome/discovery.py,custom_components/myhome/zigbee_inventory.py,custom_components/myhome/services.py,custom_components/myhome/button.py,custom_components/myhome/frontend/myhome-bus-card.js):EVENT_DEVICE_REGISTRY_UPDATED(action="remove") by purging runtimeKnownDevices,EntityRoutersubscriptions (_registered_unique_idsprotected against concurrent creation eviction and synchronized across#1062bind_entity_lifecyclere-attachments),DeviceHealthentries, andZigbeeInventoryManagercached units + pending queues (forget_product,_CURRENT_OP_EPOCH/op_epoch-stamped serialDIM 66replies), allowing a non-blocking Sweep Bus (myhome.sweep_buswitheager_start=True, unload cleanup, and Bus Monitorgatewayforwarding) or live bus frame to re-discover deleted devices immediately without reload.myhome_reconfigure_{mac}onPlatformDiscoverywhenDIM 66upgrades a cold-cached node's device type at runtime so platform entities recreate immediately.ZigBee Coarse Dimmer
%Retention, Per-Unit4.5 sWatchdog, AuthoritativeWHAT 0/1vsWHAT 32, &WHO 2 DIM 11(custom_components/myhome/light.py,custom_components/myhome/light_group.py,custom_components/myhome/binary_sensor.py,custom_components/myhome/sensor.py,custom_components/myhome/switch.py,custom_components/myhome/cover.py,custom_components/myhome/cover_scope.py):DEV_ID 258, 263, 265) viaWHAT 0 / 2..10(1->1%, 2->5%, ..., 10->100%), polls via*#1*WHERE#9##(retaining_zigbee_awaiting_status_untilacross queued polls, neverDIM 1orSoftwareFadeEngine), debounces physical*1*1*WHERE#9##taps (900 ms), and retains exact Home Assistant commanded percentages (e.g.32%stays32%) and0..255brightness values across same-bucket echoes, status polls, HA restarts,OFF -> turn_on(), and cross-bucket slider drags.<ADDR><UNIT>#9)4.5 smissing-echo watchdog on contextless unicastswitch_on/switch_off/ light / shutter commands (*#13**66*<INDEX>##check →Unavailableon offline NACK, instantt = 0 srecovery on power-on state frames).WHAT 0/WHAT 1(removing falseWHAT 32toggle inversion) while routingWHAT 32as motion keepalive on ZigBeeMyHOMEMotionSensor(259, 268, 269, 270, without fabricated"Sensitivity"entities orDIM 5/7polls), preserves ZigBee#9routing under#1068'slight_lux:/light_motion:router namespaces, emits ZigBee calibrated shutter writes (WHO 2 DIM 11) without#001priority (*#2*<WHERE>#9*#11*<LEVEL>##), and supportsfw <= 1.2.0WHAT 1 <-> 2shutter translation,0#00#9/0#<UNIT>#9broadcast cover scope, and(Unit N)multi-unit shutter calibration buttons.Serial Config/Options Flow,
BusMonitorCard, Privacy Redaction Parity, &en/nl/fr/itTranslations (custom_components/myhome/config_flow.py,custom_components/myhome/config_flow_options.py,custom_components/myhome/bus_monitor.py,custom_components/myhome/frame_safety.py,custom_components/myhome/websocket.py,custom_components/myhome/diagnostics.py,custom_components/myhome/trace_recorder.py,scripts/anonymize_plant_fixture.py,custom_components/myhome/translations/*.json):SelectSelector(custom_value=True)with POSIXflockBlockingIOError/EAGAIN/EWOULDBLOCK→port_busy), serial options hiding/popping unsupportedCONF_TRANSITION_MODE&CONF_REAPPLY_ACTUATOR_LOCKS, serialBusMonitor(dedup_window=0.0)+ Lovelace card skipping< 1.0 sduplicate suppression (connection_type === "serial",CARD_VERSION = "2.1.0b3"), admin-gated WScheck_framewith OUI redaction support, multi-frame/unparsed-raw/EUI-64//dev/serial/by-path//32-bit<ADDR>redaction parity across all surfaces, and 100%en,nl,fr, andittranslation parity across all20services (includingstart_bus_recording/stop_bus_recording).State Diagram
stateDiagram-v2 [*] --> CachedBoot : Load .storage ZigBee inventory (0 RF frames) CachedBoot --> MeshScan : Background scan or non-blocking myhome.sweep_bus state MeshScan { [*] --> RequestCount : tx *13*65*## -> rx DIM 67 (busy_retry on *#*6##, <=1/s RF pace) RequestCount --> RestoreSupervisor : tx *13*66*## immediately (bounded retry on NACK/BUSY) RestoreSupervisor --> QueryIndex : tx *#13**66*<idx>## per slot (35s timeout, yields to user TX) QueryIndex --> DrainQueuedJoins : Drain mid-scan WHAT 33 / passive DIM 66 + Supervisor restore } MeshScan --> Online : Reachable units registered (DIM 66 upgrades recreate entities) Online --> PendingEcho : Unicast light/switch/cover TX (per-unit <ADDR><UNIT>#9 4.5s watchdog) PendingEcho --> RetainedBucket : rx echo within TTL -> retain exact dimmer % (e.g. 32% in WHAT 5) PendingEcho --> VerifyReachability : 4.5s watchdog timeout -> poll non-00 units / *#13**66*<idx>## VerifyReachability --> Unavailable : DIM 66 NACK (with direct <ADDR>00#9 fallback) or WHO=13 WHAT 34 Unavailable --> Online : Power-on state frame (t=0s) or WHAT 33 join -> *13*66*## Online --> PurgedForRediscovery : HA Device Registry delete -> op_epoch forget_product + router purge PurgedForRediscovery --> MeshScan : Sweep Bus / live frame re-creates Unit 1 + Unit 2 without reloadHardware Verification
2.1.0b1, physicalLegrand 3578fw 1.2.3on HA2026.11.1/serialx 1.15.1via WSL2 USB/IP by@mvallain#233):serialxenumeration (10c4:ea60CP2102), 4-step ZigBee handshake, 11-product*13*65*##scan (12.92 s),WHO 1status polling (confirming no trailing*#*1##ACK onfw 1.2.3), live RX/TX switching, Bus Monitor (context: "zigbee"), 2-unitDIM 66timing (+32.5 ms),DIM 1NACK (16.8 ms), and floating 503-box unplug/re-plug wire timings (#7088211437).2.1.0b2→2.1.0b3): Addressed every finding from@mvalla's2.1.0b2hardware report plus full protocol/runtime audit — pre-framing[TX]/[RX]wire debug logging via UI toggle, serial Bus Monitor< 1 ssignaling retention, coarse-bucket dimmer%retention (32%stays32%),_op_epoch-guarded UI device deletion → immediate Sweep Bus re-discovery without reload, immediate*13*66*##Supervisor restore +≤ 1/sRF broadcast pacing + per-unit4.5 swatchdog across switch/light/shutter commands, authoritative switchWHAT 0/1vsWHAT 32motion keepalive,WHO 2 DIM 11without#001, and3578WHO 14/sync_timegating; ready for@mvallafinal pass on#233.How is it tested
tests/test_zigbee_where_grammar.py:<ADDR><UNIT>#9,0#00#9,0#<UNIT>#9,0#9,#<G>#9, and contextlessWHO 1/2/13effective_message_where(..., address_family="zigbee")preservation alongside TCP/SCS non-regression (*4*1*012#9##,*1*1*#9##,11#4#09,100#9).tests/test_gateway_serial.py&tests/test_config_flow_serial.py:SharedSerialRuntimereconnect-safe refcounting (hold_when_reconnecting=True),*#*6##radio BUSY retries, preflight handoff, coordinator firmware sync & empty-WHEREDIM 16/DIM 15isolation,WHO 14startup/reconnect skip on ZigBee,log_idwire debug logging, serial options hidingCONF_TRANSITION_MODE&CONF_REAPPLY_ACTUATOR_LOCKS, POSIXflockport_busymapping, and EUI-64 uniqueness.tests/test_zigbee_inventory.py&tests/test_device_delete_rediscovery.py:*13*66*##Supervisor restore across scans, empty-WHERE*13*22/33*##, mid-scanWHAT 33joins, and power-on recoveries,≤ 1/sRF broadcast pacing,35 sDIM 66timeout with<ADDR>verification + direct*#13*<ADDR>00#9*66##fallback, cold-node passiveDIM 66enrichment & runtime entity recreation (myhome_reconfigure_{mac}),DIM 73local-DB guard, per-unit<ADDR><UNIT>#9missing-echo watchdog,WHO=13leave (WHAT 34) reachability, battery-control pruning (257, 266, 274, 512), andop_epoch-guarded live re-discovery after UI Device Registry deletion without reload.tests/test_zigbee_platforms.py,tests/test_zigbee_platforms_audit.py,tests/test_zigbee_dimmer_retention.py,tests/test_who14_cover_scope.py,tests/test_websocket.py, &tests/frontend/bus_card.test.mjs/tests/frontend/bus_card_xss.test.mjs:WHAT 2..10dimmer curve (1/5/10..100%), same-bucket%and raw1/255#G#9group brightness retention across echoes/polls/restores/rapid slider changes, echo-TTL expiry, NACK/cancel rollback,900 msphysical tap debounce, authoritative switchWHAT 0/1vsWHAT 32motion keepalive, ZigBee WHO=1light_lux:/light_motion:router isolation,WHO 2 DIM 11without#001(*#2*<WHERE>#9*#11*<LEVEL>##),fw <= 1.2.0shutter translation,0#00#9/0#<UNIT>#9broadcast cover scope,3578WHO 14/sync_time/DIM 2/DIM 6/FLASHgating, and serial Bus Monitor< 1 sduplicate-suppression bypass (53 passedacrossbus_card.test.mjs+bus_card_xss.test.mjs).tests/test_zigbee_diagnostics_bus.py,tests/test_fixture_privacy.py,tests/test_golden_conformance.py, &tests/test_trace_golden_shape_coverage.py:/dev/serial/by-path//32-bit<ADDR>redaction parity acrossBusMonitor,diagnostics,services.py/websocket.py,trace_recorder, andanonymize_plant_fixture.py, plus14context: "zigbee"Golden Corpus fixtures (who99_openzigbee.yaml) and hermetic trace-shape coverage gates.3.14.7, branchfeat/233-openzigbee-serial@6691aec41):pytest:9,819 passed, 0 failed, 0 errors(5 snapshots passed),36,882 / 36,882 = 100.0%statement coverage across all 79 modules incustom_components/myhomeruff check custom_components tests scripts tools:All checks passed!scripts/typing_ratchet.py:mypy --strict: 0 error(s) in 0 module(s); baseline 0scripts/verify_ha_standards.py:54/54Platinum rules (20services,en/fr/it/nl100% parity,OWNd==2.1.0b3pin)scripts/sync_documentation.py --check:SUCCESStools/golden/validate_corpus.py --check&scripts/sync_golden_corpus.py --check:22files,499golden frames (MyHOME=499 >= OWNd=466,33staged MyHOME-only fixtures,1,190 passed)tools/golden/check_trace_shape_coverage.py:0new uncovered shapesscripts/anonymize_plant_fixture.py --check tests:694files checked,0with personal datanode --test tests/frontend/bus_card.test.mjs tests/frontend/bus_card_xss.test.mjs:53 passed, 0 failedscripts/run_ownd_smoke.py --skip-install --target pinned:5/5gates PASSWhere are the traces
Legrand 3578(fw 1.2.3) hardware captures in #233 comment #7084834900 and #7088211437 (11products:2561-gang & 2-gang switches,258dimmer,6offline/floating 503-box nodes).tests/golden/fixtures/who99_openzigbee.yaml(14context: "zigbee"golden frames synced 1:1 withOWNd) andtests/golden/corpus.json(499frames total,0modifications to existing TCP/SCS records).What does the Firmware Oracle / Encyclopedia say
WHO = 1, 2, 13/ Machine KB):openwebnet4j(WhereZigBee,GatewayMgmt,OpenDeviceType,USBConnector, EPL-2.0), Encyclopedia Machine KB claimsownkb:claim:c000652,c000664(≤ 1/sRF broadcast pacing),c000671,c000672(*#*6##500 msBUSY backoff),c000674,c000675/c002004(WHO 14unsupported on3578),c000691,c001462,c001467(FLASHunsupported),c001471,c001475..c001478(WHAT 32toggle/motion keepalive vsWHAT 0/1),c001483,c001487(DIM 2/DIM 6unsupported),c001821,c001823,c001825,c001829,c001851(sync_timeunsupported),c001873,c001953/c001954(>= 30 sDIM 66offline timeout),c002682..c002685(WHO 2 DIM 11without#001priority vs SCSc002612),ownkb:record:r000288, and liveLegrand 3578 fw 1.2.3hardware captures (#233).3578/088328image is emulated inown-firmware-oracle(no Legrand/BTicino firmware image was published and the Ember bootloader is write-only;L4686SDKis wired 2-wire SCS over USB, not ZigBee); all18emulated TCP gateway targets (742oracle inputs) remain validated viatools/golden/check_trace_shape_coverage.py,scripts/run_ownd_smoke.py, andtests/test_firmware_oracle_conformance.py.Checklist
What is the problem,What is the solution,State Diagram,Hardware Verification,How is it tested,Where are the traces,What does the Firmware Oracle / Encyclopedia say,Checklist).Legrand 3578 fw 1.2.3in#233),openwebnet4j, and Encyclopedia Machine KB claims rather than guessed.handle_event()and do not manually subscribe viaasync_dispatcher_connect.pytest,ruff,scripts/verify_ha_standards.py, andscripts/sync_documentation.py --checkpass.