mirror of
https://github.com/home-assistant/core.git
synced 2025-07-23 13:17:32 +00:00
Use shorthand attributes in venstar climate (#145294)
This commit is contained in:
parent
0cd93e7e65
commit
2e4226d7d3
@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
from __future__ import annotations
|
from __future__ import annotations
|
||||||
|
|
||||||
|
from typing import Any
|
||||||
|
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.climate import (
|
from homeassistant.components.climate import (
|
||||||
@ -111,8 +113,11 @@ class VenstarThermostat(VenstarEntity, ClimateEntity):
|
|||||||
|
|
||||||
_attr_fan_modes = [FAN_ON, FAN_AUTO]
|
_attr_fan_modes = [FAN_ON, FAN_AUTO]
|
||||||
_attr_hvac_modes = [HVACMode.HEAT, HVACMode.COOL, HVACMode.OFF, HVACMode.AUTO]
|
_attr_hvac_modes = [HVACMode.HEAT, HVACMode.COOL, HVACMode.OFF, HVACMode.AUTO]
|
||||||
|
_attr_preset_modes = [PRESET_NONE, PRESET_AWAY, HOLD_MODE_TEMPERATURE]
|
||||||
_attr_precision = PRECISION_HALVES
|
_attr_precision = PRECISION_HALVES
|
||||||
_attr_name = None
|
_attr_name = None
|
||||||
|
_attr_min_humidity = 0 # Hardcoded to 0 in API.
|
||||||
|
_attr_max_humidity = 60 # Hardcoded to 60 in API.
|
||||||
|
|
||||||
def __init__(
|
def __init__(
|
||||||
self,
|
self,
|
||||||
@ -155,12 +160,12 @@ class VenstarThermostat(VenstarEntity, ClimateEntity):
|
|||||||
return UnitOfTemperature.CELSIUS
|
return UnitOfTemperature.CELSIUS
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_temperature(self):
|
def current_temperature(self) -> float | None:
|
||||||
"""Return the current temperature."""
|
"""Return the current temperature."""
|
||||||
return self._client.get_indoor_temp()
|
return self._client.get_indoor_temp()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_humidity(self):
|
def current_humidity(self) -> float | None:
|
||||||
"""Return the current humidity."""
|
"""Return the current humidity."""
|
||||||
return self._client.get_indoor_humidity()
|
return self._client.get_indoor_humidity()
|
||||||
|
|
||||||
@ -187,14 +192,14 @@ class VenstarThermostat(VenstarEntity, ClimateEntity):
|
|||||||
return HVACAction.OFF
|
return HVACAction.OFF
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def fan_mode(self):
|
def fan_mode(self) -> str:
|
||||||
"""Return the current fan mode."""
|
"""Return the current fan mode."""
|
||||||
if self._client.fan == self._client.FAN_ON:
|
if self._client.fan == self._client.FAN_ON:
|
||||||
return FAN_ON
|
return FAN_ON
|
||||||
return FAN_AUTO
|
return FAN_AUTO
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def extra_state_attributes(self):
|
def extra_state_attributes(self) -> dict[str, Any]:
|
||||||
"""Return the optional state attributes."""
|
"""Return the optional state attributes."""
|
||||||
return {
|
return {
|
||||||
ATTR_FAN_STATE: self._client.fanstate,
|
ATTR_FAN_STATE: self._client.fanstate,
|
||||||
@ -202,7 +207,7 @@ class VenstarThermostat(VenstarEntity, ClimateEntity):
|
|||||||
}
|
}
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature(self):
|
def target_temperature(self) -> float | None:
|
||||||
"""Return the target temperature we try to reach."""
|
"""Return the target temperature we try to reach."""
|
||||||
if self._client.mode == self._client.MODE_HEAT:
|
if self._client.mode == self._client.MODE_HEAT:
|
||||||
return self._client.heattemp
|
return self._client.heattemp
|
||||||
@ -211,36 +216,26 @@ class VenstarThermostat(VenstarEntity, ClimateEntity):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature_low(self):
|
def target_temperature_low(self) -> float | None:
|
||||||
"""Return the lower bound temp if auto mode is on."""
|
"""Return the lower bound temp if auto mode is on."""
|
||||||
if self._client.mode == self._client.MODE_AUTO:
|
if self._client.mode == self._client.MODE_AUTO:
|
||||||
return self._client.heattemp
|
return self._client.heattemp
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_temperature_high(self):
|
def target_temperature_high(self) -> float | None:
|
||||||
"""Return the upper bound temp if auto mode is on."""
|
"""Return the upper bound temp if auto mode is on."""
|
||||||
if self._client.mode == self._client.MODE_AUTO:
|
if self._client.mode == self._client.MODE_AUTO:
|
||||||
return self._client.cooltemp
|
return self._client.cooltemp
|
||||||
return None
|
return None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def target_humidity(self):
|
def target_humidity(self) -> float | None:
|
||||||
"""Return the humidity we try to reach."""
|
"""Return the humidity we try to reach."""
|
||||||
return self._client.hum_setpoint
|
return self._client.hum_setpoint
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def min_humidity(self):
|
def preset_mode(self) -> str:
|
||||||
"""Return the minimum humidity. Hardcoded to 0 in API."""
|
|
||||||
return 0
|
|
||||||
|
|
||||||
@property
|
|
||||||
def max_humidity(self):
|
|
||||||
"""Return the maximum humidity. Hardcoded to 60 in API."""
|
|
||||||
return 60
|
|
||||||
|
|
||||||
@property
|
|
||||||
def preset_mode(self):
|
|
||||||
"""Return current preset."""
|
"""Return current preset."""
|
||||||
if self._client.away:
|
if self._client.away:
|
||||||
return PRESET_AWAY
|
return PRESET_AWAY
|
||||||
@ -248,11 +243,6 @@ class VenstarThermostat(VenstarEntity, ClimateEntity):
|
|||||||
return HOLD_MODE_TEMPERATURE
|
return HOLD_MODE_TEMPERATURE
|
||||||
return PRESET_NONE
|
return PRESET_NONE
|
||||||
|
|
||||||
@property
|
|
||||||
def preset_modes(self):
|
|
||||||
"""Return valid preset modes."""
|
|
||||||
return [PRESET_NONE, PRESET_AWAY, HOLD_MODE_TEMPERATURE]
|
|
||||||
|
|
||||||
def _set_operation_mode(self, operation_mode: HVACMode):
|
def _set_operation_mode(self, operation_mode: HVACMode):
|
||||||
"""Change the operation mode (internal)."""
|
"""Change the operation mode (internal)."""
|
||||||
if operation_mode == HVACMode.HEAT:
|
if operation_mode == HVACMode.HEAT:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user