def __init__(self, filename, rawInput=None): if rawInput is None: testData = readJson(filename) self.testData = testData else: self.testData = rawInput self.accessor = ViCareDeviceAccessor( '[id]', '[serial]', '[deviceid]') self.setPropertyData = []
def __extract_devices(self): for installation in self.installations: for gateway in installation.gateways: for device in gateway.devices: if device.deviceType != "heating": continue # we are not interested in non heating devices accessor = ViCareDeviceAccessor( installation.id, gateway.serial, device.id) service = self.__buildService(accessor, device.roles) logger.info(f"Device found: {device.modelId}") yield PyViCareDeviceConfig(service, device.modelId, device.status)
def __readInstallations(self, data): for installation in data: installation_id = installation["id"] for gateway in installation["gateways"]: gateway_serial = gateway["serial"] for device in gateway["devices"]: if device["deviceType"] != "heating": continue # we are not interested in non heating devices device_id = device["id"] device_model = device["modelId"] status = device["status"] accessor = ViCareDeviceAccessor(installation_id, gateway_serial, device_id) service = self.__buildService(accessor) logger.info(f"Device found: {device_model}") yield PyViCareDeviceConfig(service, device_model, status)
def setUp(self): self.oauth_mock = Mock() accessor = ViCareDeviceAccessor("[id]", "[serial]", "[device]") self.service = ViCareService(self.oauth_mock, accessor)
def setUp(self): self.oauth_mock = Mock() self.oauth_mock.get.return_value = {'data': [{"feature": "someprop"}]} accessor = ViCareDeviceAccessor("[id]", "[serial]", "[device]") self.service = ViCareCachedService(self.oauth_mock, accessor, [], self.CACHE_DURATION)