From 7c0cdedd048464987770d6c3f0894a275d0f1b1b Mon Sep 17 00:00:00 2001 From: Christopher Fenner <9592452+CFenner@users.noreply.github.com> Date: Mon, 7 Oct 2024 20:20:21 +0200 Subject: [PATCH] feat: Add methods do distinguish between e3 and legacy devices (#419) * add methods do distinguish between e3 and legacy devices * add test case --- PyViCare/PyViCareDevice.py | 6 ++++++ tests/test_PyViCareDeviceConfig.py | 15 ++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) 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)