1 Commits

Author SHA1 Message Date
44de824041 Normalize event destination and clamp percent 2026-02-13 20:45:27 +01:00
4 changed files with 20 additions and 14 deletions

View File

@@ -1,5 +1,8 @@
# Changelog # Changelog
## 0.0.16 - 2026-02-13
- Normalize incoming event destinations and clamp percent payloads even without inversion.
## 0.0.15 - 2026-02-13 ## 0.0.15 - 2026-02-13
- Remove unsupported `payload_length` field from KNX send calls. - Remove unsupported `payload_length` field from KNX send calls.

View File

@@ -67,6 +67,6 @@ Each group address has `invert incoming` and `invert outgoing` toggles to flip K
- Advanced DPT mapping options and inversion settings. - Advanced DPT mapping options and inversion settings.
## Versioning and Releases ## Versioning and Releases
- Current version: 0.0.15 - Current version: 0.0.16
- `CHANGELOG.md` lists versions with the newest entries at the top. - `CHANGELOG.md` lists versions with the newest entries at the top.
- Release creation is manual and only done when explicitly requested. - Release creation is manual and only done when explicitly requested.

View File

@@ -482,11 +482,7 @@ class BridgeManager:
if direction is not None and not str(direction).lower().startswith("incoming"): if direction is not None and not str(direction).lower().startswith("incoming"):
return return
destination = ( destination = _event_destination(event)
event.data.get("destination")
or event.data.get("destination_address")
or event.data.get("address")
)
if not destination: if not destination:
return return
@@ -502,9 +498,8 @@ class BridgeManager:
value = _extract_event_value(event) value = _extract_event_value(event)
if value is None: if value is None:
return return
value = _invert_value( destination = _event_destination(event)
value, event.data.get("destination"), self._address_options, "incoming" value = _invert_value(value, destination, self._address_options, "incoming")
)
if action == "move_long": if action == "move_long":
if value == 0: if value == 0:
@@ -530,9 +525,8 @@ class BridgeManager:
value = _extract_event_value(event) value = _extract_event_value(event)
if value is None: if value is None:
return return
value = _invert_value( destination = _event_destination(event)
value, event.data.get("destination"), self._address_options, "incoming" value = _invert_value(value, destination, self._address_options, "incoming")
)
if value == 0: if value == 0:
await self._call_switch_service(port.entity_id, "turn_off") await self._call_switch_service(port.entity_id, "turn_off")
elif value == 1: elif value == 1:
@@ -624,6 +618,8 @@ def _invert_value(
options = address_options.get(address) options = address_options.get(address)
if options is None: if options is None:
return value return value
if options.value_type == "percent":
value = _clamp_percent(value)
if direction == "incoming": if direction == "incoming":
if not options.invert_incoming: if not options.invert_incoming:
return value return value
@@ -631,7 +627,6 @@ def _invert_value(
if not options.invert_outgoing: if not options.invert_outgoing:
return value return value
if options.value_type == "percent": if options.value_type == "percent":
value = _clamp_percent(value)
return 100 - value return 100 - value
if value not in (0, 1): if value not in (0, 1):
return value return value
@@ -680,6 +675,14 @@ def _map_scalar_value(value: Any) -> int | None:
return 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]]]: def _iter_port_configs(entry: ConfigEntry) -> list[tuple[str, dict[str, Any]]]:
ports: list[tuple[str, dict[str, Any]]] = [] ports: list[tuple[str, dict[str, Any]]] = []
subentries = getattr(entry, "subentries", []) subentries = getattr(entry, "subentries", [])

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.15", "version": "0.0.16",
"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",