Use climate enums in opentherm_gw (#70728)

This commit is contained in:
epenet 2022-04-26 10:12:03 +02:00 committed by GitHub
parent 8745401af5
commit 0a3f88d14c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,21 +1,17 @@
"""Support for OpenTherm Gateway climate devices."""
from __future__ import annotations
import logging
from pyotgw import vars as gw_vars
from homeassistant.components.climate import (
ENTITY_ID_FORMAT,
ClimateEntity,
ClimateEntityFeature,
)
from homeassistant.components.climate import ENTITY_ID_FORMAT, ClimateEntity
from homeassistant.components.climate.const import (
CURRENT_HVAC_COOL,
CURRENT_HVAC_HEAT,
CURRENT_HVAC_IDLE,
HVAC_MODE_COOL,
HVAC_MODE_HEAT,
PRESET_AWAY,
PRESET_NONE,
ClimateEntityFeature,
HVACAction,
HVACMode,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import (
@ -82,9 +78,9 @@ class OpenThermClimate(ClimateEntity):
self.temp_set_precision = options.get(CONF_SET_PRECISION)
self.temporary_ovrd_mode = options.get(CONF_TEMPORARY_OVRD_MODE, True)
self._available = False
self._current_operation = None
self._current_operation: HVACAction | None = None
self._current_temperature = None
self._hvac_mode = HVAC_MODE_HEAT
self._hvac_mode = HVACMode.HEAT
self._new_target_temperature = None
self._target_temperature = None
self._away_mode_a = None
@ -127,13 +123,13 @@ class OpenThermClimate(ClimateEntity):
flame_on = status[gw_vars.BOILER].get(gw_vars.DATA_SLAVE_FLAME_ON)
cooling_active = status[gw_vars.BOILER].get(gw_vars.DATA_SLAVE_COOLING_ACTIVE)
if ch_active and flame_on:
self._current_operation = CURRENT_HVAC_HEAT
self._hvac_mode = HVAC_MODE_HEAT
self._current_operation = HVACAction.HEATING
self._hvac_mode = HVACMode.HEAT
elif cooling_active:
self._current_operation = CURRENT_HVAC_COOL
self._hvac_mode = HVAC_MODE_COOL
self._current_operation = HVACAction.COOLING
self._hvac_mode = HVACMode.COOL
else:
self._current_operation = CURRENT_HVAC_IDLE
self._current_operation = HVACAction.IDLE
self._current_temperature = status[gw_vars.THERMOSTAT].get(
gw_vars.DATA_ROOM_TEMP
@ -216,21 +212,21 @@ class OpenThermClimate(ClimateEntity):
return TEMP_CELSIUS
@property
def hvac_action(self):
def hvac_action(self) -> HVACAction | None:
"""Return current HVAC operation."""
return self._current_operation
@property
def hvac_mode(self):
def hvac_mode(self) -> HVACMode:
"""Return current HVAC mode."""
return self._hvac_mode
@property
def hvac_modes(self):
def hvac_modes(self) -> list[HVACMode]:
"""Return available HVAC modes."""
return []
def set_hvac_mode(self, hvac_mode):
def set_hvac_mode(self, hvac_mode: HVACMode) -> None:
"""Set the HVAC mode."""
_LOGGER.warning("Changing HVAC mode is not supported")