Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update TC_TSTAT_4_2 to work with thermostats that do not have AUTO feature #35579

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 53 additions & 25 deletions src/python_testing/TC_TSTAT_4_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ def get_available_scenario(self, presetTypes: list, presetScenarioCounts: map):
return availableScenarios[0]
return None

def make_preset(self, presetScenario, coolSetpoint, heatSetpoint, presetHandle=NullValue, name=None, builtIn=False):
preset = cluster.Structs.PresetStruct(presetHandle=presetHandle, presetScenario=presetScenario, builtIn=builtIn)
if self.check_pics("TSTAT.S.F00"):
preset.heatingSetpoint = heatSetpoint
if self.check_pics("TSTAT.S.F01"):
preset.coolingSetpoint = coolSetpoint
if name is not None:
preset.name = name
return preset

async def write_presets(self,
endpoint,
presets,
Expand Down Expand Up @@ -255,13 +265,29 @@ async def test_TC_TSTAT_4_2(self):
presetTypes = []
presetScenarioCounts = {}
numberOfPresetsSupported = 0
minHeatSetpointLimit = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.MinHeatSetpointLimit)
maxHeatSetpointLimit = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.MaxHeatSetpointLimit)
minCoolSetpointLimit = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.MinCoolSetpointLimit)
maxCoolSetpointLimit = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.MaxCoolSetpointLimit)
minHeatSetpointLimit = 700
maxHeatSetpointLimit = 3000
minCoolSetpointLimit = 1600
maxCoolSetpointLimit = 3200

supportsHeat = self.check_pics("TSTAT.S.F00")
supportsCool = self.check_pics("TSTAT.S.F01")
supportsOccupancy = self.check_pics("TSTAT.S.F02")

occupied = True

asserts.assert_true(minHeatSetpointLimit < maxHeatSetpointLimit, "Heat setpoint range invalid")
asserts.assert_true(minCoolSetpointLimit < maxCoolSetpointLimit, "Cool setpoint range invalid")
if supportsHeat:
minHeatSetpointLimit = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.MinHeatSetpointLimit)
maxHeatSetpointLimit = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.MaxHeatSetpointLimit)
asserts.assert_true(minHeatSetpointLimit < maxHeatSetpointLimit, "Heat setpoint range invalid")

if supportsCool:
minCoolSetpointLimit = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.MinCoolSetpointLimit)
maxCoolSetpointLimit = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.MaxCoolSetpointLimit)
asserts.assert_true(minCoolSetpointLimit < maxCoolSetpointLimit, "Cool setpoint range invalid")

if supportsOccupancy:
occupied = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.Occupancy) & 1

heatSetpoint = minHeatSetpointLimit + ((maxHeatSetpointLimit - minHeatSetpointLimit) / 2)
coolSetpoint = minCoolSetpointLimit + ((maxCoolSetpointLimit - minCoolSetpointLimit) / 2)
Expand Down Expand Up @@ -296,8 +322,7 @@ async def test_TC_TSTAT_4_2(self):
for preset in test_presets:
preset.builtIn = NullValue

test_presets.append(cluster.Structs.PresetStruct(presetHandle=NullValue, presetScenario=availableScenario,
coolingSetpoint=coolSetpoint, heatingSetpoint=heatSetpoint, builtIn=False))
test_presets.append(self.make_preset(availableScenario, coolSetpoint, heatSetpoint))

await self.send_atomic_request_begin_command()

Expand Down Expand Up @@ -334,8 +359,7 @@ async def test_TC_TSTAT_4_2(self):
if len(builtInPresets) > 0:
builtInPresets[0].builtIn = NullValue

test_presets.append(cluster.Structs.PresetStruct(presetHandle=NullValue, presetScenario=availableScenario,
coolingSetpoint=coolSetpoint, heatingSetpoint=heatSetpoint, builtIn=False))
test_presets.append(self.make_preset(availableScenario, coolSetpoint, heatSetpoint))

# Send the AtomicRequest begin command
await self.send_atomic_request_begin_command()
Expand Down Expand Up @@ -415,7 +439,16 @@ async def test_TC_TSTAT_4_2(self):
"Couldn't run test step 6 since there were no non-built-in presets to activate and delete")

# Write the occupied cooling setpoint to a different value
await self.write_single_attribute(attribute_value=cluster.Attributes.OccupiedCoolingSetpoint(2300), endpoint_id=endpoint)
if occupied:
if supportsHeat:
await self.write_single_attribute(attribute_value=cluster.Attributes.OccupiedHeatingSetpoint(heatSetpoint+1), endpoint_id=endpoint)
elif supportsCool:
await self.write_single_attribute(attribute_value=cluster.Attributes.OccupiedCoolingSetpoint(coolSetpoint+1), endpoint_id=endpoint)
else:
if supportsHeat:
await self.write_single_attribute(attribute_value=cluster.Attributes.UnoccupiedHeatingSetpoint(heatSetpoint+1), endpoint_id=endpoint)
elif supportsCool:
await self.write_single_attribute(attribute_value=cluster.Attributes.UnoccupiedCoolingSetpoint(coolSetpoint+1), endpoint_id=endpoint)

