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