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:
David F. Mulcahey 2020-01-21 06:07:47 -05:00 committed by GitHub
parent bc6603d8d7
commit 41014d73be
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 10 deletions

View file

@ -906,6 +906,11 @@ def async_load_api(hass):
async def remove(service):
"""Remove a node from the network."""
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)
await application_controller.remove(ieee)

View file

@ -165,8 +165,10 @@ class ZHADevice(LogMixin):
@property
def device_type(self):
"""Return the logical device type for the device."""
device_type = self._zigpy_device.node_desc.logical_type
return device_type.name if device_type else UNKNOWN
node_descriptor = self._zigpy_device.node_desc
return (
node_descriptor.logical_type.name if node_descriptor.is_valid else UNKNOWN
)
@property
def power_source(self):

View file

@ -135,8 +135,6 @@ class ZHAGateway:
await coro
for device in self.application_controller.devices.values():
if device.nwk == 0x0000:
continue
init_tasks.append(
init_with_semaphore(self.async_device_restored(device), semaphore)
)
@ -160,9 +158,6 @@ class ZHAGateway:
def raw_device_initialized(self, device):
"""Handle a device initialization without quirks loaded."""
if device.nwk == 0x0000:
return
manuf = device.manufacturer
async_dispatcher_send(
self._hass,
@ -336,9 +331,6 @@ class ZHAGateway:
async def async_device_initialized(self, device):
"""Handle device joined and basic information discovered (async)."""
if device.nwk == 0x0000:
return
zha_device = self._async_get_or_create_device(device)
_LOGGER.debug(