mirror of
https://github.com/home-assistant/core.git
synced 2025-07-16 09:47:13 +00:00
Use climate enums in spider (#70740)
This commit is contained in:
parent
f2d5433339
commit
f85e225227
@ -1,10 +1,6 @@
|
|||||||
"""Support for Spider thermostats."""
|
"""Support for Spider thermostats."""
|
||||||
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
|
from homeassistant.components.climate import ClimateEntity
|
||||||
from homeassistant.components.climate.const import (
|
from homeassistant.components.climate.const import ClimateEntityFeature, HVACMode
|
||||||
HVAC_MODE_COOL,
|
|
||||||
HVAC_MODE_HEAT,
|
|
||||||
HVAC_MODE_OFF,
|
|
||||||
)
|
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
from homeassistant.const import ATTR_TEMPERATURE, TEMP_CELSIUS
|
||||||
from homeassistant.core import HomeAssistant
|
from homeassistant.core import HomeAssistant
|
||||||
@ -14,9 +10,9 @@ from homeassistant.helpers.entity_platform import AddEntitiesCallback
|
|||||||
from .const import DOMAIN
|
from .const import DOMAIN
|
||||||
|
|
||||||
HA_STATE_TO_SPIDER = {
|
HA_STATE_TO_SPIDER = {
|
||||||
HVAC_MODE_COOL: "Cool",
|
HVACMode.COOL: "Cool",
|
||||||
HVAC_MODE_HEAT: "Heat",
|
HVACMode.HEAT: "Heat",
|
||||||
HVAC_MODE_OFF: "Idle",
|
HVACMode.OFF: "Idle",
|
||||||
}
|
}
|
||||||
|
|
||||||
SPIDER_STATE_TO_HA = {value: key for key, value in HA_STATE_TO_SPIDER.items()}
|
SPIDER_STATE_TO_HA = {value: key for key, value in HA_STATE_TO_SPIDER.items()}
|
||||||
@ -110,12 +106,12 @@ class SpiderThermostat(ClimateEntity):
|
|||||||
return self.thermostat.maximum_temperature
|
return self.thermostat.maximum_temperature
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hvac_mode(self):
|
def hvac_mode(self) -> HVACMode:
|
||||||
"""Return current operation ie. heat, cool, idle."""
|
"""Return current operation ie. heat, cool, idle."""
|
||||||
return SPIDER_STATE_TO_HA[self.thermostat.operation_mode]
|
return SPIDER_STATE_TO_HA[self.thermostat.operation_mode]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def hvac_modes(self):
|
def hvac_modes(self) -> list[HVACMode]:
|
||||||
"""Return the list of available operation modes."""
|
"""Return the list of available operation modes."""
|
||||||
return self.support_hvac
|
return self.support_hvac
|
||||||
|
|
||||||
@ -126,7 +122,7 @@ class SpiderThermostat(ClimateEntity):
|
|||||||
|
|
||||||
self.thermostat.set_temperature(temperature)
|
self.thermostat.set_temperature(temperature)
|
||||||
|
|
||||||
def set_hvac_mode(self, hvac_mode):
|
def set_hvac_mode(self, hvac_mode: HVACMode) -> None:
|
||||||
"""Set new target operation mode."""
|
"""Set new target operation mode."""
|
||||||
self.thermostat.set_operation_mode(HA_STATE_TO_SPIDER.get(hvac_mode))
|
self.thermostat.set_operation_mode(HA_STATE_TO_SPIDER.get(hvac_mode))
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user