4.0 KiB
4.0 KiB
Architecture
Core Layers
ha_deconz_bridge.color: shared color model and conversionsha_deconz_bridge.lights: typed light definitions and validationha_deconz_bridge.solver_model: compiled light-model and exclusivity combinationsha_deconz_bridge.solver_numeric: shared numeric color-solve helpersha_deconz_bridge.solver: solve orchestration and deterministic elimination policyha_deconz_bridge.translate: controller and virtual-light translation helpers
Runtime Layers
ha_deconz_bridge.backends.base: backend protocolha_deconz_bridge.backends.deconz: deCONZ HTTP and websocket normalizationha_deconz_bridge.automation: remote specs, gesture detection, and automation rule matchingha_deconz_bridge.controller: one physical controller runtimeha_deconz_bridge.group_light: exposed groups that translate commands into member light commandsha_deconz_bridge.groups: group specs, member restrictions, and capability derivationha_deconz_bridge.light: one virtual Home Assistant lightha_deconz_bridge.ha: MQTT discovery, commands, and state publishingha_deconz_bridge.queueing: HA command coalescing and event prioritizationha_deconz_bridge.app: service wiring
Debug Layer
ha_deconz_bridge.debugger.mpl_debuggeris an offline simulator.- It uses the same
Color, solver, and translation code as runtime. - It does not have a separate solver branch.
Solver Shape
- Each exposed virtual light or debugger selection is compiled once into a light model.
- Only exclusivity groups create solver branches; independent control paths may be active together.
solve_light()treats all emitters uniformly in one shared color space.- Semantic labels like
rgbandcolor_tempare used only during policy stages, not in the mixing math itself.
Event Flow
- Home Assistant command arrives over MQTT.
- The command is normalized into a typed HA event.
- The event queue coalesces pending commands for the same virtual light. Sensor events run first, HA commands run before pending light readback events, and deCONZ light readbacks are deduplicated by controller.
- Individual
VirtualLightentities merge the command with their last stable state and ask the solver for controller targets. - Group entities translate the group command into member
VirtualLightcommands. A group member may have a fixed RGB or CT restriction that applies only when that group is controlled. - Each
PhysicalControllerwrites the solver's physical command to deCONZ. HA-driven writes trust a successful HTTP response and keep the accepted logical report state while near-term stale readbacks arrive. VirtualLightand group entities aggregate accepted-or-physical output state and publish it back to Home Assistant.- Unsolicited deCONZ events update hardware truth directly when they are not near-term stale readbacks from a just-written command.
Remote Event Flow
- deCONZ sends a websocket sensor event for a configured remote.
- The raw
buttoneventis normalized into a button and gesture. - Double-press detection is tracked per physical sensor ID.
- Automation rules match the remote's internal
remote_id, button, gesture, and optional time condition. - Actions execute through the same virtual-light command path as Home Assistant.
Shared Controllers
- Runtime owns exactly one
PhysicalControllerobject per physical deCONZ controller ID. - Individual virtual lights reference those shared controller objects. Configured groups reference individual virtual lights, not controllers directly.
ha_deconz_bridge.appmaintains a controller-to-virtual-lights index.- A deCONZ event updates the shared controller once, then every virtual light that includes that controller recomputes and republishes state. Groups containing any changed member recompute after those member updates.
- This allows overlapping exposed entities, such as one individual light and one room/group light, to stay consistent after external physical changes.