Skip to content

Commit

Permalink
feat: detect vitopure ventilation devices (#443)
Browse files Browse the repository at this point in the history
* detect vitopure device as ventilation

* add test cases
  • Loading branch information
CFenner authored Oct 29, 2024
1 parent 4cec5d1 commit ae9beef
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
1 change: 1 addition & 0 deletions PyViCare/PyViCareDeviceConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ def asAutoDetectDevice(self):
(self.asPelletsBoiler, r"Vitoligno|Ecotronic|VBC550P", []),
(self.asElectricalEnergySystem, r"E3_VitoCharge_03", ["type:ees"]),
(self.asVentilation, r"E3_ViAir", ["type:ventilation"]),
(self.asVentilation, r"E3_VitoPure", ["type:ventilation;purifier"]),
(self.asRadiatorActuator, r"E3_RadiatorActuator", ["type:radiator"]),
(self.asRoomSensor, r"E3_RoomSensor", ["type:climateSensor"]),
(self.asGateway, r"E3_TCU41_x04", ["type:gateway;TCU100"]),
Expand Down
11 changes: 11 additions & 0 deletions tests/test_PyViCareDeviceConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ def test_autoDetect_Vitoair_FS_300E_asVentilation(self):
device_type = c.asAutoDetectDevice()
self.assertEqual("VentilationDevice", type(device_type).__name__)

def test_autoDetect_RoleVentilationPurifier_asVentilation(self):
self.service.hasRoles = has_roles(["type:ventilation;purifier"])
c = PyViCareDeviceConfig(self.service, "0", "Unknown", "Online")
device_type = c.asAutoDetectDevice()
self.assertEqual("VentilationDevice", type(device_type).__name__)

def test_autoDetect_Vitopure_350_asVentilation(self):
c = PyViCareDeviceConfig(self.service, "0", "E3_VitoPure", "Online")
device_type = c.asAutoDetectDevice()
self.assertEqual("VentilationDevice", type(device_type).__name__)

def test_autoDetect_VitoconnectOpto1_asGateway(self):
c = PyViCareDeviceConfig(self.service, "0", "Heatbox1", "Online")
device_type = c.asAutoDetectDevice()
Expand Down
33 changes: 33 additions & 0 deletions tests/test_Vitopure350.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import unittest

from PyViCare.PyViCareUtils import PyViCareNotSupportedFeatureError
from PyViCare.PyViCareVentilationDevice import VentilationDevice
from tests.ViCareServiceMock import ViCareServiceMock


class Vitopure350(unittest.TestCase):
def setUp(self):
self.service = ViCareServiceMock('response/Vitopure350.json')
self.device = VentilationDevice(self.service)

def test_getActiveMode(self):
self.assertEqual("sensorDriven", self.device.getActiveMode())

def test_getAvailableModes(self):
expected_modes = ['permanent', 'ventilation', 'sensorDriven']
self.assertListEqual(expected_modes, self.device.getAvailableModes())

def test_getActiveProgram(self):
self.assertEqual("automatic", self.device.getActiveProgram())

def test_getAvailablePrograms(self):
expected_programs = ['standby']
self.assertListEqual(expected_programs, self.device.getAvailablePrograms())

def test_getSchedule(self):
keys = ['active', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']
self.assertListEqual(keys, list(self.device.getSchedule().keys()))

def test_getSerial(self):
with self.assertRaises(PyViCareNotSupportedFeatureError):
self.device.getSerial()

0 comments on commit ae9beef

Please sign in to comment.