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 test_autoDetect_RoleHeatpump_asHeatpump(self): self.service.hasRoles = has_roles(["type:heatpump"]) c = PyViCareDeviceConfig(self.service, "Unknown", "Online") device_type = c.asAutoDetectDevice() self.assertEqual("HeatPump", type(device_type).__name__)
def test_autoDetect_RoleBoiler_asGazBoiler(self): self.service.hasRoles = has_roles(["type:boiler"]) c = PyViCareDeviceConfig(self.service, "Unknown", "Online") device_type = c.asAutoDetectDevice() self.assertEqual("GazBoiler", type(device_type).__name__)
def test_autoDetect_VScot_asGazBoiler(self): c = PyViCareDeviceConfig(self.service, "VScotHO1_200", "Online") device_type = c.asAutoDetectDevice() self.assertEqual("GazBoiler", type(device_type).__name__)
def test_autoDetect_Unknown_asGeneric(self): c = PyViCareDeviceConfig(self.service, "myRobot", "Online") device_type = c.asAutoDetectDevice() self.assertEqual("Device", type(device_type).__name__)
def test_autoDetect_Vitodens_asGazBoiler(self): c = PyViCareDeviceConfig( self.service, "E3_Vitodens_200_xxxx/E3_Dictionary", "Online") device_type = c.asAutoDetectDevice() self.assertEqual("GazBoiler", type(device_type).__name__)