Use climate enums in heatmiser (#70662)

This commit is contained in:
epenet 2022-04-26 09:57:20 +02:00 committed by GitHub
parent cb6320536f
commit 035635dbaf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,13 +6,8 @@ import logging
from heatmiserV3 import connection, heatmiser
import voluptuous as vol
from homeassistant.components.climate import (
HVAC_MODE_HEAT,
HVAC_MODE_OFF,
PLATFORM_SCHEMA,
ClimateEntity,
ClimateEntityFeature,
)
from homeassistant.components.climate import PLATFORM_SCHEMA, ClimateEntity
from homeassistant.components.climate.const import ClimateEntityFeature, HVACMode
from homeassistant.const import (
ATTR_TEMPERATURE,
CONF_HOST,
@ -76,6 +71,7 @@ def setup_platform(
class HeatmiserV3Thermostat(ClimateEntity):
"""Representation of a HeatmiserV3 thermostat."""
_attr_hvac_modes = [HVACMode.HEAT, HVACMode.OFF]
_attr_supported_features = ClimateEntityFeature.TARGET_TEMPERATURE
def __init__(self, therm, device, uh1):
@ -87,7 +83,7 @@ class HeatmiserV3Thermostat(ClimateEntity):
self._target_temperature = None
self._id = device
self.dcb = None
self._hvac_mode = HVAC_MODE_HEAT
self._attr_hvac_mode = HVACMode.HEAT
self._temperature_unit = None
@property
@ -100,22 +96,6 @@ class HeatmiserV3Thermostat(ClimateEntity):
"""Return the unit of measurement which this thermostat uses."""
return self._temperature_unit
@property
def hvac_mode(self) -> str:
"""Return hvac operation ie. heat, cool mode.
Need to be one of HVAC_MODE_*.
"""
return self._hvac_mode
@property
def hvac_modes(self) -> list[str]:
"""Return the list of available hvac operation modes.
Need to be a subset of HVAC_MODES.
"""
return [HVAC_MODE_HEAT, HVAC_MODE_OFF]
@property
def current_temperature(self):
"""Return the current temperature."""
@ -146,8 +126,8 @@ class HeatmiserV3Thermostat(ClimateEntity):
)
self._current_temperature = int(self.therm.get_floor_temp())
self._target_temperature = int(self.therm.get_target_temp())
self._hvac_mode = (
HVAC_MODE_OFF
self._attr_hvac_mode = (
HVACMode.OFF
if (int(self.therm.get_current_state()) == 0)
else HVAC_MODE_HEAT
else HVACMode.HEAT
)