mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 01:37:08 +00:00
Use shorthand attributes in melissa climate (#145286)
This commit is contained in:
parent
ed2024e67a
commit
99f91003d8
@ -57,6 +57,7 @@ async def async_setup_platform(
|
||||
class MelissaClimate(ClimateEntity):
|
||||
"""Representation of a Melissa Climate device."""
|
||||
|
||||
_attr_fan_modes = FAN_MODES
|
||||
_attr_hvac_modes = OP_MODES
|
||||
_attr_supported_features = (
|
||||
ClimateEntityFeature.FAN_MODE
|
||||
@ -64,11 +65,14 @@ class MelissaClimate(ClimateEntity):
|
||||
| ClimateEntityFeature.TURN_OFF
|
||||
| ClimateEntityFeature.TURN_ON
|
||||
)
|
||||
_attr_target_temperature_step = PRECISION_WHOLE
|
||||
_attr_temperature_unit = UnitOfTemperature.CELSIUS
|
||||
_attr_min_temp = 16
|
||||
_attr_max_temp = 30
|
||||
|
||||
def __init__(self, api, serial_number, init_data):
|
||||
"""Initialize the climate device."""
|
||||
self._name = init_data["name"]
|
||||
self._attr_name = init_data["name"]
|
||||
self._api = api
|
||||
self._serial_number = serial_number
|
||||
self._data = init_data["controller_log"]
|
||||
@ -76,36 +80,26 @@ class MelissaClimate(ClimateEntity):
|
||||
self._cur_settings = None
|
||||
|
||||
@property
|
||||
def name(self):
|
||||
"""Return the name of the thermostat, if any."""
|
||||
return self._name
|
||||
|
||||
@property
|
||||
def fan_mode(self):
|
||||
def fan_mode(self) -> str | None:
|
||||
"""Return the current fan mode."""
|
||||
if self._cur_settings is not None:
|
||||
return self.melissa_fan_to_hass(self._cur_settings[self._api.FAN])
|
||||
return None
|
||||
|
||||
@property
|
||||
def current_temperature(self):
|
||||
def current_temperature(self) -> float | None:
|
||||
"""Return the current temperature."""
|
||||
if self._data:
|
||||
return self._data[self._api.TEMP]
|
||||
return None
|
||||
|
||||
@property
|
||||
def current_humidity(self):
|
||||
def current_humidity(self) -> float | None:
|
||||
"""Return the current humidity value."""
|
||||
if self._data:
|
||||
return self._data[self._api.HUMIDITY]
|
||||
return None
|
||||
|
||||
@property
|
||||
def target_temperature_step(self):
|
||||
"""Return the supported step of target temperature."""
|
||||
return PRECISION_WHOLE
|
||||
|
||||
@property
|
||||
def hvac_mode(self) -> HVACMode | None:
|
||||
"""Return the current operation mode."""
|
||||
@ -123,27 +117,12 @@ class MelissaClimate(ClimateEntity):
|
||||
return self.melissa_op_to_hass(self._cur_settings[self._api.MODE])
|
||||
|
||||
@property
|
||||
def fan_modes(self):
|
||||
"""List of available fan modes."""
|
||||
return FAN_MODES
|
||||
|
||||
@property
|
||||
def target_temperature(self):
|
||||
def target_temperature(self) -> float | None:
|
||||
"""Return the temperature we try to reach."""
|
||||
if self._cur_settings is None:
|
||||
return None
|
||||
return self._cur_settings[self._api.TEMP]
|
||||
|
||||
@property
|
||||
def min_temp(self):
|
||||
"""Return the minimum supported temperature for the thermostat."""
|
||||
return 16
|
||||
|
||||
@property
|
||||
def max_temp(self):
|
||||
"""Return the maximum supported temperature for the thermostat."""
|
||||
return 30
|
||||
|
||||
async def async_set_temperature(self, **kwargs: Any) -> None:
|
||||
"""Set new target temperature."""
|
||||
temp = kwargs.get(ATTR_TEMPERATURE)
|
||||
|
Loading…
x
Reference in New Issue
Block a user