diff --git a/PyViCare/PyViCareDevice.py b/PyViCare/PyViCareDevice.py index 4a1d0525..13f77f4a 100644 --- a/PyViCare/PyViCareDevice.py +++ b/PyViCare/PyViCareDevice.py @@ -15,3 +15,9 @@ def __init__(self, service: ViCareService) -> None: @handleNotSupported def getSerial(self): return self.service.getProperty("device.serial")["properties"]["value"]["value"] + + def isLegacyDevice(self) -> bool: + return self.service.hasRoles(["type:legacy"]) + + def isE3Device(self) -> bool: + return self.service.hasRoles(["type:E3"]) diff --git a/tests/test_PyViCareDeviceConfig.py b/tests/test_PyViCareDeviceConfig.py index c3fbd31e..efe324ef 100644 --- a/tests/test_PyViCareDeviceConfig.py +++ b/tests/test_PyViCareDeviceConfig.py @@ -62,7 +62,6 @@ def test_autoDetect_RoleVentilation_asVentilation(self): self.assertEqual("VentilationDevice", type(device_type).__name__) def test_autoDetect_Vitoair_FS_300E_asVentilation(self): - # self.service.hasRoles = has_roles(["type:ventilation"]) c = PyViCareDeviceConfig(self.service, "0", "E3_ViAir_300F", "Online") device_type = c.asAutoDetectDevice() self.assertEqual("VentilationDevice", type(device_type).__name__) @@ -121,3 +120,17 @@ def test_autoDetect_RoleGateway_asGateway_TCU300(self): c = PyViCareDeviceConfig(self.service, "0", "Unknown", "Online") device_type = c.asAutoDetectDevice() self.assertEqual("Gateway", type(device_type).__name__) + + def test_legacy_device(self): + self.service.hasRoles = has_roles(["type:legacy"]) + c = PyViCareDeviceConfig(self.service, "0", "Unknown", "Online") + device = c.asAutoDetectDevice() + self.assertEqual(device.isLegacyDevice(), True) + self.assertEqual(device.isE3Device(), False) + + def test_e3_device(self): + self.service.hasRoles = has_roles(["type:E3"]) + c = PyViCareDeviceConfig(self.service, "0", "Unknown", "Online") + device = c.asAutoDetectDevice() + self.assertEqual(device.isLegacyDevice(), False) + self.assertEqual(device.isE3Device(), True)