-
Notifications
You must be signed in to change notification settings - Fork 193
Description
The quirks implementation can cause the real signature for a device to get overwritten in the database. If this happens the quirk will not match again after a restart because the "replacement" signature is stored in the database now and not the original signature.
I have seen 2 different things cause this:
- forcing a device to rejoin that hasn't actually been removed from the network
- a device rejoining on its own with a different nwk value
def handle_join(self, nwk, ieee, parent_nwk): LOGGER.info("Device 0x%04x (%s) joined the network", nwk, ieee) if ieee in self.devices: dev = self.get_device(ieee) if dev.nwk != nwk: LOGGER.debug("Device %s changed id (0x%04x => 0x%04x)", ieee, dev.nwk, nwk) dev.nwk = nwk elif dev.initializing or dev.status == zigpy.device.Status.ENDPOINTS_INIT: LOGGER.debug("Skip initialization for existing device %s", ieee) return else: dev = self.add_device(ieee, nwk) self.listener_event('device_joined', dev) dev.schedule_initialize()
both paths cause dev.schedule_initialize()
to get called. This results in raw_device_initialized
being fired again after the "initial join". This is after quirks have been matched (which happened either at zigpy startup for an existing device or when the device joined the first time for a new device) and because of that the modified device is what exists in memory. This causes the replacement signature to overwrite the original signature in the database. If the signature deviates from the real signature in any way, all future quirks matching for the device will fail.