class Vitocal200S(unittest.TestCase): def setUp(self): self.service = ViCareServiceMock('response/Vitocal200S.json') self.device = HeatPump(self.service) def test_getDomesticHotWaterConfiguredTemperature(self): self.assertEqual( self.device.getDomesticHotWaterConfiguredTemperature(), 40) def test_getDomesticHotWaterConfiguredTemperature2(self): self.assertEqual( self.device.getDomesticHotWaterConfiguredTemperature2(), 60)
def setup(hass, config): """Create the ViCare component.""" conf = config[DOMAIN] params = {"token_file": hass.config.path(STORAGE_DIR, "vicare_token.save")} if conf.get(CONF_CIRCUIT) is not None: params["circuit"] = conf[CONF_CIRCUIT] heating_type = conf[CONF_HEATING_TYPE] try: if heating_type == HeatingType.gas: vicare_api = GazBoiler(conf[CONF_USERNAME], conf[CONF_PASSWORD], **params) elif heating_type == HeatingType.heatpump: vicare_api = HeatPump(conf[CONF_USERNAME], conf[CONF_PASSWORD], **params) else: vicare_api = Device(conf[CONF_USERNAME], conf[CONF_PASSWORD], **params) except AttributeError: _LOGGER.error( "Failed to create PyViCare API client. Please check your credentials." ) return False hass.data[DOMAIN] = {} hass.data[DOMAIN][VICARE_API] = vicare_api hass.data[DOMAIN][VICARE_NAME] = conf[CONF_NAME] hass.data[DOMAIN][VICARE_HEATING_TYPE] = heating_type for platform in VICARE_PLATFORMS: discovery.load_platform(hass, platform, DOMAIN, {}, config) return True
class Vitodens111W(unittest.TestCase): def setUp(self): self.service = ViCareServiceMock('response_Vitocal200.json', 0) self.heat = HeatPump(None, None, None, 0, 0, self.service) PyViCare.Feature.raise_exception_on_not_supported_device_feature = True def test_getCompressorActive(self): self.assertEqual(self.heat.getCompressorActive(), False) def test_getCompressorHours(self): self.assertAlmostEqual(self.heat.getCompressorHours(), 6801.2) def test_getHeatingRodStatusOverall(self): self.assertEqual(self.heat.getHeatingRodStatusOverall(), False) def test_getHeatingRodStatusLevel1(self): self.assertEqual(self.heat.getHeatingRodStatusLevel1(), False) def test_getReturnTemperature(self): self.assertAlmostEqual(self.heat.getReturnTemperature(), 25.8) def test_getMonthSinceLastService_fails(self): self.assertRaises(PyViCareNotSupportedFeatureError, self.heat.getMonthSinceLastService) def test_getPrograms_fails(self): expected_programs = ['active', 'comfort', 'eco', 'fixed', 'holiday', 'normal', 'reduced', 'standby'] self.assertListEqual(self.heat.getPrograms(), expected_programs) def test_getModes(self): expected_modes = ['standby', 'dhw', 'dhwAndHeatingCooling'] self.assertListEqual(self.heat.getModes(), expected_modes)
def setup(hass, config): """Create the ViCare component.""" conf = config[DOMAIN] params = {"token_file": hass.config.path(STORAGE_DIR, "vicare_token.save")} if conf.get(CONF_CIRCUIT) is not None: params["circuit"] = conf[CONF_CIRCUIT] params["cacheDuration"] = conf.get(CONF_SCAN_INTERVAL) heating_type = conf[CONF_HEATING_TYPE] try: if heating_type == HeatingType.gas: vicare_api = GazBoiler(conf[CONF_USERNAME], conf[CONF_PASSWORD], **params) elif heating_type == HeatingType.heatpump: vicare_api = HeatPump(conf[CONF_USERNAME], conf[CONF_PASSWORD], **params) else: vicare_api = Device(conf[CONF_USERNAME], conf[CONF_PASSWORD], **params) except AttributeError: _LOGGER.error( "Failed to create PyViCare API client. Please check your credentials" ) return False hass.data[DOMAIN] = {} hass.data[DOMAIN]["entities"] = {} hass.data[DOMAIN]["entities"]["climate"] = [] hass.data[DOMAIN][VICARE_API] = vicare_api hass.data[DOMAIN][VICARE_NAME] = conf[CONF_NAME] hass.data[DOMAIN][VICARE_HEATING_TYPE] = heating_type for platform in VICARE_PLATFORMS: discovery.load_platform(hass, platform, DOMAIN, {}, config) def service_vicare_mode(service): """Dispatch service calls to target entities.""" cmd = service.data[ATTR_COMMAND] entity_id = service.data[ATTR_ENTITY_ID] target_devices = [ dev for dev in hass.data[DOMAIN]["entities"]["climate"] if dev.entity_id in entity_id ] for target_device in target_devices: target_device.vicare_mode(cmd) hass.services.register( DOMAIN, SERVICE_VICARE_MODE, service_vicare_mode, schema=SERVICE_VICARE_MODE_SCHEMA, ) return True
class Vitocal200S(unittest.TestCase): def setUp(self): self.service = ViCareServiceMock('response/Vitocal200S.json') self.device = HeatPump(self.service) def test_getDomesticHotWaterConfiguredTemperature(self): self.assertEqual( self.device.getDomesticHotWaterConfiguredTemperature(), 40) def test_getAvailableCompressors(self): self.assertEqual(self.device.getAvailableCompressors(), ['0']) def test_getDomesticHotWaterConfiguredTemperature2(self): self.assertEqual( self.device.getDomesticHotWaterConfiguredTemperature2(), 60) def test_getReturnTemperature(self): self.assertEqual(self.device.getReturnTemperature(), 27.9) def test_getSupplyTemperaturePrimaryCircuit(self): self.assertEqual(self.device.getSupplyTemperaturePrimaryCircuit(), 14.5) def test_getReturnTemperatureSecondaryCircuit(self): self.assertEqual(self.device.getReturnTemperatureSecondaryCircuit(), 27.9)
class Vitocal222S(unittest.TestCase): def setUp(self): self.service = ViCareServiceMock('response/Vitocal222S.json') self.device = HeatPump(self.service) def test_getDomesticHotWaterActiveMode_10_10_time(self): with now_is('2000-01-01 10:10:00'): self.assertEqual(self.device.getDomesticHotWaterActiveMode(), 'normal') def test_getCurrentDesiredTemperature(self): self.assertEqual( self.device.circuits[0].getCurrentDesiredTemperature(), 23)
def setUp(self): self.service = ViCareServiceMock('response/Vitocal300G.json') self.device = HeatPump(self.service)
class Vitocal300G(unittest.TestCase): def setUp(self): self.service = ViCareServiceMock('response/Vitocal300G.json') self.device = HeatPump(self.service) def test_getCompressorActive(self): self.assertEqual(self.device.compressors[0].getActive(), False) def test_getCompressorHours(self): self.assertAlmostEqual(self.device.compressors[0].getHours(), 1762.41) def test_getCompressorStarts(self): self.assertAlmostEqual(self.device.compressors[0].getStarts(), 3012) def test_getCompressorHoursLoadClass1(self): self.assertAlmostEqual(self.device.compressors[0].getHoursLoadClass1(), 30) def test_getCompressorHoursLoadClass2(self): self.assertAlmostEqual(self.device.compressors[0].getHoursLoadClass2(), 703) def test_getCompressorHoursLoadClass3(self): self.assertAlmostEqual(self.device.compressors[0].getHoursLoadClass3(), 878) def test_getCompressorHoursLoadClass4(self): self.assertAlmostEqual(self.device.compressors[0].getHoursLoadClass4(), 117) def test_getCompressorHoursLoadClass5(self): self.assertAlmostEqual(self.device.compressors[0].getHoursLoadClass5(), 20) def test_getHeatingCurveSlope(self): self.assertAlmostEqual(self.device.circuits[0].getHeatingCurveSlope(), 0.8) def test_getHeatingCurveShift(self): self.assertAlmostEqual(self.device.circuits[0].getHeatingCurveShift(), -5) def test_getReturnTemperature(self): self.assertAlmostEqual(self.device.getReturnTemperature(), 18.9) def test_getReturnTemperaturePrimaryCircuit(self): self.assertAlmostEqual( self.device.getReturnTemperaturePrimaryCircuit(), 18.4) def test_getSupplyTemperaturePrimaryCircuit(self): self.assertAlmostEqual( self.device.getSupplyTemperaturePrimaryCircuit(), 18.2) def test_getPrograms(self): expected_programs = [ 'active', 'comfort', 'eco', 'fixed', 'holiday', 'normal', 'reduced', 'standby' ] self.assertListEqual(self.device.circuits[0].getPrograms(), expected_programs) def test_getModes(self): expected_modes = [ 'dhw', 'dhwAndHeating', 'forcedNormal', 'forcedReduced', 'standby', 'normalStandby' ] self.assertListEqual(self.device.circuits[0].getModes(), expected_modes) def test_getDomesticHotWaterCirculationPumpActive(self): self.assertEqual( self.device.getDomesticHotWaterCirculationPumpActive(), False)
def setUp(self): self.service = ViCareServiceMock('response_Vitocal200.json', 0) self.heat = HeatPump(None, None, None, 0, 0, self.service) PyViCare.Feature.raise_exception_on_not_supported_device_feature = True
class Vitocal200(unittest.TestCase): def setUp(self): self.service = ViCareServiceMock('response/Vitocal200.json') self.device = HeatPump(self.service) def test_getCompressorActive(self): self.assertEqual(self.device.compressors[0].getActive(), False) def test_getCompressorHours(self): self.assertAlmostEqual(self.device.compressors[0].getHours(), 8583.2) def test_getAvailableCompressors(self): self.assertEqual(self.device.getAvailableCompressors(), ['0']) def test_getCompressorStarts(self): self.assertAlmostEqual(self.device.compressors[0].getStarts(), 3180) def test_getCompressorHoursLoadClass1(self): self.assertAlmostEqual(self.device.compressors[0].getHoursLoadClass1(), 227) def test_getCompressorHoursLoadClass2(self): self.assertAlmostEqual(self.device.compressors[0].getHoursLoadClass2(), 3294) def test_getCompressorHoursLoadClass3(self): self.assertAlmostEqual(self.device.compressors[0].getHoursLoadClass3(), 3903) def test_getCompressorHoursLoadClass4(self): self.assertAlmostEqual(self.device.compressors[0].getHoursLoadClass4(), 506) def test_getCompressorHoursLoadClass5(self): self.assertAlmostEqual(self.device.compressors[0].getHoursLoadClass5(), 461) def test_getHeatingCurveSlope(self): self.assertAlmostEqual(self.device.circuits[0].getHeatingCurveSlope(), 0.3) def test_getHeatingCurveShift(self): self.assertAlmostEqual(self.device.circuits[0].getHeatingCurveShift(), -5) def test_getReturnTemperature(self): self.assertAlmostEqual(self.device.getReturnTemperature(), 27.5) def test_getReturnTemperaturePrimaryCircuit(self): self.assertRaises(PyViCareNotSupportedFeatureError, self.device.getReturnTemperaturePrimaryCircuit) def test_getSupplyTemperaturePrimaryCircuit(self): self.assertAlmostEqual( self.device.getSupplyTemperaturePrimaryCircuit(), 18.9) def test_getPrograms(self): expected_programs = [ 'active', 'comfort', 'eco', 'fixed', 'normal', 'reduced', 'standby' ] self.assertListEqual(self.device.circuits[0].getPrograms(), expected_programs) def test_getModes(self): expected_modes = ['standby', 'dhw', 'dhwAndHeatingCooling'] self.assertListEqual(self.device.circuits[0].getModes(), expected_modes) def test_getDomesticHotWaterCirculationPumpActive(self): self.assertEqual( self.device.getDomesticHotWaterCirculationPumpActive(), False) def test_getDomesticHotWaterActiveMode_fri_10_10_time(self): with now_is('2021-09-10 10:10:00'): self.assertEqual(self.device.getDomesticHotWaterActiveMode(), 'temp-2') def test_getDomesticHotWaterDesiredTemperature_fri_10_10_time(self): with now_is('2021-09-10 10:10:00'): self.assertEqual( self.device.getDomesticHotWaterDesiredTemperature(), 60) def test_getDomesticHotWaterDesiredTemperature_fri_20_00_time(self): with now_is('2021-09-10 20:00:00'): self.assertEqual( self.device.getDomesticHotWaterDesiredTemperature(), 50)
def asHeatPump(self): return HeatPump(self.service)