From b59455909cfdc47cfefb02378174d36f07d5ec0f Mon Sep 17 00:00:00 2001 From: bahmcloud Date: Fri, 13 Feb 2026 21:28:10 +0100 Subject: [PATCH] Fix port toggle updates and device layout --- CHANGELOG.md | 4 ++++ README.md | 2 +- custom_components/ha_knx_bridge/manifest.json | 2 +- custom_components/ha_knx_bridge/switch.py | 21 ++++++------------- 4 files changed, 12 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 94c3d66..293bc02 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 0.0.19 - 2026-02-13 +- Fix port enable switches by updating config entry options properly. +- Show port switches under the main integration device instead of per-port devices. + ## 0.0.18 - 2026-02-13 - Add port devices with enable toggles and an edit-port flow. - Provide locale fallback translations for all Home Assistant languages. diff --git a/README.md b/README.md index e6ab918..c661399 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,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.18 +- Current version: 0.0.19 - `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/manifest.json b/custom_components/ha_knx_bridge/manifest.json index 90264ef..8adab6b 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.18", + "version": "0.0.19", "config_flow": true, "documentation": "https://github.com/bahmcloud/HA-KNX-Bridge", "issue_tracker": "https://github.com/bahmcloud/HA-KNX-Bridge/issues", diff --git a/custom_components/ha_knx_bridge/switch.py b/custom_components/ha_knx_bridge/switch.py index c40a7b7..920655a 100644 --- a/custom_components/ha_knx_bridge/switch.py +++ b/custom_components/ha_knx_bridge/switch.py @@ -7,7 +7,6 @@ from homeassistant.config_entries import ConfigEntry from homeassistant.core import HomeAssistant from homeassistant.helpers.entity import DeviceInfo from homeassistant.components.switch import SwitchEntity -from homeassistant.helpers import device_registry as dr from .const import CONF_PORTS, CONF_PORT_ENABLED, DOMAIN from .bridge import iter_ports @@ -23,14 +22,6 @@ class PortDescriptor: async def async_setup_entry( hass: HomeAssistant, entry: ConfigEntry, async_add_entities ) -> None: - device_registry = dr.async_get(hass) - device_registry.async_get_or_create( - config_entry_id=entry.entry_id, - identifiers={(DOMAIN, entry.entry_id)}, - name="HA KNX Bridge", - manufacturer="HA KNX Bridge", - model="Integration", - ) entities: list[SwitchEntity] = [] for port in iter_ports(entry): entities.append( @@ -56,11 +47,10 @@ class PortEnabledSwitch(SwitchEntity): @property def device_info(self) -> DeviceInfo: return DeviceInfo( - identifiers={(DOMAIN, self._port_id)}, - name=f"{self._title} Port", + identifiers={(DOMAIN, self._entry.entry_id)}, + name="HA KNX Bridge", manufacturer="HA KNX Bridge", - model=self._port_type, - via_device=(DOMAIN, self._entry.entry_id), + model="Integration", ) @property @@ -79,7 +69,8 @@ class PortEnabledSwitch(SwitchEntity): async def _async_set_enabled(self, enabled: bool) -> None: overrides = dict(self._entry.options.get(CONF_PORT_ENABLED, {})) overrides[self._port_id] = enabled - self._entry.async_update_options( - {**self._entry.options, CONF_PORT_ENABLED: overrides} + self.hass.config_entries.async_update_entry( + self._entry, + options={**self._entry.options, CONF_PORT_ENABLED: overrides}, ) await self.hass.config_entries.async_reload(self._entry.entry_id)