Fix invalid alexa climate or water_heater state report with double listed targetSetpoint (#107673)
parent
5bdcbc4e8b
commit
de9bb20135
|
@ -1112,13 +1112,17 @@ class AlexaThermostatController(AlexaCapability):
|
|||
"""Return what properties this entity supports."""
|
||||
properties = [{"name": "thermostatMode"}]
|
||||
supported = self.entity.attributes.get(ATTR_SUPPORTED_FEATURES, 0)
|
||||
if supported & climate.ClimateEntityFeature.TARGET_TEMPERATURE:
|
||||
if self.entity.domain == climate.DOMAIN:
|
||||
if supported & climate.ClimateEntityFeature.TARGET_TEMPERATURE_RANGE:
|
||||
properties.append({"name": "lowerSetpoint"})
|
||||
properties.append({"name": "upperSetpoint"})
|
||||
if supported & climate.ClimateEntityFeature.TARGET_TEMPERATURE:
|
||||
properties.append({"name": "targetSetpoint"})
|
||||
elif (
|
||||
self.entity.domain == water_heater.DOMAIN
|
||||
and supported & water_heater.WaterHeaterEntityFeature.TARGET_TEMPERATURE
|
||||
):
|
||||
properties.append({"name": "targetSetpoint"})
|
||||
if supported & water_heater.WaterHeaterEntityFeature.TARGET_TEMPERATURE:
|
||||
properties.append({"name": "targetSetpoint"})
|
||||
if supported & climate.ClimateEntityFeature.TARGET_TEMPERATURE_RANGE:
|
||||
properties.append({"name": "lowerSetpoint"})
|
||||
properties.append({"name": "upperSetpoint"})
|
||||
return properties
|
||||
|
||||
def properties_proactively_reported(self) -> bool:
|
||||
|
|
|
@ -224,9 +224,20 @@ class ReportedProperties:
|
|||
|
||||
def assert_equal(self, namespace, name, value):
|
||||
"""Assert a property is equal to a given value."""
|
||||
prop_set = None
|
||||
prop_count = 0
|
||||
for prop in self.properties:
|
||||
if prop["namespace"] == namespace and prop["name"] == name:
|
||||
assert prop["value"] == value
|
||||
return prop
|
||||
prop_set = prop
|
||||
prop_count += 1
|
||||
|
||||
if prop_count > 1:
|
||||
pytest.fail(
|
||||
f"property {namespace}:{name} more than once in {self.properties!r}"
|
||||
)
|
||||
|
||||
if prop_set:
|
||||
return prop_set
|
||||
|
||||
pytest.fail(f"property {namespace}:{name} not in {self.properties!r}")
|
||||
|
|
Loading…
Reference in New Issue