Skip to content

Commit

Permalink
feat: Add methods do distinguish between e3 and legacy devices (#419)
Browse files Browse the repository at this point in the history
* add methods do distinguish between e3 and legacy devices

* add test case
  • Loading branch information
CFenner authored Oct 7, 2024
1 parent 90120c0 commit 7c0cded
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
6 changes: 6 additions & 0 deletions PyViCare/PyViCareDevice.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
15 changes: 14 additions & 1 deletion tests/test_PyViCareDeviceConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand Down Expand Up @@ -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)

0 comments on commit 7c0cded

Please sign in to comment.