From de24d00a1c04a0714619ca71b052733f9cefc685 Mon Sep 17 00:00:00 2001 From: Franck Nijhof Date: Thu, 17 Feb 2022 14:11:47 +0100 Subject: [PATCH] Use min/max/step from thermostat in Plugwise (#66618) --- homeassistant/components/plugwise/climate.py | 8 ++++++-- .../plugwise/fixtures/anna_heatpump/all_data.json | 3 +++ tests/components/plugwise/test_climate.py | 3 +++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/homeassistant/components/plugwise/climate.py b/homeassistant/components/plugwise/climate.py index abf08b70dad..c4c444441c2 100644 --- a/homeassistant/components/plugwise/climate.py +++ b/homeassistant/components/plugwise/climate.py @@ -51,8 +51,6 @@ async def async_setup_entry( class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity): """Representation of an Plugwise thermostat.""" - _attr_max_temp = DEFAULT_MAX_TEMP - _attr_min_temp = DEFAULT_MIN_TEMP _attr_temperature_unit = TEMP_CELSIUS def __init__( @@ -79,6 +77,12 @@ class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity): if self.device.get("available_schedules") != ["None"]: self._attr_hvac_modes.append(HVAC_MODE_AUTO) + self._attr_min_temp = self.device.get("lower_bound", DEFAULT_MIN_TEMP) + self._attr_max_temp = self.device.get("upper_bound", DEFAULT_MAX_TEMP) + if resolution := self.device.get("resolution"): + # Ensure we don't drop below 0.1 + self._attr_target_temperature_step = max(resolution, 0.1) + @property def current_temperature(self) -> float | None: """Return the current temperature.""" diff --git a/tests/components/plugwise/fixtures/anna_heatpump/all_data.json b/tests/components/plugwise/fixtures/anna_heatpump/all_data.json index 017d1ce41e8..ee0f60d92ce 100644 --- a/tests/components/plugwise/fixtures/anna_heatpump/all_data.json +++ b/tests/components/plugwise/fixtures/anna_heatpump/all_data.json @@ -53,6 +53,9 @@ "model": "Anna", "name": "Anna", "vendor": "Plugwise", + "lower_bound": 5, + "upper_bound": 31, + "resolution": 0.1, "preset_modes": ["no_frost", "home", "away", "asleep", "vacation"], "active_preset": "home", "presets": { diff --git a/tests/components/plugwise/test_climate.py b/tests/components/plugwise/test_climate.py index c40ad32c078..1a8b7815be4 100644 --- a/tests/components/plugwise/test_climate.py +++ b/tests/components/plugwise/test_climate.py @@ -166,6 +166,9 @@ async def test_anna_climate_entity_attributes( assert state.attributes["preset_mode"] == "home" assert state.attributes["supported_features"] == 17 assert state.attributes["temperature"] == 21.0 + assert state.attributes["min_temp"] == 5.0 + assert state.attributes["max_temp"] == 31.0 + assert state.attributes["target_temp_step"] == 0.1 async def test_anna_climate_entity_climate_changes(