Allow ZHA device creation for the Zigbee coordinator (#31032)
* allow zha device creation for coordinator * don't let coordinator get removed * fix truthy issue in logical device type
This commit is contained in:
parent
bc6603d8d7
commit
41014d73be
3 changed files with 9 additions and 10 deletions
|
@ -906,6 +906,11 @@ def async_load_api(hass):
|
||||||
async def remove(service):
|
async def remove(service):
|
||||||
"""Remove a node from the network."""
|
"""Remove a node from the network."""
|
||||||
ieee = service.data.get(ATTR_IEEE_ADDRESS)
|
ieee = service.data.get(ATTR_IEEE_ADDRESS)
|
||||||
|
zha_gateway = hass.data[DATA_ZHA][DATA_ZHA_GATEWAY]
|
||||||
|
zha_device = zha_gateway.get_device(ieee)
|
||||||
|
if zha_device.is_coordinator:
|
||||||
|
_LOGGER.info("Removing the coordinator (%s) is not allowed", ieee)
|
||||||
|
return
|
||||||
_LOGGER.info("Removing node %s", ieee)
|
_LOGGER.info("Removing node %s", ieee)
|
||||||
await application_controller.remove(ieee)
|
await application_controller.remove(ieee)
|
||||||
|
|
||||||
|
|
|
@ -165,8 +165,10 @@ class ZHADevice(LogMixin):
|
||||||
@property
|
@property
|
||||||
def device_type(self):
|
def device_type(self):
|
||||||
"""Return the logical device type for the device."""
|
"""Return the logical device type for the device."""
|
||||||
device_type = self._zigpy_device.node_desc.logical_type
|
node_descriptor = self._zigpy_device.node_desc
|
||||||
return device_type.name if device_type else UNKNOWN
|
return (
|
||||||
|
node_descriptor.logical_type.name if node_descriptor.is_valid else UNKNOWN
|
||||||
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def power_source(self):
|
def power_source(self):
|
||||||
|
|
|
@ -135,8 +135,6 @@ class ZHAGateway:
|
||||||
await coro
|
await coro
|
||||||
|
|
||||||
for device in self.application_controller.devices.values():
|
for device in self.application_controller.devices.values():
|
||||||
if device.nwk == 0x0000:
|
|
||||||
continue
|
|
||||||
init_tasks.append(
|
init_tasks.append(
|
||||||
init_with_semaphore(self.async_device_restored(device), semaphore)
|
init_with_semaphore(self.async_device_restored(device), semaphore)
|
||||||
)
|
)
|
||||||
|
@ -160,9 +158,6 @@ class ZHAGateway:
|
||||||
|
|
||||||
def raw_device_initialized(self, device):
|
def raw_device_initialized(self, device):
|
||||||
"""Handle a device initialization without quirks loaded."""
|
"""Handle a device initialization without quirks loaded."""
|
||||||
if device.nwk == 0x0000:
|
|
||||||
return
|
|
||||||
|
|
||||||
manuf = device.manufacturer
|
manuf = device.manufacturer
|
||||||
async_dispatcher_send(
|
async_dispatcher_send(
|
||||||
self._hass,
|
self._hass,
|
||||||
|
@ -336,9 +331,6 @@ class ZHAGateway:
|
||||||
|
|
||||||
async def async_device_initialized(self, device):
|
async def async_device_initialized(self, device):
|
||||||
"""Handle device joined and basic information discovered (async)."""
|
"""Handle device joined and basic information discovered (async)."""
|
||||||
if device.nwk == 0x0000:
|
|
||||||
return
|
|
||||||
|
|
||||||
zha_device = self._async_get_or_create_device(device)
|
zha_device = self._async_get_or_create_device(device)
|
||||||
|
|
||||||
_LOGGER.debug(
|
_LOGGER.debug(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue