def list_accessories_and_characteristics(self): """ This retrieves a current set of accessories and characteristics behind this pairing. :return: the accessory data as described in the spec on page 73 and following :raises AccessoryNotFoundError: if the device can not be found via zeroconf """ if not self.session: self.session = IpSession(self.pairing_data) try: response = self.session.get('/accessories') except (AccessoryDisconnectedError, EncryptionError): self.session.close() self.session = None raise tmp = response.read().decode() accessories = json.loads(tmp)['accessories'] for accessory in accessories: for service in accessory['services']: service['type'] = service['type'].upper() try: service['type'] = ServicesTypes.get_uuid(service['type']) except KeyError: pass for characteristic in service['characteristics']: characteristic['type'] = characteristic['type'].upper() try: characteristic['type'] = CharacteristicsTypes.get_uuid(characteristic['type']) except KeyError: pass self.pairing_data['accessories'] = accessories return accessories
def __init__(self): AbstractService.__init__( self, ServicesTypes.get_uuid('public.hap.service.lightbulb'), get_id()) OnCharacteristicMixin.__init__(self, get_id()) BrightnessCharacteristicMixin.__init__(self, get_id()) HueCharacteristicMixin.__init__(self, get_id()) SaturationCharacteristicMixin.__init__(self, get_id())
def __init__(self, device): service = ServiceEntry( ServicesTypes.get_uuid('public.hap.service.pairing'), model_mixin.get_id(), ) super().__init__(device, service) self.characteristics.append(PairingSetupCharacteristicHandler(self)) self.characteristics.append(PairingVerifyCharacteristicHandler(self)) self.characteristics.append(PairingPairingsCharacteristicHandler(self))
def __init__(self, name, manufacturer, model, serialnumber, firmwarerevision): AbstractService.__init__( self, ServicesTypes.get_uuid('public.hap.service.accessory-information'), get_id()) self.characteristics.append(IdentifyCharacteristic(get_id())) self.characteristics.append( ManufacturerCharacteristic(get_id(), manufacturer)) self.characteristics.append(ModelCharacteristic(get_id(), model)) self.characteristics.append(NameCharacteristic(get_id(), name)) self.characteristics.append( SerialNumberCharacteristic(get_id(), serialnumber)) self.characteristics.append( FirmwareRevisionCharacteristic(get_id(), firmwarerevision))
def __init__(self, service_name): """Create a fake service by its short form HAP spec name.""" char_type = ServicesTypes.get_uuid(service_name) super().__init__(char_type, get_id())
def __init__(self, service_name): """Create a fake service by its short form HAP spec name.""" char_type = ServicesTypes.get_uuid(service_name) super().__init__(char_type, get_id())
def __init__(self): AbstractService.__init__( self, ServicesTypes.get_uuid('public.hap.service.fan'), get_id()) OnCharacteristicMixin.__init__(self, get_id())
def test_get_uuid(self): self.assertEqual(ServicesTypes.get_uuid('public.hap.service.doorbell'), '00000121-0000-1000-8000-0026BB765291')