[climate] Tweak evohome migration (#25187)
* de-lint * use _evo_tcs instead of _evo_device for TCS * add hvac_action to zones, remove target_temp from controller * fix incorrect hvac_action * de-lint
This commit is contained in:
parent
ac91423d71
commit
2bac24fbb7
1 changed files with 25 additions and 41 deletions
|
@ -9,6 +9,7 @@ import evohomeclient2
|
||||||
from homeassistant.components.climate import ClimateDevice
|
from homeassistant.components.climate import ClimateDevice
|
||||||
from homeassistant.components.climate.const import (
|
from homeassistant.components.climate.const import (
|
||||||
HVAC_MODE_HEAT, HVAC_MODE_AUTO, HVAC_MODE_OFF,
|
HVAC_MODE_HEAT, HVAC_MODE_AUTO, HVAC_MODE_OFF,
|
||||||
|
CURRENT_HVAC_HEAT, CURRENT_HVAC_IDLE, CURRENT_HVAC_OFF,
|
||||||
PRESET_AWAY, PRESET_ECO, PRESET_HOME,
|
PRESET_AWAY, PRESET_ECO, PRESET_HOME,
|
||||||
SUPPORT_TARGET_TEMPERATURE, SUPPORT_PRESET_MODE)
|
SUPPORT_TARGET_TEMPERATURE, SUPPORT_PRESET_MODE)
|
||||||
from homeassistant.const import PRECISION_TENTHS
|
from homeassistant.const import PRECISION_TENTHS
|
||||||
|
@ -183,6 +184,17 @@ class EvoZone(EvoClimateDevice):
|
||||||
is_off = self.target_temperature <= self.min_temp
|
is_off = self.target_temperature <= self.min_temp
|
||||||
return HVAC_MODE_OFF if is_off else HVAC_MODE_HEAT
|
return HVAC_MODE_OFF if is_off else HVAC_MODE_HEAT
|
||||||
|
|
||||||
|
@property
|
||||||
|
def hvac_action(self) -> Optional[str]:
|
||||||
|
"""Return the current running hvac operation if supported."""
|
||||||
|
if self._evo_tcs.systemModeStatus['mode'] == EVO_HEATOFF:
|
||||||
|
return CURRENT_HVAC_OFF
|
||||||
|
if self.target_temperature <= self.min_temp:
|
||||||
|
return CURRENT_HVAC_OFF
|
||||||
|
if self.target_temperature <= self.current_temperature:
|
||||||
|
return CURRENT_HVAC_HEAT
|
||||||
|
return CURRENT_HVAC_IDLE
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def current_temperature(self) -> Optional[float]:
|
def current_temperature(self) -> Optional[float]:
|
||||||
"""Return the current temperature of the evohome Zone."""
|
"""Return the current temperature of the evohome Zone."""
|
||||||
|
@ -221,7 +233,7 @@ class EvoZone(EvoClimateDevice):
|
||||||
return self._evo_device.setpointCapabilities['maxHeatSetpoint']
|
return self._evo_device.setpointCapabilities['maxHeatSetpoint']
|
||||||
|
|
||||||
def set_temperature(self, **kwargs) -> None:
|
def set_temperature(self, **kwargs) -> None:
|
||||||
"""Set a new target temperature for an hour."""
|
"""Set a new target temperature."""
|
||||||
until = kwargs.get('until')
|
until = kwargs.get('until')
|
||||||
if until:
|
if until:
|
||||||
until = parse_datetime(until)
|
until = parse_datetime(until)
|
||||||
|
@ -268,7 +280,7 @@ class EvoController(EvoClimateDevice):
|
||||||
@property
|
@property
|
||||||
def hvac_mode(self) -> str:
|
def hvac_mode(self) -> str:
|
||||||
"""Return the current operating mode of the evohome Controller."""
|
"""Return the current operating mode of the evohome Controller."""
|
||||||
tcs_mode = self._evo_device.systemModeStatus['mode']
|
tcs_mode = self._evo_tcs.systemModeStatus['mode']
|
||||||
return HVAC_MODE_OFF if tcs_mode == EVO_HEATOFF else HVAC_MODE_HEAT
|
return HVAC_MODE_OFF if tcs_mode == EVO_HEATOFF else HVAC_MODE_HEAT
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -278,44 +290,18 @@ class EvoController(EvoClimateDevice):
|
||||||
Controllers do not have a current temp, but one is expected by HA.
|
Controllers do not have a current temp, but one is expected by HA.
|
||||||
"""
|
"""
|
||||||
temps = [z.temperatureStatus['temperature']
|
temps = [z.temperatureStatus['temperature']
|
||||||
for z in self._evo_device.zones.values()
|
for z in self._evo_tcs.zones.values()
|
||||||
if z.temperatureStatus['isAvailable']]
|
if z.temperatureStatus['isAvailable']]
|
||||||
return round(sum(temps) / len(temps), 1) if temps else None
|
return round(sum(temps) / len(temps), 1) if temps else None
|
||||||
|
|
||||||
@property
|
|
||||||
def target_temperature(self) -> Optional[float]:
|
|
||||||
"""Return the average target temperature of the heating Zones.
|
|
||||||
|
|
||||||
Controllers do not have a target temp, but one is expected by HA.
|
|
||||||
"""
|
|
||||||
temps = [z.setpointStatus['targetHeatTemperature']
|
|
||||||
for z in self._evo_device.zones.values()]
|
|
||||||
return round(sum(temps) / len(temps), 1) if temps else None
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def preset_mode(self) -> Optional[str]:
|
def preset_mode(self) -> Optional[str]:
|
||||||
"""Return the current preset mode, e.g., home, away, temp."""
|
"""Return the current preset mode, e.g., home, away, temp."""
|
||||||
return TCS_PRESET_TO_HA.get(self._evo_device.systemModeStatus['mode'])
|
return TCS_PRESET_TO_HA.get(self._evo_tcs.systemModeStatus['mode'])
|
||||||
|
|
||||||
@property
|
def set_temperature(self, **kwargs) -> None:
|
||||||
def min_temp(self) -> float:
|
"""The evohome Controller doesn't have a targert temperature."""
|
||||||
"""Return the minimum target temperature of the heating Zones.
|
return
|
||||||
|
|
||||||
Controllers do not have a min target temp, but one is required by HA.
|
|
||||||
"""
|
|
||||||
temps = [z.setpointCapabilities['minHeatSetpoint']
|
|
||||||
for z in self._evo_device.zones.values()]
|
|
||||||
return min(temps) if temps else 5
|
|
||||||
|
|
||||||
@property
|
|
||||||
def max_temp(self) -> float:
|
|
||||||
"""Return the maximum target temperature of the heating Zones.
|
|
||||||
|
|
||||||
Controllers do not have a max target temp, but one is required by HA.
|
|
||||||
"""
|
|
||||||
temps = [z.setpointCapabilities['maxHeatSetpoint']
|
|
||||||
for z in self._evo_device.zones.values()]
|
|
||||||
return max(temps) if temps else 35
|
|
||||||
|
|
||||||
def set_hvac_mode(self, hvac_mode: str) -> None:
|
def set_hvac_mode(self, hvac_mode: str) -> None:
|
||||||
"""Set an operating mode for the Controller."""
|
"""Set an operating mode for the Controller."""
|
||||||
|
@ -330,7 +316,7 @@ class EvoController(EvoClimateDevice):
|
||||||
|
|
||||||
def update(self) -> None:
|
def update(self) -> None:
|
||||||
"""Get the latest state data."""
|
"""Get the latest state data."""
|
||||||
pass
|
return
|
||||||
|
|
||||||
|
|
||||||
class EvoThermostat(EvoZone):
|
class EvoThermostat(EvoZone):
|
||||||
|
@ -344,8 +330,6 @@ class EvoThermostat(EvoZone):
|
||||||
super().__init__(evo_broker, evo_device)
|
super().__init__(evo_broker, evo_device)
|
||||||
|
|
||||||
self._name = evo_broker.tcs.location.name
|
self._name = evo_broker.tcs.location.name
|
||||||
self._icon = 'mdi:radiator'
|
|
||||||
|
|
||||||
self._preset_modes = [PRESET_AWAY, PRESET_ECO]
|
self._preset_modes = [PRESET_AWAY, PRESET_ECO]
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
@ -353,8 +337,8 @@ class EvoThermostat(EvoZone):
|
||||||
"""Return the device-specific state attributes."""
|
"""Return the device-specific state attributes."""
|
||||||
status = super().device_state_attributes['status']
|
status = super().device_state_attributes['status']
|
||||||
|
|
||||||
status['systemModeStatus'] = getattr(self._evo_tcs, 'systemModeStatus')
|
status['systemModeStatus'] = self._evo_tcs.systemModeStatus
|
||||||
status['activeFaults'] += getattr(self._evo_tcs, 'activeFaults')
|
status['activeFaults'] += self._evo_tcs.activeFaults
|
||||||
|
|
||||||
return {'status': status}
|
return {'status': status}
|
||||||
|
|
||||||
|
@ -369,8 +353,8 @@ class EvoThermostat(EvoZone):
|
||||||
@property
|
@property
|
||||||
def preset_mode(self) -> Optional[str]:
|
def preset_mode(self) -> Optional[str]:
|
||||||
"""Return the current preset mode, e.g., home, away, temp."""
|
"""Return the current preset mode, e.g., home, away, temp."""
|
||||||
if self._evo_tcs.systemModeStatus['mode'] == EVO_AUTOECO:
|
if self._evo_tcs.systemModeStatus['mode'] == EVO_AUTOECO and \
|
||||||
if self._evo_device.setpointStatus['setpointMode'] == EVO_FOLLOW:
|
self._evo_device.setpointStatus['setpointMode'] == EVO_FOLLOW:
|
||||||
return PRESET_ECO
|
return PRESET_ECO
|
||||||
|
|
||||||
return super().preset_mode
|
return super().preset_mode
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue