Exemple #1
0
    def handleDiscovery(self, device: ScanEntry, isNew: bool, isData: bool):
        if not isNew:
            return

        device_name = device.getValueText(ScanEntry.COMPLETE_LOCAL_NAME)

        if not isinstance(device_name,
                          str) or not device_name.startswith("Snooz"):
            return

        advertisement = device.getValue(ScanEntry.MANUFACTURER)

        # unexpected data
        if len(advertisement) < 3:
            return

        if advertisement[:3] == b"\xFF\xFF\x08":
            _LOGGER.warning(
                f"Discovered {device_name} ({device.addr}) but it is not in pairing mode."
            )
            return

        token = b64encode(advertisement[3:]).decode("UTF-8")

        snooz_device = DiscoveredSnooz(device_name, token, device)

        self.devices.append(snooz_device)
Exemple #2
0
 def handleDiscovery(self, dev: ScanEntry, isNewDev: bool, isNewData: bool):
     name = dev.getValue(ScanEntry.COMPLETE_LOCAL_NAME) or ""
     toy_type = TOY_BY_PREFIX.get(name[:3])
     if toy_type:
         self.queue.put_nowait(_ScanItem(dev.addr, toy_type, name))