diff --git a/custom_components/versatile_thermostat/underlyings.py b/custom_components/versatile_thermostat/underlyings.py index bb40fc3..d0ad3e5 100644 --- a/custom_components/versatile_thermostat/underlyings.py +++ b/custom_components/versatile_thermostat/underlyings.py @@ -632,22 +632,20 @@ async def set_temperature(self, temperature, max_temp, min_temp): # Issue 508 we have to take care of service set_temperature or set_range target_temp = self.cap_sent_value(temperature) - if ( - ClimateEntityFeature.TARGET_TEMPERATURE_RANGE - in self._underlying_climate.supported_features - ): - data = { - ATTR_ENTITY_ID: self._entity_id, - "target_temp_high": target_temp, - "target_temp_low": target_temp, - # issue 518 - we should send also the target temperature, even in TARGET RANGE - "temperature": target_temp, - } - else: - data = { - ATTR_ENTITY_ID: self._entity_id, - "temperature": target_temp, - } + data = { + ATTR_ENTITY_ID: self._entity_id, + } + # Issue 807 add TARGET_TEMPERATURE only if in the features + if ClimateEntityFeature.TARGET_TEMPERATURE_RANGE in self._underlying_climate.supported_features: + data.update( + { + "target_temp_high": target_temp, + "target_temp_low": target_temp, + } + ) + + if ClimateEntityFeature.TARGET_TEMPERATURE in self._underlying_climate.supported_features: + data["temperature"] = target_temp await self._hass.services.async_call( CLIMATE_DOMAIN, diff --git a/tests/test_overclimate.py b/tests/test_overclimate.py index 53da490..30c27ce 100644 --- a/tests/test_overclimate.py +++ b/tests/test_overclimate.py @@ -580,7 +580,6 @@ async def test_bug_508( # "temperature": 17.5, "target_temp_high": 10, "target_temp_low": 10, - "temperature": 10, }, ), ] @@ -604,7 +603,6 @@ async def test_bug_508( "entity_id": "climate.mock_climate", "target_temp_high": 31, "target_temp_low": 31, - "temperature": 31, }, ), ]