mirror of
https://github.com/bahmcloud/HA-KNX-Bridge.git
synced 2026-04-06 22:41:14 +00:00
Compare commits
5 Commits
v0.0.9
...
6ce60029a1
| Author | SHA1 | Date | |
|---|---|---|---|
| 6ce60029a1 | |||
| 22afc5addf | |||
| 0fa390fd7f | |||
| 4660344a89 | |||
| de0146ccae |
19
CHANGELOG.md
19
CHANGELOG.md
@@ -1,5 +1,24 @@
|
||||
# Changelog
|
||||
|
||||
## 0.0.15 - 2026-02-13
|
||||
- Remove unsupported `payload_length` field from KNX send calls.
|
||||
|
||||
## 0.0.14 - 2026-02-13
|
||||
- Improve KNX event decoding for cover commands and address the up/down mapping.
|
||||
|
||||
## 0.0.13 - 2026-02-13
|
||||
- Clamp percent payloads to avoid invalid KNX DPT 5.001 values.
|
||||
|
||||
## 0.0.12 - 2026-02-13
|
||||
- Fix KNX event listener setup for HA versions without async_track_event helper.
|
||||
|
||||
## 0.0.11 - 2026-02-13
|
||||
- Move translations into the integration folder so UI labels render.
|
||||
- Downgrade missing subentry support log to debug.
|
||||
|
||||
## 0.0.10 - 2026-02-13
|
||||
- Add translations for options flow menu labels.
|
||||
|
||||
## 0.0.9 - 2026-02-13
|
||||
- Add options flow fallback to add/remove ports when subentries are unavailable.
|
||||
|
||||
|
||||
@@ -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.9
|
||||
- Current version: 0.0.15
|
||||
- `CHANGELOG.md` lists versions with the newest entries at the top.
|
||||
- Release creation is manual and only done when explicitly requested.
|
||||
|
||||
@@ -12,6 +12,7 @@ from homeassistant.helpers import event as event_helper
|
||||
from .const import (
|
||||
CONF_ANGLE_ADDRESS,
|
||||
CONF_ANGLE_STATE_ADDRESS,
|
||||
ADDRESS_EVENT_TYPE,
|
||||
ADDRESS_VALUE_TYPE,
|
||||
CONF_COMMAND_ADDRESS,
|
||||
CONF_INVERT_INCOMING,
|
||||
@@ -329,9 +330,14 @@ class BridgeManager:
|
||||
)
|
||||
|
||||
if self._address_handlers:
|
||||
self._knx_event_unsub = event_helper.async_track_event(
|
||||
self.hass, "knx_event", self._handle_knx_event
|
||||
)
|
||||
if hasattr(event_helper, "async_track_event"):
|
||||
self._knx_event_unsub = event_helper.async_track_event(
|
||||
self.hass, "knx_event", self._handle_knx_event
|
||||
)
|
||||
else:
|
||||
self._knx_event_unsub = self.hass.bus.async_listen(
|
||||
"knx_event", self._handle_knx_event
|
||||
)
|
||||
|
||||
await self._register_knx_events()
|
||||
|
||||
@@ -351,10 +357,11 @@ class BridgeManager:
|
||||
port, action, event
|
||||
)
|
||||
value_type = _get_value_type(address_key)
|
||||
event_type = _get_event_type(address_key)
|
||||
self._remember_address_options(
|
||||
address, value_type, invert_incoming, invert_outgoing
|
||||
)
|
||||
self._registered_addresses.append((address, value_type))
|
||||
self._registered_addresses.append((address, event_type))
|
||||
|
||||
def _register_knx_switch_address(
|
||||
self,
|
||||
@@ -374,7 +381,7 @@ class BridgeManager:
|
||||
invert_incoming,
|
||||
invert_outgoing,
|
||||
)
|
||||
self._registered_addresses.append((address, None))
|
||||
self._registered_addresses.append((address, _get_event_type(CONF_COMMAND_ADDRESS)))
|
||||
|
||||
def _remember_address_options(
|
||||
self,
|
||||
@@ -390,19 +397,19 @@ class BridgeManager:
|
||||
)
|
||||
|
||||
async def _register_knx_events(self) -> None:
|
||||
for address, value_type in self._registered_addresses:
|
||||
for address, event_type in self._registered_addresses:
|
||||
data: dict[str, Any] = {"address": address}
|
||||
if value_type:
|
||||
data["type"] = value_type
|
||||
if event_type:
|
||||
data["type"] = event_type
|
||||
await self.hass.services.async_call(
|
||||
KNX_DOMAIN, "event_register", data, blocking=False
|
||||
)
|
||||
|
||||
async def _unregister_knx_events(self) -> None:
|
||||
for address, value_type in self._registered_addresses:
|
||||
for address, event_type in self._registered_addresses:
|
||||
data: dict[str, Any] = {"address": address, "remove": True}
|
||||
if value_type:
|
||||
data["type"] = value_type
|
||||
if event_type:
|
||||
data["type"] = event_type
|
||||
await self.hass.services.async_call(
|
||||
KNX_DOMAIN, "event_register", data, blocking=False
|
||||
)
|
||||
@@ -471,10 +478,15 @@ class BridgeManager:
|
||||
return _handler
|
||||
|
||||
async def _handle_knx_event(self, event: Event) -> None:
|
||||
if event.data.get("direction") != "Incoming":
|
||||
direction = event.data.get("direction")
|
||||
if direction is not None and not str(direction).lower().startswith("incoming"):
|
||||
return
|
||||
|
||||
destination = event.data.get("destination")
|
||||
destination = (
|
||||
event.data.get("destination")
|
||||
or event.data.get("destination_address")
|
||||
or event.data.get("address")
|
||||
)
|
||||
if not destination:
|
||||
return
|
||||
|
||||
@@ -552,13 +564,14 @@ class BridgeManager:
|
||||
await self.hass.services.async_call(
|
||||
KNX_DOMAIN,
|
||||
"send",
|
||||
{"address": address, "payload": payload, "payload_length": 0},
|
||||
{"address": address, "payload": payload},
|
||||
blocking=False,
|
||||
)
|
||||
|
||||
async def _knx_send_percent(self, address: str | None, value: int) -> None:
|
||||
if not address:
|
||||
return
|
||||
value = _clamp_percent(value)
|
||||
await self.hass.services.async_call(
|
||||
KNX_DOMAIN,
|
||||
"send",
|
||||
@@ -569,15 +582,18 @@ class BridgeManager:
|
||||
|
||||
def _extract_event_value(event: Event) -> int | None:
|
||||
if "value" in event.data:
|
||||
try:
|
||||
return int(event.data["value"])
|
||||
except (TypeError, ValueError):
|
||||
return None
|
||||
value = event.data["value"]
|
||||
mapped = _map_scalar_value(value)
|
||||
if mapped is not None:
|
||||
return mapped
|
||||
data = event.data.get("data")
|
||||
if data is None:
|
||||
return None
|
||||
if isinstance(data, list) and data:
|
||||
data = data[0]
|
||||
mapped = _map_scalar_value(data)
|
||||
if mapped is not None:
|
||||
return mapped
|
||||
try:
|
||||
return int(data) & 1
|
||||
except (TypeError, ValueError):
|
||||
@@ -615,6 +631,7 @@ 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
|
||||
@@ -633,6 +650,36 @@ def _get_value_type(address_key: str) -> str | None:
|
||||
return ADDRESS_VALUE_TYPE.get(address_key)
|
||||
|
||||
|
||||
def _get_event_type(address_key: str) -> str | None:
|
||||
return ADDRESS_EVENT_TYPE.get(address_key)
|
||||
|
||||
|
||||
def _clamp_percent(value: int) -> int:
|
||||
if value < 0:
|
||||
return 0
|
||||
if value > 100:
|
||||
return 100
|
||||
return value
|
||||
|
||||
|
||||
def _map_scalar_value(value: Any) -> int | None:
|
||||
if isinstance(value, bool):
|
||||
return 1 if value else 0
|
||||
if isinstance(value, (int, float)):
|
||||
return int(value)
|
||||
if isinstance(value, str):
|
||||
text = value.strip().lower()
|
||||
if text in ("on", "true", "yes", "1", "down", "close", "closed"):
|
||||
return 1
|
||||
if text in ("off", "false", "no", "0", "up", "open", "opened"):
|
||||
return 0
|
||||
try:
|
||||
return int(text)
|
||||
except ValueError:
|
||||
return None
|
||||
return None
|
||||
|
||||
|
||||
def _iter_port_configs(entry: ConfigEntry) -> list[tuple[str, dict[str, Any]]]:
|
||||
ports: list[tuple[str, dict[str, Any]]] = []
|
||||
subentries = getattr(entry, "subentries", [])
|
||||
|
||||
@@ -70,7 +70,7 @@ class HAKnxBridgeConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
|
||||
def async_get_supported_subentry_types(config_entry):
|
||||
subentry_type = _get_subentry_type()
|
||||
if subentry_type is None:
|
||||
_LOGGER.warning(
|
||||
_LOGGER.debug(
|
||||
"Config subentries are not supported in this Home Assistant version"
|
||||
)
|
||||
return {}
|
||||
|
||||
@@ -35,3 +35,12 @@ ADDRESS_VALUE_TYPE: dict[str, str] = {
|
||||
CONF_ANGLE_ADDRESS: "percent",
|
||||
CONF_ANGLE_STATE_ADDRESS: "percent",
|
||||
}
|
||||
|
||||
ADDRESS_EVENT_TYPE: dict[str, str] = {
|
||||
CONF_MOVE_LONG_ADDRESS: "up_down",
|
||||
CONF_MOVE_SHORT_ADDRESS: "step",
|
||||
CONF_POSITION_ADDRESS: "percent",
|
||||
CONF_POSITION_STATE_ADDRESS: "percent",
|
||||
CONF_ANGLE_ADDRESS: "percent",
|
||||
CONF_ANGLE_STATE_ADDRESS: "percent",
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"domain": "ha_knx_bridge",
|
||||
"name": "HA KNX Bridge",
|
||||
"version": "0.0.9",
|
||||
"version": "0.0.15",
|
||||
"config_flow": true,
|
||||
"documentation": "https://github.com/bahmcloud/HA-KNX-Bridge",
|
||||
"issue_tracker": "https://github.com/bahmcloud/HA-KNX-Bridge/issues",
|
||||
|
||||
73
custom_components/ha_knx_bridge/translations/de.json
Normal file
73
custom_components/ha_knx_bridge/translations/de.json
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"options": {
|
||||
"abort": {
|
||||
"no_ports_to_remove": "Es gibt noch keine Ports zum Entfernen."
|
||||
},
|
||||
"step": {
|
||||
"init": {
|
||||
"title": "HA KNX Bridge Optionen",
|
||||
"description": "Ports verwalten, wenn Subentries nicht verfügbar sind.",
|
||||
"menu_options": {
|
||||
"add_binary_sensor": "Binary-Sensor-Port hinzufügen",
|
||||
"add_switch": "Schalter-Port hinzufügen",
|
||||
"add_cover": "Cover-Port hinzufügen",
|
||||
"remove_port": "Port entfernen"
|
||||
}
|
||||
},
|
||||
"add_binary_sensor": {
|
||||
"title": "Binary-Sensor-Port hinzufügen",
|
||||
"data": {
|
||||
"entity_id": "Binary-Sensor-Entity",
|
||||
"state_address": "State-Gruppenadresse (DPT 1)",
|
||||
"state_address_invert_incoming": "Eingehend invertieren",
|
||||
"state_address_invert_outgoing": "Ausgehend invertieren"
|
||||
}
|
||||
},
|
||||
"add_switch": {
|
||||
"title": "Schalter-Port hinzufügen",
|
||||
"data": {
|
||||
"entity_id": "Schalter-Entity",
|
||||
"command_address": "Command-Gruppenadresse (DPT 1)",
|
||||
"command_address_invert_incoming": "Eingehend invertieren",
|
||||
"command_address_invert_outgoing": "Ausgehend invertieren",
|
||||
"state_address": "State-Gruppenadresse (DPT 1)",
|
||||
"state_address_invert_incoming": "Eingehend invertieren",
|
||||
"state_address_invert_outgoing": "Ausgehend invertieren"
|
||||
}
|
||||
},
|
||||
"add_cover": {
|
||||
"title": "Cover-Port hinzufügen",
|
||||
"data": {
|
||||
"entity_id": "Cover-Entity",
|
||||
"move_long_address": "Move long (DPT 1.008 Auf/Ab)",
|
||||
"move_long_address_invert_incoming": "Eingehend invertieren",
|
||||
"move_long_address_invert_outgoing": "Ausgehend invertieren",
|
||||
"move_short_address": "Move short (DPT 1.007 Schritt)",
|
||||
"move_short_address_invert_incoming": "Eingehend invertieren",
|
||||
"move_short_address_invert_outgoing": "Ausgehend invertieren",
|
||||
"stop_address": "Stop (DPT 1)",
|
||||
"stop_address_invert_incoming": "Eingehend invertieren",
|
||||
"stop_address_invert_outgoing": "Ausgehend invertieren",
|
||||
"position_address": "Position setzen (DPT 5.001)",
|
||||
"position_address_invert_incoming": "Eingehend invertieren",
|
||||
"position_address_invert_outgoing": "Ausgehend invertieren",
|
||||
"position_state_address": "Positionsstatus (DPT 5.001)",
|
||||
"position_state_address_invert_incoming": "Eingehend invertieren",
|
||||
"position_state_address_invert_outgoing": "Ausgehend invertieren",
|
||||
"angle_address": "Tilt setzen (DPT 5.001)",
|
||||
"angle_address_invert_incoming": "Eingehend invertieren",
|
||||
"angle_address_invert_outgoing": "Ausgehend invertieren",
|
||||
"angle_state_address": "Tilt-Status (DPT 5.001)",
|
||||
"angle_state_address_invert_incoming": "Eingehend invertieren",
|
||||
"angle_state_address_invert_outgoing": "Ausgehend invertieren"
|
||||
}
|
||||
},
|
||||
"remove_port": {
|
||||
"title": "Port entfernen",
|
||||
"data": {
|
||||
"port_id": "Zu entfernender Port"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
73
custom_components/ha_knx_bridge/translations/en.json
Normal file
73
custom_components/ha_knx_bridge/translations/en.json
Normal file
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"options": {
|
||||
"abort": {
|
||||
"no_ports_to_remove": "There are no ports to remove yet."
|
||||
},
|
||||
"step": {
|
||||
"init": {
|
||||
"title": "HA KNX Bridge Options",
|
||||
"description": "Manage ports when subentries are unavailable.",
|
||||
"menu_options": {
|
||||
"add_binary_sensor": "Add binary sensor port",
|
||||
"add_switch": "Add switch port",
|
||||
"add_cover": "Add cover port",
|
||||
"remove_port": "Remove port"
|
||||
}
|
||||
},
|
||||
"add_binary_sensor": {
|
||||
"title": "Add Binary Sensor Port",
|
||||
"data": {
|
||||
"entity_id": "Binary sensor entity",
|
||||
"state_address": "State group address (DPT 1)",
|
||||
"state_address_invert_incoming": "Invert incoming",
|
||||
"state_address_invert_outgoing": "Invert outgoing"
|
||||
}
|
||||
},
|
||||
"add_switch": {
|
||||
"title": "Add Switch Port",
|
||||
"data": {
|
||||
"entity_id": "Switch entity",
|
||||
"command_address": "Command group address (DPT 1)",
|
||||
"command_address_invert_incoming": "Invert incoming",
|
||||
"command_address_invert_outgoing": "Invert outgoing",
|
||||
"state_address": "State group address (DPT 1)",
|
||||
"state_address_invert_incoming": "Invert incoming",
|
||||
"state_address_invert_outgoing": "Invert outgoing"
|
||||
}
|
||||
},
|
||||
"add_cover": {
|
||||
"title": "Add Cover Port",
|
||||
"data": {
|
||||
"entity_id": "Cover entity",
|
||||
"move_long_address": "Move long (DPT 1.008 Up/Down)",
|
||||
"move_long_address_invert_incoming": "Invert incoming",
|
||||
"move_long_address_invert_outgoing": "Invert outgoing",
|
||||
"move_short_address": "Move short (DPT 1.007 Step)",
|
||||
"move_short_address_invert_incoming": "Invert incoming",
|
||||
"move_short_address_invert_outgoing": "Invert outgoing",
|
||||
"stop_address": "Stop (DPT 1)",
|
||||
"stop_address_invert_incoming": "Invert incoming",
|
||||
"stop_address_invert_outgoing": "Invert outgoing",
|
||||
"position_address": "Set position (DPT 5.001)",
|
||||
"position_address_invert_incoming": "Invert incoming",
|
||||
"position_address_invert_outgoing": "Invert outgoing",
|
||||
"position_state_address": "State position (DPT 5.001)",
|
||||
"position_state_address_invert_incoming": "Invert incoming",
|
||||
"position_state_address_invert_outgoing": "Invert outgoing",
|
||||
"angle_address": "Set tilt (DPT 5.001)",
|
||||
"angle_address_invert_incoming": "Invert incoming",
|
||||
"angle_address_invert_outgoing": "Invert outgoing",
|
||||
"angle_state_address": "State tilt (DPT 5.001)",
|
||||
"angle_state_address_invert_incoming": "Invert incoming",
|
||||
"angle_state_address_invert_outgoing": "Invert outgoing"
|
||||
}
|
||||
},
|
||||
"remove_port": {
|
||||
"title": "Remove Port",
|
||||
"data": {
|
||||
"port_id": "Port to remove"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user