Improve relative dimming decode

This commit is contained in:
2026-02-15 21:51:50 +01:00
parent 60b436f79f
commit 1eb283112c
5 changed files with 34 additions and 6 deletions

View File

@@ -47,7 +47,8 @@ Completed:
- Relative color temperature steps (DPT 3.007) added for lights. - Relative color temperature steps (DPT 3.007) added for lights.
- Relative color temperature control wired into light schema, UI order adjusted, and KNX color temperature types aligned. - Relative color temperature control wired into light schema, UI order adjusted, and KNX color temperature types aligned.
- Color temperature service calls now use mireds for better compatibility. - Color temperature service calls now use mireds for better compatibility.
- Project version set to 0.0.29 and `CHANGELOG.md` maintained. - Relative dimming/color temperature decoding improved for control/stepcode payloads.
- Project version set to 0.0.30 and `CHANGELOG.md` maintained.
Files created: Files created:
- `custom_components/ha_knx_bridge/__init__.py` - `custom_components/ha_knx_bridge/__init__.py`

View File

@@ -1,5 +1,8 @@
# Changelog # Changelog
## 0.0.30 - 2026-02-15
- Improve relative dimming/color temperature decoding for control/stepcode payloads.
## 0.0.29 - 2026-02-15 ## 0.0.29 - 2026-02-15
- Use mired-based HA color temperature service calls for better device compatibility. - Use mired-based HA color temperature service calls for better device compatibility.

View File

@@ -74,7 +74,7 @@ Only state addresses expose an `invert outgoing` toggle to flip KNX payloads.
Notes: Notes:
- For XY color, the bridge sends the brightness as the Y (luminance) component. - For XY color, the bridge sends the brightness as the Y (luminance) component.
- Relative dimming (DPT 3.007) maps KNX step values to small `brightness_step_pct` changes in Home Assistant. - Relative dimming (DPT 3.007) maps KNX step values (control/stepcode) to small `brightness_step_pct` changes in Home Assistant.
- For relative dimming, the bridge repeats steps until a KNX stop telegram (0 or 8) is received. - For relative dimming, the bridge repeats steps until a KNX stop telegram (0 or 8) is received.
- Relative color temperature (DPT 3.007) adjusts Kelvin in the same start/stop pattern. - Relative color temperature (DPT 3.007) adjusts Kelvin in the same start/stop pattern.
- Color temperature mode must match the KNX telegram DPT: `relative` for 5.001, `absolute` for 7.600 (2-byte unsigned), `absolute_float` for DPT 9 (2-byte float). The bridge sends HA color temperature using `color_temp` (mireds) for maximum compatibility. - Color temperature mode must match the KNX telegram DPT: `relative` for 5.001, `absolute` for 7.600 (2-byte unsigned), `absolute_float` for DPT 9 (2-byte float). The bridge sends HA color temperature using `color_temp` (mireds) for maximum compatibility.
@@ -112,5 +112,5 @@ Notes:
- Advanced DPT mapping options and inversion settings. - Advanced DPT mapping options and inversion settings.
## Versioning and Releases ## Versioning and Releases
- Current version: 0.0.29 - Current version: 0.0.30
- `CHANGELOG.md` lists versions with the newest entries at the top. - `CHANGELOG.md` lists versions with the newest entries at the top.

View File

@@ -1172,7 +1172,7 @@ class BridgeManager:
return return
if action == "relative_dimming": if action == "relative_dimming":
value = _extract_event_value(event) value = _extract_dimming_value(event)
if value is None: if value is None:
return return
if value in (0, 8): if value in (0, 8):
@@ -1188,7 +1188,7 @@ class BridgeManager:
return return
if action == "relative_color_temperature": if action == "relative_color_temperature":
value = _extract_event_value(event) value = _extract_dimming_value(event)
if value is None: if value is None:
return return
if value in (0, 8): if value in (0, 8):
@@ -1511,6 +1511,30 @@ def _extract_event_value(event: Event) -> int | None:
return None return None
def _extract_dimming_value(event: Event) -> int | None:
if "value" in event.data:
value = event.data["value"]
if isinstance(value, dict):
control = value.get("control")
step = value.get("stepcode", value.get("step_code"))
if control is not None and step is not None:
try:
control_bit = 1 if int(control) else 0
step_code = int(step) & 0x07
return (control_bit << 3) | step_code
except (TypeError, ValueError):
pass
data = event.data.get("data")
if isinstance(data, (list, tuple)) and len(data) >= 2:
try:
control_bit = 1 if int(data[0]) else 0
step_code = int(data[1]) & 0x07
return (control_bit << 3) | step_code
except (TypeError, ValueError):
return None
return _extract_event_value(event)
def _clean_address(address: Any) -> str | None: def _clean_address(address: Any) -> str | None:
if not address: if not address:
return None return None

View File

@@ -1,7 +1,7 @@
{ {
"domain": "ha_knx_bridge", "domain": "ha_knx_bridge",
"name": "HA KNX Bridge", "name": "HA KNX Bridge",
"version": "0.0.29", "version": "0.0.30",
"config_flow": true, "config_flow": true,
"documentation": "https://github.com/bahmcloud/HA-KNX-Bridge", "documentation": "https://github.com/bahmcloud/HA-KNX-Bridge",
"issue_tracker": "https://github.com/bahmcloud/HA-KNX-Bridge/issues", "issue_tracker": "https://github.com/bahmcloud/HA-KNX-Bridge/issues",