diff --git a/homeassistant/components/alexa/capabilities.py b/homeassistant/components/alexa/capabilities.py index 502912ee8de..ab3bd8591fd 100644 --- a/homeassistant/components/alexa/capabilities.py +++ b/homeassistant/components/alexa/capabilities.py @@ -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: diff --git a/tests/components/alexa/test_common.py b/tests/components/alexa/test_common.py index d3ea1bcda3e..8c9cea526b6 100644 --- a/tests/components/alexa/test_common.py +++ b/tests/components/alexa/test_common.py @@ -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}")