activePresetHandle = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=cluster.Attributes.ActivePresetHandle)
logger.info(f"Rx'd ActivePresetHandle: {activePresetHandle}")
Expand Down Expand Up @@ -456,8 +489,7 @@ async def test_TC_TSTAT_4_2(self):
await self.send_atomic_request_begin_command()

# Write to the presets attribute after adding a preset with builtIn set to True
test_presets.append(cluster.Structs.PresetStruct(presetHandle=NullValue, presetScenario=availableScenario,
coolingSetpoint=coolSetpoint, heatingSetpoint=heatSetpoint, builtIn=True))
test_presets.append(self.make_preset(availableScenario, coolSetpoint, heatSetpoint, builtIn=True))

status = await self.write_presets(endpoint=endpoint, presets=test_presets, expected_status=Status.ConstraintError)

Expand All @@ -475,8 +507,8 @@ async def test_TC_TSTAT_4_2(self):

# Write to the presets attribute after adding a preset with a preset handle that doesn't exist in Presets attribute
test_presets = copy.deepcopy(current_presets)
test_presets.append(cluster.Structs.PresetStruct(presetHandle=random.randbytes(16), presetScenario=cluster.Enums.PresetScenarioEnum.kWake,
name="Wake", coolingSetpoint=coolSetpoint, heatingSetpoint=heatSetpoint, builtIn=True))
test_presets.append(self.make_preset(cluster.Enums.PresetScenarioEnum.kWake, coolSetpoint,
heatSetpoint, presetHandle=random.randbytes(16), name="Wake", builtIn=True))

status = await self.write_presets(endpoint=endpoint, presets=test_presets, expected_status=Status.NotFound)

Expand All @@ -497,8 +529,8 @@ async def test_TC_TSTAT_4_2(self):
await self.send_atomic_request_begin_command()

# Write to the presets attribute after adding a duplicate preset
test_presets.append(cluster.Structs.PresetStruct(
presetHandle=duplicatePreset.presetHandle, presetScenario=availableScenario, coolingSetpoint=coolSetpoint, heatingSetpoint=heatSetpoint, builtIn=False))
test_presets.append(self.make_preset(availableScenario, coolSetpoint,
heatSetpoint, presetHandle=duplicatePreset.presetHandle))

await self.write_presets(endpoint=endpoint, presets=test_presets, expected_status=Status.ConstraintError)

Expand Down Expand Up @@ -540,8 +572,7 @@ async def test_TC_TSTAT_4_2(self):
presets_without_name_support = list(preset for preset in test_presets if preset.presetScenario in availableScenarios)

if len(presets_without_name_support) == 0 and len(availableScenarios) > 0:
new_preset = cluster.Structs.PresetStruct(presetHandle=NullValue, presetScenario=availableScenarios[0],
coolingSetpoint=coolSetpoint, heatingSetpoint=heatSetpoint, builtIn=True)
new_preset = self.make_preset(availableScenarios[0], coolSetpoint, heatSetpoint, builtIn=True)
test_presets.append(new_preset)
presets_without_name_support = [new_preset]

Expand Down Expand Up @@ -570,8 +601,7 @@ async def test_TC_TSTAT_4_2(self):

# Write to the presets attribute with a new valid preset added
test_presets = copy.deepcopy(current_presets)
test_presets.append(cluster.Structs.PresetStruct(presetHandle=NullValue, presetScenario=availableScenario,
coolingSetpoint=coolSetpoint, heatingSetpoint=heatSetpoint, builtIn=False))
test_presets.append(self.make_preset(availableScenario, coolSetpoint, heatSetpoint))

# Send the AtomicRequest begin command
await self.send_atomic_request_begin_command()
Expand Down Expand Up @@ -630,8 +660,7 @@ async def test_TC_TSTAT_4_2(self):
presetScenario for presetScenario in cluster.Enums.PresetScenarioEnum if presetScenario not in supportedScenarios)
if len(unavailableScenarios) > 0:
test_presets = current_presets.copy()
test_presets.append(cluster.Structs.PresetStruct(presetHandle=NullValue, presetScenario=unavailableScenarios[0],
name="Preset", coolingSetpoint=coolSetpoint, heatingSetpoint=heatSetpoint, builtIn=False))
test_presets.append(self.make_preset(unavailableScenarios[0], coolSetpoint, heatSetpoint, name="Preset"))

# Send the AtomicRequest begin command
await self.send_atomic_request_begin_command()
Expand Down Expand Up @@ -664,8 +693,7 @@ async def test_TC_TSTAT_4_2(self):
presetsAddedForScenario = presetsAddedForScenario + 1

while presetsAddedForScenario < presetType.numberOfPresets:
testPresets.append(cluster.Structs.PresetStruct(presetHandle=NullValue, presetScenario=scenario,
coolingSetpoint=coolSetpoint, heatingSetpoint=heatSetpoint, builtIn=False))
testPresets.append(self.make_preset(scenario, coolSetpoint, heatSetpoint))
presetsAddedForScenario = presetsAddedForScenario + 1

# Send the AtomicRequest begin command
Expand Down
Loading