diff --git a/CHANGELOG.md b/CHANGELOG.md index e70b5a1..fe75eb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 0.0.16 - 2026-02-13 +- Normalize incoming event destinations and clamp percent payloads even without inversion. + ## 0.0.15 - 2026-02-13 - Remove unsupported `payload_length` field from KNX send calls. diff --git a/README.md b/README.md index f9c8d46..465265a 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,6 @@ Each group address has `invert incoming` and `invert outgoing` toggles to flip K - Advanced DPT mapping options and inversion settings. ## Versioning and Releases -- Current version: 0.0.15 +- Current version: 0.0.16 - `CHANGELOG.md` lists versions with the newest entries at the top. - Release creation is manual and only done when explicitly requested. diff --git a/custom_components/ha_knx_bridge/bridge.py b/custom_components/ha_knx_bridge/bridge.py index 7038548..c61d173 100644 --- a/custom_components/ha_knx_bridge/bridge.py +++ b/custom_components/ha_knx_bridge/bridge.py @@ -482,11 +482,7 @@ class BridgeManager: if direction is not None and not str(direction).lower().startswith("incoming"): return - destination = ( - event.data.get("destination") - or event.data.get("destination_address") - or event.data.get("address") - ) + destination = _event_destination(event) if not destination: return @@ -502,9 +498,8 @@ class BridgeManager: value = _extract_event_value(event) if value is None: return - value = _invert_value( - value, event.data.get("destination"), self._address_options, "incoming" - ) + destination = _event_destination(event) + value = _invert_value(value, destination, self._address_options, "incoming") if action == "move_long": if value == 0: @@ -530,9 +525,8 @@ class BridgeManager: value = _extract_event_value(event) if value is None: return - value = _invert_value( - value, event.data.get("destination"), self._address_options, "incoming" - ) + destination = _event_destination(event) + value = _invert_value(value, destination, self._address_options, "incoming") if value == 0: await self._call_switch_service(port.entity_id, "turn_off") elif value == 1: @@ -624,6 +618,8 @@ def _invert_value( options = address_options.get(address) if options is None: return value + if options.value_type == "percent": + value = _clamp_percent(value) if direction == "incoming": if not options.invert_incoming: return value @@ -631,7 +627,6 @@ def _invert_value( if not options.invert_outgoing: return value if options.value_type == "percent": - value = _clamp_percent(value) return 100 - value if value not in (0, 1): return value @@ -680,6 +675,14 @@ def _map_scalar_value(value: Any) -> int | None: return None +def _event_destination(event: Event) -> str | None: + return ( + event.data.get("destination") + or event.data.get("destination_address") + or event.data.get("address") + ) + + def _iter_port_configs(entry: ConfigEntry) -> list[tuple[str, dict[str, Any]]]: ports: list[tuple[str, dict[str, Any]]] = [] subentries = getattr(entry, "subentries", []) diff --git a/custom_components/ha_knx_bridge/manifest.json b/custom_components/ha_knx_bridge/manifest.json index 4ad629b..75a3a79 100644 --- a/custom_components/ha_knx_bridge/manifest.json +++ b/custom_components/ha_knx_bridge/manifest.json @@ -1,7 +1,7 @@ { "domain": "ha_knx_bridge", "name": "HA KNX Bridge", - "version": "0.0.15", + "version": "0.0.16", "config_flow": true, "documentation": "https://github.com/bahmcloud/HA-KNX-Bridge", "issue_tracker": "https://github.com/bahmcloud/HA-KNX-Bridge/issues",