class Vitodens100W(unittest.TestCase): def setUp(self): self.service = ViCareServiceMock('response/Vitodens100W.json') self.device = GazBoiler(self.service) def test_getActive(self): self.assertEqual(self.device.burners[0].getActive(), False) def test_getBurnerStarts(self): self.assertEqual(self.device.burners[0].getStarts(), 6826) def test_getBurnerHours(self): self.assertEqual(self.device.burners[0].getHours(), 675) def test_getBurnerModulation(self): self.assertEqual(self.device.burners[0].getModulation(), 0) def test_getGasSummaryConsumptionHeatingCurrentDay(self): self.assertEqual( self.device.getGasSummaryConsumptionHeatingCurrentDay(), 11.2) def test_getGasSummaryConsumptionDomesticHotWaterCurrentMonth(self): self.assertEqual( self.device.getGasSummaryConsumptionDomesticHotWaterCurrentMonth(), 13.7) def test_getPowerSummaryConsumptionHeatingCurrentDay(self): self.assertEqual( self.device.getPowerSummaryConsumptionHeatingCurrentDay(), 0.9) def test_getPowerSummaryConsumptionDomesticHotWaterCurrentYear(self): self.assertEqual( self.device.getPowerSummaryConsumptionDomesticHotWaterCurrentYear( ), 18)
class Vitodens111W(unittest.TestCase): def setUp(self): self.service = ViCareServiceForTesting('response_Vitodens111W.json', 0) self.gaz = GazBoiler(None, None, None, 0, 0, self.service) PyViCare.Feature.raise_exception_on_not_supported_device_feature = True def test_getBurnerActive(self): self.assertEqual(self.gaz.getBurnerActive(), False) def test_getBurnerStarts(self): self.assertEqual(self.gaz.getBurnerStarts(), 12648) def test_getPowerConsumptionDays_fails(self): self.assertRaises(PyViCareNotSupportedFeatureError, self.gaz.getPowerConsumptionDays) def test_getMonthSinceLastService_fails(self): self.assertRaises(PyViCareNotSupportedFeatureError, self.gaz.getMonthSinceLastService) def test_getPrograms_fails(self): self.assertRaises(PyViCareNotSupportedFeatureError, self.gaz.getPrograms) def test_getModes(self): expected_modes = ['standby', 'dhw', 'dhwAndHeating'] self.assertListEqual(self.gaz.getModes(), expected_modes) self.assertRaises(PyViCareNotSupportedFeatureError, self.gaz.getPrograms) def test_ensure_old_behavior_non_supported_feature_returns_error(self): PyViCare.Feature.raise_exception_on_not_supported_device_feature = False self.assertEqual(self.gaz.getPowerConsumptionDays(), "error")
class Vitodens333F(unittest.TestCase): def setUp(self): self.service = ViCareServiceMock('response/Vitodens333F.json') self.device = GazBoiler(self.service) # currently missing an up-to-date test response def test_getActive(self): self.assertRaises(PyViCareNotSupportedFeatureError, self.device.burners[0].getActive) def test_getBurnerStarts(self): self.assertEqual(self.device.burners[0].getStarts(), 13987) def test_getBurnerHours(self): self.assertEqual(self.device.burners[0].getHours(), 14071.8) def test_getBurnerModulation(self): self.assertEqual(self.device.burners[0].getModulation(), 0) def test_getPrograms(self): expected_programs = [ 'active', 'comfort', 'eco', 'external', 'holiday', 'normal', 'reduced', 'standby' ] self.assertListEqual(self.device.circuits[0].getPrograms(), expected_programs) def test_getModes(self): expected_modes = [ 'standby', 'dhw', 'dhwAndHeating', 'forcedReduced', 'forcedNormal' ] self.assertListEqual(self.device.circuits[0].getModes(), expected_modes) # the api has changed, and the current response file is missing the new property, so for now we expect a not supported error def test_getPowerConsumptionDays(self): self.assertRaises(PyViCareNotSupportedFeatureError, self.device.getPowerConsumptionDays) def test_getFrostProtectionActive(self): self.assertEqual(self.device.circuits[0].getFrostProtectionActive(), False) def test_getDomesticHotWaterCirculationPumpActive(self): self.assertEqual( self.device.getDomesticHotWaterCirculationPumpActive(), False) def test_getDomesticHotWaterOutletTemperature(self): self.assertEqual(self.device.getDomesticHotWaterOutletTemperature(), 29.8) def test_getDomesticHotWaterCirculationScheduleModes(self): self.assertEqual( self.device.getDomesticHotWaterCirculationScheduleModes(), ['on']) def test_getOutsideTemperature(self): self.assertEqual(self.device.getOutsideTemperature(), 26.2) def test_getBoilerTemperature(self): self.assertEqual(self.device.getBoilerTemperature(), 35)
class Vitodens300W(unittest.TestCase): def setUp(self): self.service = ViCareServiceMock('response/Vitodens300W.json') self.device = GazBoiler(self.service) def test_getBurnerActive(self): self.assertEqual(self.device.getBurnerActive(), True) # Is currently (August, 2021) not supported by the Viessman API even though it works for the Vitodens 200W. def test_getBurnerStarts(self): self.assertRaises(PyViCareNotSupportedFeatureError, self.device.circuits[0].getBurnerStarts) # Is currently (August, 2021) not supported by the Viessman API even though it works for the Vitodens 200W. def test_getBurnerHours(self): self.assertRaises(PyViCareNotSupportedFeatureError, self.device.circuits[0].getBurnerHours) # Is currently (August, 2021) not supported by the Viessman API even though it works for the Vitodens 200W. def test_getBurnerModulation(self): self.assertRaises(PyViCareNotSupportedFeatureError, self.device.circuits[0].getBurnerModulation) def test_getPrograms(self): expected_programs = ['active', 'comfort', 'eco', 'external', 'holiday', 'normal', 'reduced', 'standby'] self.assertListEqual( self.device.circuits[0].getPrograms(), expected_programs) def test_getModes(self): expected_modes = ['dhw', 'dhwAndHeating', 'forcedNormal', 'forcedReduced', 'standby'] self.assertListEqual( self.device.circuits[0].getModes(), expected_modes) def test_getPowerConsumptionDays(self): expected_consumption = [0.103, 0.186, 0.224, 0.254, 0.202, 0.207, 0.185, 0.145] self.assertEqual(self.device.getPowerConsumptionDays(), expected_consumption) def test_getFrostProtectionActive(self): self.assertEqual( self.device.circuits[0].getFrostProtectionActive(), False) def test_getDomesticHotWaterCirculationPumpActive(self): self.assertEqual( self.device.getDomesticHotWaterCirculationPumpActive(), False) # Is currently (August, 2021) not supported by the Viessman API even though it works for the Vitodens 200W. def test_getDomesticHotWaterOutletTemperature(self): self.assertRaises(PyViCareNotSupportedFeatureError, self.device.getDomesticHotWaterOutletTemperature) def test_getDomesticHotWaterCirculationScheduleModes(self): self.assertEqual( self.device.getDomesticHotWaterCirculationScheduleModes(), ['on'])
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 Vitodens200W(unittest.TestCase): def setUp(self): self.service = ViCareServiceMock('response/Vitodens200W.json') self.device = GazBoiler(self.service) def test_getBurnerActive(self): self.assertEqual(self.device.getBurnerActive(), False) def test_getBurnerStarts(self): self.assertEqual(self.device.circuits[0].getBurnerStarts(), 8125) def test_getBurnerHours(self): self.assertEqual(self.device.circuits[0].getBurnerHours(), 5605) def test_getBurnerModulation(self): self.assertEqual(self.device.circuits[0].getBurnerModulation(), 0) def test_getPrograms(self): expected_programs = [ 'active', 'comfort', 'forcedLastFromSchedule', 'normal', 'reduced', 'standby' ] self.assertListEqual(self.device.circuits[0].getPrograms(), expected_programs) def test_getModes(self): expected_modes = ['standby', 'heating', 'dhw', 'dhwAndHeating'] self.assertListEqual(self.device.circuits[0].getModes(), expected_modes) # Is currently (August, 2021) not supported by the Viessman API def test_getPowerConsumptionDays(self): self.assertRaises(PyViCareNotSupportedFeatureError, self.device.getPowerConsumptionDays) def test_getDomesticHotWaterMaxTemperature(self): self.assertEqual(self.device.getDomesticHotWaterMaxTemperature(), 60) def test_getDomesticHotWaterMinTemperature(self): self.assertEqual(self.device.getDomesticHotWaterMinTemperature(), 10) def test_getFrostProtectionActive(self): self.assertEqual(self.device.circuits[0].getFrostProtectionActive(), False) def test_getDomesticHotWaterCirculationPumpActive(self): self.assertEqual( self.device.getDomesticHotWaterCirculationPumpActive(), False) def test_getDomesticHotWaterOutletTemperature(self): self.assertEqual(self.device.getDomesticHotWaterOutletTemperature(), 41.9) def test_getDomesticHotWaterConfiguredTemperature(self): self.assertEqual( self.device.getDomesticHotWaterConfiguredTemperature(), 55) def test_getDomesticHotWaterCirculationScheduleModes(self): self.assertEqual( self.device.getDomesticHotWaterCirculationScheduleModes(), ['on'])
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 Vitodens333F(unittest.TestCase): def setUp(self): self.service = ViCareServiceMock('response/Vitodens333F.json') self.device = GazBoiler(self.service) def test_getBurnerActive(self): self.assertEqual(self.device.getBurnerActive(), False) def test_getBurnerStarts(self): self.assertEqual(self.device.circuits[0].getBurnerStarts(), 13987) def test_getBurnerHours(self): self.assertEqual(self.device.circuits[0].getBurnerHours(), 14071.8) def test_getBurnerModulation(self): self.assertEqual(self.device.circuits[0].getBurnerModulation(), 0) def test_getPrograms(self): expected_programs = ['active', 'comfort', 'eco', 'external', 'holiday', 'normal', 'reduced', 'standby'] self.assertListEqual( self.device.circuits[0].getPrograms(), expected_programs) def test_getModes(self): expected_modes = ['standby', 'dhw', 'dhwAndHeating', 'forcedReduced', 'forcedNormal'] self.assertListEqual( self.device.circuits[0].getModes(), expected_modes) def test_getPowerConsumptionDays(self): expected_consumption = [0.097, 0.162, 0.166, 0.162, 0.159, 0.173, 0.182, 0.159] self.assertEqual(self.device.getPowerConsumptionDays(), expected_consumption) def test_getFrostProtectionActive(self): self.assertEqual( self.device.circuits[0].getFrostProtectionActive(), False) def test_getDomesticHotWaterCirculationPumpActive(self): self.assertEqual( self.device.getDomesticHotWaterCirculationPumpActive(), False) def test_getDomesticHotWaterOutletTemperature(self): self.assertEqual( self.device.getDomesticHotWaterOutletTemperature(), 29.8) def test_getDomesticHotWaterCirculationScheduleModes(self): self.assertEqual( self.device.getDomesticHotWaterCirculationScheduleModes(), ['on']) def test_getOutsideTemperature(self): self.assertEqual( self.device.getOutsideTemperature(), 26.2) def test_getBoilerTemperature(self): self.assertEqual( self.device.getBoilerTemperature(), 35)
class Vitodens222W(unittest.TestCase): def setUp(self): self.service = ViCareServiceMock('response/Vitodens222W.json') self.device = GazBoiler(self.service) def test_getActive(self): self.assertEqual(self.device.burners[0].getActive(), True) def test_getBurnerStarts(self): self.assertEqual(self.device.burners[0].getStarts(), 8299) def test_getBurnerHours(self): self.assertEqual(self.device.burners[0].getHours(), 5674) def test_getBurnerModulation(self): self.assertEqual(self.device.burners[0].getModulation(), 15.8) def test_getPrograms(self): expected_programs = [ 'active', 'comfort', 'forcedLastFromSchedule', 'normal', 'reduced', 'standby' ] self.assertListEqual(self.device.circuits[0].getPrograms(), expected_programs) def test_getModes(self): expected_modes = ['standby', 'heating', 'dhw', 'dhwAndHeating'] self.assertListEqual(self.device.circuits[0].getModes(), expected_modes) def test_getPowerConsumptionDays(self): expected_consumption = [0.4, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1, 0.1] self.assertListEqual(self.device.getPowerConsumptionDays(), expected_consumption) def test_getFrostProtectionActive(self): self.assertEqual(self.device.circuits[0].getFrostProtectionActive(), False) def test_getDomesticHotWaterCirculationPumpActive(self): self.assertEqual( self.device.getDomesticHotWaterCirculationPumpActive(), False) def test_getDomesticHotWaterOutletTemperature(self): self.assertEqual(self.device.getDomesticHotWaterOutletTemperature(), 39.8) def test_getDomesticHotWaterCirculationScheduleModes(self): self.assertEqual( self.device.getDomesticHotWaterCirculationScheduleModes(), ['on']) def test_getOutsideTemperature(self): self.assertEqual(self.device.getOutsideTemperature(), 11.9) def test_getOneTimeCharge(self): self.assertEqual(self.device.getOneTimeCharge(), False) def test_getBoilerTemperature(self): self.assertRaises(PyViCareNotSupportedFeatureError, self.device.getBoilerTemperature)
class Vitodens222W(unittest.TestCase): def setUp(self): self.service = ViCareServiceMock('response/Vitodens222W.json') self.device = GazBoiler(self.service) def test_getBurnerActive(self): self.assertEqual(self.device.getBurnerActive(), False) def test_getBurnerStarts(self): self.assertEqual(self.device.circuits[0].getBurnerStarts(), 79167) def test_getBurnerHours(self): self.assertEqual(self.device.circuits[0].getBurnerHours(), 25123.2) def test_getBurnerModulation(self): self.assertEqual(self.device.circuits[0].getBurnerModulation(), 0) def test_getPrograms(self): expected_programs = [ 'active', 'comfort', 'eco', 'external', 'holiday', 'normal', 'reduced', 'standby' ] self.assertListEqual(self.device.circuits[0].getPrograms(), expected_programs) def test_getModes(self): expected_modes = [ 'standby', 'dhw', 'dhwAndHeating', 'forcedReduced', 'forcedNormal' ] self.assertListEqual(self.device.circuits[0].getModes(), expected_modes) def test_getPowerConsumptionDays(self): self.assertRaises(PyViCareNotSupportedFeatureError, self.device.getPowerConsumptionDays) def test_getFrostProtectionActive(self): self.assertEqual(self.device.circuits[0].getFrostProtectionActive(), False) def test_getDomesticHotWaterCirculationPumpActive(self): self.assertEqual( self.device.getDomesticHotWaterCirculationPumpActive(), False) def test_getDomesticHotWaterOutletTemperature(self): self.assertEqual(self.device.getDomesticHotWaterOutletTemperature(), 44.8) def test_getDomesticHotWaterCirculationScheduleModes(self): self.assertEqual( self.device.getDomesticHotWaterCirculationScheduleModes(), ['on']) def test_getOutsideTemperature(self): self.assertEqual(self.device.getOutsideTemperature(), 16.3) def test_getBoilerTemperature(self): self.assertEqual(self.device.getBoilerTemperature(), 73)
def setUp(self): self.service = ViCareServiceMock('response/Vitodens100W.json') self.device = GazBoiler(self.service)
def asGazBoiler(self): return GazBoiler(self.service)
def setUp(self): self.service = ViCareServiceForTesting('response_Vitodens222F.json', 0) self.gaz = GazBoiler(None, None, None, 0, 0, self.service) PyViCare.Feature.raise_exception_on_not_supported_device_feature = True
class Vitodens222F(unittest.TestCase): def setUp(self): self.service = ViCareServiceForTesting('response_Vitodens222F.json', 0) self.gaz = GazBoiler(None, None, None, 0, 0, self.service) PyViCare.Feature.raise_exception_on_not_supported_device_feature = True def test_getBurnerActive(self): self.assertEqual(self.gaz.getBurnerActive(), False) def test_getBurnerStarts(self): self.assertEqual(self.gaz.getBurnerStarts(), 5898) def test_getPowerConsumptionToday(self): self.assertEqual(self.gaz.getPowerConsumptionToday(), 1) def test_getMonthSinceLastService_fails(self): self.assertRaises(PyViCareNotSupportedFeatureError, self.gaz.getMonthSinceLastService) def test_getSupplyTemperature(self): self.assertAlmostEqual(self.gaz.getSupplyTemperature(), 41.9) def test_getPrograms(self): expected_programs = [ 'active', 'comfort', 'forcedLastFromSchedule', 'holiday', 'holidayAtHome', 'normal', 'reduced', 'standby' ] self.assertListEqual(self.gaz.getPrograms(), expected_programs) def test_getOneTimeCharge(self): self.assertEqual(self.gaz.getOneTimeCharge(), False) def test_activateComfort(self): self.gaz.activateOneTimeCharge() self.assertEqual(len(self.service.setPropertyData), 1) self.assertEqual(self.service.setPropertyData[0]['action'], 'activate') self.assertEqual(self.service.setPropertyData[0]['property_name'], 'heating.dhw.oneTimeCharge') self.assertEqual( self.service.setPropertyData[0]['url'], 'https://api.viessmann-platform.io/operational-data/v1/installations/[id]/gateways/[serial]/devices/0/features/heating.dhw.oneTimeCharge/activate' ) def test_deactivateComfort(self): self.gaz.deactivateOneTimeCharge() self.assertEqual(len(self.service.setPropertyData), 1) self.assertEqual(self.service.setPropertyData[0]['action'], 'deactivate') self.assertEqual(self.service.setPropertyData[0]['property_name'], 'heating.dhw.oneTimeCharge') self.assertEqual( self.service.setPropertyData[0]['url'], 'https://api.viessmann-platform.io/operational-data/v1/installations/[id]/gateways/[serial]/devices/0/features/heating.dhw.oneTimeCharge/deactivate' ) def test_getModes(self): expected_modes = ['standby', 'heating', 'dhw', 'dhwAndHeating'] self.assertListEqual(self.gaz.getModes(), expected_modes)
class Vitodens200W(unittest.TestCase): def setUp(self): self.service = ViCareServiceMock('response/Vitodens200W.json') self.device = GazBoiler(self.service) def test_getSerial(self): self.assertEqual(self.device.getSerial(), '################') def test_getBoilerCommonSupplyTemperature(self): self.assertEqual(self.device.getBoilerCommonSupplyTemperature(), 44.4) def test_getActive(self): self.assertEqual(self.device.burners[0].getActive(), False) def test_getDomesticHotWaterActive(self): self.assertEqual(self.device.getDomesticHotWaterActive(), True) def test_getBurnerStarts(self): self.assertEqual(self.device.burners[0].getStarts(), 8237) def test_getBurnerHours(self): self.assertEqual(self.device.burners[0].getHours(), 5644) def test_getBurnerModulation(self): self.assertEqual(self.device.burners[0].getModulation(), 0) def test_getPrograms(self): expected_programs = [ 'active', 'comfort', 'forcedLastFromSchedule', 'normal', 'reduced', 'standby'] self.assertListEqual( self.device.circuits[0].getPrograms(), expected_programs) def test_getModes(self): expected_modes = ['standby', 'heating', 'dhw', 'dhwAndHeating'] self.assertListEqual( self.device.circuits[0].getModes(), expected_modes) def test_getPowerConsumptionDays(self): expected_days = [0.1, 0.2, 0.2, 0.2, 0.2, 0.4, 0.4, 0.1] self.assertEqual(self.device.getPowerConsumptionDays(), expected_days) def test_getDomesticHotWaterMaxTemperature(self): self.assertEqual(self.device.getDomesticHotWaterMaxTemperature(), 60) def test_getDomesticHotWaterMinTemperature(self): self.assertEqual(self.device.getDomesticHotWaterMinTemperature(), 10) def test_getFrostProtectionActive(self): self.assertEqual( self.device.circuits[0].getFrostProtectionActive(), False) def test_getDomesticHotWaterCirculationPumpActive(self): self.assertEqual( self.device.getDomesticHotWaterCirculationPumpActive(), False) def test_getDomesticHotWaterOutletTemperature(self): self.assertEqual( self.device.getDomesticHotWaterOutletTemperature(), 39.1) def test_getDomesticHotWaterConfiguredTemperature(self): self.assertEqual( self.device.getDomesticHotWaterConfiguredTemperature(), 55) def test_getDomesticHotWaterCirculationScheduleModes(self): self.assertEqual( self.device.getDomesticHotWaterCirculationScheduleModes(), ['on']) def test_getDomesticHotWaterCirculationMode_wed_07_30_time(self): with now_is('2021-09-08 07:30:00'): self.assertEqual( self.device.getDomesticHotWaterCirculationMode(), 'on') def test_getDomesticHotWaterCirculationMode_wed_10_10_time(self): with now_is('2021-09-08 10:10:00'): self.assertEqual( self.device.getDomesticHotWaterCirculationMode(), 'off') def test_getGasConsumptionHeatingUnit(self): self.assertEqual( self.device.getGasConsumptionHeatingUnit(), "cubicMeter") def test_getGasConsumptionHeatingToday(self): self.assertEqual( self.device.getGasConsumptionHeatingToday(), 0) def test_getGasConsumptionDomesticHotWaterUnit(self): self.assertEqual( self.device.getGasConsumptionDomesticHotWaterUnit(), "cubicMeter") def test_getGasConsumptionDomesticHotWaterToday(self): self.assertEqual( self.device.getGasConsumptionDomesticHotWaterToday(), 1.3) def test_getPowerConsumptionUnit(self): self.assertEqual( self.device.getPowerConsumptionUnit(), "kilowattHour") def test_getPowerConsumptionToday(self): self.assertEqual( self.device.getPowerConsumptionToday(), 0.1)