Use climate enums in ambiclimate (#70625)
This commit is contained in:
parent
54fed9ee7b
commit
6988b0725d
1 changed files with 6 additions and 6 deletions
|
@ -8,8 +8,8 @@ from typing import Any
|
||||||
import ambiclimate
|
import ambiclimate
|
||||||
import voluptuous as vol
|
import voluptuous as vol
|
||||||
|
|
||||||
from homeassistant.components.climate import ClimateEntity, ClimateEntityFeature
|
from homeassistant.components.climate import ClimateEntity
|
||||||
from homeassistant.components.climate.const import HVAC_MODE_HEAT, HVAC_MODE_OFF
|
from homeassistant.components.climate.const import ClimateEntityFeature, HVACMode
|
||||||
from homeassistant.config_entries import ConfigEntry
|
from homeassistant.config_entries import ConfigEntry
|
||||||
from homeassistant.const import (
|
from homeassistant.const import (
|
||||||
ATTR_NAME,
|
ATTR_NAME,
|
||||||
|
@ -149,7 +149,7 @@ class AmbiclimateEntity(ClimateEntity):
|
||||||
_attr_temperature_unit = TEMP_CELSIUS
|
_attr_temperature_unit = TEMP_CELSIUS
|
||||||
_attr_target_temperature_step = 1
|
_attr_target_temperature_step = 1
|
||||||
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
|
||||||
_attr_hvac_modes = [HVAC_MODE_HEAT, HVAC_MODE_OFF]
|
_attr_hvac_modes = [HVACMode.HEAT, HVACMode.OFF]
|
||||||
|
|
||||||
def __init__(self, heater, store):
|
def __init__(self, heater, store):
|
||||||
"""Initialize the thermostat."""
|
"""Initialize the thermostat."""
|
||||||
|
@ -171,10 +171,10 @@ class AmbiclimateEntity(ClimateEntity):
|
||||||
|
|
||||||
async def async_set_hvac_mode(self, hvac_mode: str) -> None:
|
async def async_set_hvac_mode(self, hvac_mode: str) -> None:
|
||||||
"""Set new target hvac mode."""
|
"""Set new target hvac mode."""
|
||||||
if hvac_mode == HVAC_MODE_HEAT:
|
if hvac_mode == HVACMode.HEAT:
|
||||||
await self._heater.turn_on()
|
await self._heater.turn_on()
|
||||||
return
|
return
|
||||||
if hvac_mode == HVAC_MODE_OFF:
|
if hvac_mode == HVACMode.OFF:
|
||||||
await self._heater.turn_off()
|
await self._heater.turn_off()
|
||||||
|
|
||||||
async def async_update(self) -> None:
|
async def async_update(self) -> None:
|
||||||
|
@ -195,5 +195,5 @@ class AmbiclimateEntity(ClimateEntity):
|
||||||
self._attr_current_temperature = data.get("temperature")
|
self._attr_current_temperature = data.get("temperature")
|
||||||
self._attr_current_humidity = data.get("humidity")
|
self._attr_current_humidity = data.get("humidity")
|
||||||
self._attr_hvac_mode = (
|
self._attr_hvac_mode = (
|
||||||
HVAC_MODE_HEAT if data.get("power", "").lower() == "on" else HVAC_MODE_OFF
|
HVACMode.HEAT if data.get("power", "").lower() == "on" else HVACMode.OFF
|
||||||
)
|
)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue