mirror of
https://github.com/bahmcloud/HA-KNX-Bridge.git
synced 2026-04-06 16:51:14 +00:00
Fix port toggle updates and device layout
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user