Use climate enums in proliphix (#70730)

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

View File

@ -4,19 +4,11 @@ from __future__ import annotations
import proliphix import proliphix
import voluptuous as vol import voluptuous as vol
from homeassistant.components.climate import ( from homeassistant.components.climate import PLATFORM_SCHEMA, ClimateEntity
PLATFORM_SCHEMA,
ClimateEntity,
ClimateEntityFeature,
)
from homeassistant.components.climate.const import ( from homeassistant.components.climate.const import (
CURRENT_HVAC_COOL, ClimateEntityFeature,
CURRENT_HVAC_HEAT, HVACAction,
CURRENT_HVAC_IDLE, HVACMode,
CURRENT_HVAC_OFF,
HVAC_MODE_COOL,
HVAC_MODE_HEAT,
HVAC_MODE_OFF,
) )
from homeassistant.const import ( from homeassistant.const import (
ATTR_TEMPERATURE, ATTR_TEMPERATURE,
@ -114,28 +106,28 @@ class ProliphixThermostat(ClimateEntity):
return self._pdp.setback return self._pdp.setback
@property @property
def hvac_action(self): def hvac_action(self) -> HVACAction:
"""Return the current state of the thermostat.""" """Return the current state of the thermostat."""
state = self._pdp.hvac_state state = self._pdp.hvac_state
if state == 1: if state == 1:
return CURRENT_HVAC_OFF return HVACAction.OFF
if state in (3, 4, 5): if state in (3, 4, 5):
return CURRENT_HVAC_HEAT return HVACAction.HEATING
if state in (6, 7): if state in (6, 7):
return CURRENT_HVAC_COOL return HVACAction.COOLING
return CURRENT_HVAC_IDLE return HVACAction.IDLE
@property @property
def hvac_mode(self): def hvac_mode(self) -> HVACMode:
"""Return the current state of the thermostat.""" """Return the current state of the thermostat."""
if self._pdp.is_heating: if self._pdp.is_heating:
return HVAC_MODE_HEAT return HVACMode.HEAT
if self._pdp.is_cooling: if self._pdp.is_cooling:
return HVAC_MODE_COOL return HVACMode.COOL
return HVAC_MODE_OFF return HVACMode.OFF
@property @property
def hvac_modes(self): def hvac_modes(self) -> list[HVACMode]:
"""Return available HVAC modes.""" """Return available HVAC modes."""
return [] return []