1 Commits

Author SHA1 Message Date
b59455909c Fix port toggle updates and device layout 2026-02-13 21:28:10 +01:00
4 changed files with 12 additions and 17 deletions

View File

@@ -1,5 +1,9 @@
# Changelog # 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 ## 0.0.18 - 2026-02-13
- Add port devices with enable toggles and an edit-port flow. - Add port devices with enable toggles and an edit-port flow.
- Provide locale fallback translations for all Home Assistant languages. - Provide locale fallback translations for all Home Assistant languages.

View File

@@ -68,6 +68,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.18 - Current version: 0.0.19
- `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

@@ -1,7 +1,7 @@
{ {
"domain": "ha_knx_bridge", "domain": "ha_knx_bridge",
"name": "HA KNX Bridge", "name": "HA KNX Bridge",
"version": "0.0.18", "version": "0.0.19",
"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",

View File

@@ -7,7 +7,6 @@ from homeassistant.config_entries import ConfigEntry
from homeassistant.core import HomeAssistant from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity import DeviceInfo from homeassistant.helpers.entity import DeviceInfo
from homeassistant.components.switch import SwitchEntity from homeassistant.components.switch import SwitchEntity
from homeassistant.helpers import device_registry as dr
from .const import CONF_PORTS, CONF_PORT_ENABLED, DOMAIN from .const import CONF_PORTS, CONF_PORT_ENABLED, DOMAIN
from .bridge import iter_ports from .bridge import iter_ports
@@ -23,14 +22,6 @@ class PortDescriptor:
async def async_setup_entry( async def async_setup_entry(
hass: HomeAssistant, entry: ConfigEntry, async_add_entities hass: HomeAssistant, entry: ConfigEntry, async_add_entities
) -> None: ) -> 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] = [] entities: list[SwitchEntity] = []
for port in iter_ports(entry): for port in iter_ports(entry):
entities.append( entities.append(
@@ -56,11 +47,10 @@ class PortEnabledSwitch(SwitchEntity):
@property @property
def device_info(self) -> DeviceInfo: def device_info(self) -> DeviceInfo:
return DeviceInfo( return DeviceInfo(
identifiers={(DOMAIN, self._port_id)}, identifiers={(DOMAIN, self._entry.entry_id)},
name=f"{self._title} Port", name="HA KNX Bridge",
manufacturer="HA KNX Bridge", manufacturer="HA KNX Bridge",
model=self._port_type, model="Integration",
via_device=(DOMAIN, self._entry.entry_id),
) )
@property @property
@@ -79,7 +69,8 @@ class PortEnabledSwitch(SwitchEntity):
async def _async_set_enabled(self, enabled: bool) -> None: async def _async_set_enabled(self, enabled: bool) -> None:
overrides = dict(self._entry.options.get(CONF_PORT_ENABLED, {})) overrides = dict(self._entry.options.get(CONF_PORT_ENABLED, {}))
overrides[self._port_id] = enabled overrides[self._port_id] = enabled
self._entry.async_update_options( self.hass.config_entries.async_update_entry(
{**self._entry.options, CONF_PORT_ENABLED: overrides} self._entry,
options={**self._entry.options, CONF_PORT_ENABLED: overrides},
) )
await self.hass.config_entries.async_reload(self._entry.entry_id) await self.hass.config_entries.async_reload(self._entry.entry_id)