Skip to content

Commit e9d7b2f

Browse files
authored
Update TC_TSTAT_4_2 to work with thermostats that are already on a fabric or don't have min/max (project-chip#35754)
* Don't hard-code the fabric index when removing the secondary fabric * Fall back on Absolute setpoints, and then defaults, when user-configured setpoints are unimplemented
1 parent a643be6 commit e9d7b2f

File tree

1 file changed

+38
-8
lines changed

1 file changed

+38
-8
lines changed

src/python_testing/TC_TSTAT_4_2.py

+38-8
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,8 @@ async def test_TC_TSTAT_4_2(self):
261261
nodeId=self.dut_node_id, setupPinCode=params.setupPinCode,
262262
filterType=ChipDeviceCtrl.DiscoveryFilterType.LONG_DISCRIMINATOR, filter=1234)
263263

264+
secondary_fabric_index = await self.read_single_attribute_check_success(dev_ctrl=secondary_controller, endpoint=0, cluster=Clusters.Objects.OperationalCredentials, attribute=Clusters.OperationalCredentials.Attributes.CurrentFabricIndex)
265+
264266
current_presets = []
265267
presetTypes = []
266268
presetScenarioCounts = {}
@@ -272,26 +274,54 @@ async def test_TC_TSTAT_4_2(self):
272274

273275
supportsHeat = self.check_pics("TSTAT.S.F00")
274276
supportsCool = self.check_pics("TSTAT.S.F01")
275-
supportsOccupancy = self.check_pics("TSTAT.S.F02")
276-
277-
occupied = True
278277

279278
if supportsHeat:
280-
minHeatSetpointLimit = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.MinHeatSetpointLimit)
281-
maxHeatSetpointLimit = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.MaxHeatSetpointLimit)
279+
# If the server supports MinHeatSetpointLimit & MaxHeatSetpointLimit, use those
280+
if self.check_pics("TSTAT.S.A0015") and self.check_pics("TSTAT.S.A0016"):
281+
minHeatSetpointLimit = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.MinHeatSetpointLimit)
282+
maxHeatSetpointLimit = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.MaxHeatSetpointLimit)
283+
elif self.check_pics("TSTAT.S.A0003") and self.check_pics("TSTAT.S.A0004"):
284+
# Otherwise, if the server supports AbsMinHeatSetpointLimit & AbsMaxHeatSetpointLimit, use those
285+
minHeatSetpointLimit = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.AbsMinHeatSetpointLimit)
286+
maxHeatSetpointLimit = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.AbsMaxHeatSetpointLimit)
287+
282288
asserts.assert_true(minHeatSetpointLimit < maxHeatSetpointLimit, "Heat setpoint range invalid")
283289

284290
if supportsCool:
285-
minCoolSetpointLimit = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.MinCoolSetpointLimit)
286-
maxCoolSetpointLimit = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.MaxCoolSetpointLimit)
291+
# If the server supports MinCoolSetpointLimit & MaxCoolSetpointLimit, use those
292+
if self.check_pics("TSTAT.S.A0017") and self.check_pics("TSTAT.S.A0018"):
293+
minCoolSetpointLimit = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.MinCoolSetpointLimit)
294+
maxCoolSetpointLimit = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.MaxCoolSetpointLimit)
295+
elif self.check_pics("TSTAT.S.A0005") and self.check_pics("TSTAT.S.A0006"):
296+
# Otherwise, if the server supports AbsMinCoolSetpointLimit & AbsMaxCoolSetpointLimit, use those
297+
minCoolSetpointLimit = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.AbsMinCoolSetpointLimit)
298+
maxCoolSetpointLimit = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.AbsMaxCoolSetpointLimit)
299+
287300
asserts.assert_true(minCoolSetpointLimit < maxCoolSetpointLimit, "Cool setpoint range invalid")
288301

302+
# Servers that do not support occupancy are always "occupied"
303+
occupied = True
304+
305+
supportsOccupancy = self.check_pics("TSTAT.S.F02")
289306
if supportsOccupancy:
290307
occupied = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.Occupancy) & 1
291308

309+
# Target setpoints
292310
heatSetpoint = minHeatSetpointLimit + ((maxHeatSetpointLimit - minHeatSetpointLimit) / 2)
293311
coolSetpoint = minCoolSetpointLimit + ((maxCoolSetpointLimit - minCoolSetpointLimit) / 2)
294312

313+
# Set the heating and cooling setpoints to something other than the target setpoints
314+
if occupied:
315+
if supportsHeat:
316+
await self.write_single_attribute(attribute_value=cluster.Attributes.OccupiedHeatingSetpoint(heatSetpoint-1), endpoint_id=endpoint)
317+
if supportsCool:
318+
await self.write_single_attribute(attribute_value=cluster.Attributes.OccupiedCoolingSetpoint(coolSetpoint-1), endpoint_id=endpoint)
319+
else:
320+
if supportsHeat:
321+
await self.write_single_attribute(attribute_value=cluster.Attributes.UnoccupiedHeatingSetpoint(heatSetpoint-1), endpoint_id=endpoint)
322+
if supportsCool:
323+
await self.write_single_attribute(attribute_value=cluster.Attributes.UnoccupiedCoolingSetpoint(coolSetpoint-1), endpoint_id=endpoint)
324+
295325
self.step("2")
296326
if self.pics_guard(self.check_pics("TSTAT.S.F08") and self.check_pics("TSTAT.S.A0050")):
297327

@@ -643,7 +673,7 @@ async def test_TC_TSTAT_4_2(self):
643673
await self.send_atomic_request_begin_command(dev_ctrl=secondary_controller)
644674

645675
# Primary controller removes the second fabric
646-
await self.send_single_cmd(Clusters.OperationalCredentials.Commands.RemoveFabric(fabricIndex=2), endpoint=0)
676+
await self.send_single_cmd(Clusters.OperationalCredentials.Commands.RemoveFabric(fabricIndex=secondary_fabric_index), endpoint=0)
647677

648678
# Send the AtomicRequest begin command from primary controller, which should succeed, as the secondary controller's atomic write state has been cleared
649679
status = await self.send_atomic_request_begin_command()

0 commit comments

Comments
 (0)