Skip to content

Commit

Permalink
fix: use correct service URL for TCU19_x05 gateway (#423)
Browse files Browse the repository at this point in the history
* Update PyViCareService.py

* update test case

* fix test case
  • Loading branch information
CFenner authored Oct 4, 2024
1 parent 2c25e29 commit 883ad3b
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
2 changes: 1 addition & 1 deletion PyViCare/PyViCareDeviceConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ def asAutoDetectDevice(self):
(self.asVentilation, r"E3_ViAir", ["type:ventilation"]),
(self.asRadiatorActuator, r"E3_RadiatorActuator", ["type:radiator"]),
(self.asRoomSensor, r"E3_RoomSensor", ["type:climateSensor"]),
(self.asGateway, r"E3_TCU41_x04", ["type:gateway;TCU100"]),
(self.asGateway, r"E3_TCU19_x05", ["type:gateway;TCU200"]),
(self.asGateway, r"E3_TCU10_x07", ["type:gateway;TCU300"]),
(self.asGateway, r"E3_TCU41_x04", ["type:gateway;TCU100"]),
(self.asGateway, r"Heatbox1", ["type:gateway;VitoconnectOpto1"]),
(self.asGateway, r"Heatbox2", ["type:gateway;VitoconnectOpto2/OT2"])
]
Expand Down
2 changes: 1 addition & 1 deletion PyViCare/PyViCareService.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def hasRoles(self, requested_roles) -> bool:
return hasRoles(requested_roles, self.roles)

def _isGateway(self) -> bool:
return self.hasRoles(["type:gateway;VitoconnectOpto1"]) or self.hasRoles(["type:gateway;VitoconnectOpto2/OT2"]) or self.hasRoles(["type:gateway;TCU100"]) or self.hasRoles(["type:gateway;TCU300"])
return self.hasRoles(["type:gateway;VitoconnectOpto1"]) or self.hasRoles(["type:gateway;VitoconnectOpto2/OT2"]) or self.hasRoles(["type:gateway;TCU100"]) or self.hasRoles(["type:gateway;TCU200"]) or self.hasRoles(["type:gateway;TCU300"])

def setProperty(self, property_name: str, action: str, data: Any) -> Any:
url = buildSetPropertyUrl(
Expand Down
22 changes: 22 additions & 0 deletions tests/test_PyViCareDeviceConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ def test_autoDetect_VitoconnectOpto2_asGateway(self):
device_type = c.asAutoDetectDevice()
self.assertEqual("Gateway", type(device_type).__name__)

def test_autoDetect_TCU100_asGateway(self):
c = PyViCareDeviceConfig(self.service, "0", "E3_TCU41_x04", "Online")
device_type = c.asAutoDetectDevice()
self.assertEqual("Gateway", type(device_type).__name__)

def test_autoDetect_TCU200_asGateway(self):
c = PyViCareDeviceConfig(self.service, "0", "E3_TCU19_x05", "Online")
device_type = c.asAutoDetectDevice()
self.assertEqual("Gateway", type(device_type).__name__)

def test_autoDetect_TCU300_asGateway(self):
c = PyViCareDeviceConfig(self.service, "0", "E3_TCU10_x07", "Online")
device_type = c.asAutoDetectDevice()
Expand All @@ -94,6 +104,18 @@ def test_autoDetect_RoleGateway_asGateway_vc_opto2(self):
device_type = c.asAutoDetectDevice()
self.assertEqual("Gateway", type(device_type).__name__)

def test_autoDetect_RoleGateway_asGateway_TCU100(self):
self.service.hasRoles = has_roles(["type:gateway;TCU100"])
c = PyViCareDeviceConfig(self.service, "0", "Unknown", "Online")
device_type = c.asAutoDetectDevice()
self.assertEqual("Gateway", type(device_type).__name__)

def test_autoDetect_RoleGateway_asGateway_TCU200(self):
self.service.hasRoles = has_roles(["type:gateway;TCU200"])
c = PyViCareDeviceConfig(self.service, "0", "Unknown", "Online")
device_type = c.asAutoDetectDevice()
self.assertEqual("Gateway", type(device_type).__name__)

def test_autoDetect_RoleGateway_asGateway_TCU300(self):
self.service.hasRoles = has_roles(["type:gateway;TCU300"])
c = PyViCareDeviceConfig(self.service, "0", "Unknown", "Online")
Expand Down

0 comments on commit 883ad3b

Please sign in to comment.