Use min/max/step from thermostat in Plugwise (#66618)

This commit is contained in:
Franck Nijhof 2022-02-17 14:11:47 +01:00 committed by GitHub
parent 1a9fda96c3
commit de24d00a1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 2 deletions

View File

@ -51,8 +51,6 @@ async def async_setup_entry(
class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity): class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity):
"""Representation of an Plugwise thermostat.""" """Representation of an Plugwise thermostat."""
_attr_max_temp = DEFAULT_MAX_TEMP
_attr_min_temp = DEFAULT_MIN_TEMP
_attr_temperature_unit = TEMP_CELSIUS _attr_temperature_unit = TEMP_CELSIUS
def __init__( def __init__(
@ -79,6 +77,12 @@ class PlugwiseClimateEntity(PlugwiseEntity, ClimateEntity):
if self.device.get("available_schedules") != ["None"]: if self.device.get("available_schedules") != ["None"]:
self._attr_hvac_modes.append(HVAC_MODE_AUTO) 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 @property
def current_temperature(self) -> float | None: def current_temperature(self) -> float | None:
"""Return the current temperature.""" """Return the current temperature."""

View File

@ -53,6 +53,9 @@
"model": "Anna", "model": "Anna",
"name": "Anna", "name": "Anna",
"vendor": "Plugwise", "vendor": "Plugwise",
"lower_bound": 5,
"upper_bound": 31,
"resolution": 0.1,
"preset_modes": ["no_frost", "home", "away", "asleep", "vacation"], "preset_modes": ["no_frost", "home", "away", "asleep", "vacation"],
"active_preset": "home", "active_preset": "home",
"presets": { "presets": {

View File

@ -166,6 +166,9 @@ async def test_anna_climate_entity_attributes(
assert state.attributes["preset_mode"] == "home" assert state.attributes["preset_mode"] == "home"
assert state.attributes["supported_features"] == 17 assert state.attributes["supported_features"] == 17
assert state.attributes["temperature"] == 21.0 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( async def test_anna_climate_entity_climate_changes(