Fix Ecobee HVAC action + available presets (#25488)

* Fix Ecobee HVAC action + available presets

* Update python-ecobee-api to 0.0.21

* Include proper operation list.

* Allows pass on preset to set_climate_hold

* Remove aux heat as a preset

* Fix test
This commit is contained in:
Paulus Schoutsen 2019-07-30 15:25:03 -07:00 committed by GitHub
parent f8bb0e1229
commit 0257fe0375
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 62 additions and 24 deletions

View File

@ -11,8 +11,9 @@ from homeassistant.components.climate.const import (
DOMAIN, HVAC_MODE_COOL, HVAC_MODE_HEAT, HVAC_MODE_AUTO, HVAC_MODE_OFF, DOMAIN, HVAC_MODE_COOL, HVAC_MODE_HEAT, HVAC_MODE_AUTO, HVAC_MODE_OFF,
ATTR_TARGET_TEMP_LOW, ATTR_TARGET_TEMP_HIGH, SUPPORT_TARGET_TEMPERATURE, ATTR_TARGET_TEMP_LOW, ATTR_TARGET_TEMP_HIGH, SUPPORT_TARGET_TEMPERATURE,
SUPPORT_AUX_HEAT, SUPPORT_TARGET_TEMPERATURE_RANGE, SUPPORT_FAN_MODE, SUPPORT_AUX_HEAT, SUPPORT_TARGET_TEMPERATURE_RANGE, SUPPORT_FAN_MODE,
PRESET_AWAY, FAN_AUTO, FAN_ON, CURRENT_HVAC_OFF, CURRENT_HVAC_HEAT, PRESET_AWAY, FAN_AUTO, FAN_ON, CURRENT_HVAC_IDLE, CURRENT_HVAC_HEAT,
CURRENT_HVAC_COOL, SUPPORT_PRESET_MODE, PRESET_NONE CURRENT_HVAC_COOL, SUPPORT_PRESET_MODE, PRESET_NONE, CURRENT_HVAC_FAN,
CURRENT_HVAC_DRY,
) )
from homeassistant.const import ( from homeassistant.const import (
ATTR_ENTITY_ID, STATE_ON, ATTR_TEMPERATURE, TEMP_FAHRENHEIT) ATTR_ENTITY_ID, STATE_ON, ATTR_TEMPERATURE, TEMP_FAHRENHEIT)
@ -27,7 +28,6 @@ ATTR_RESUME_ALL = 'resume_all'
DEFAULT_RESUME_ALL = False DEFAULT_RESUME_ALL = False
PRESET_TEMPERATURE = 'temp' PRESET_TEMPERATURE = 'temp'
PRESET_VACATION = 'vacation' PRESET_VACATION = 'vacation'
PRESET_AUX_HEAT_ONLY = 'aux_heat_only'
PRESET_HOLD_NEXT_TRANSITION = 'next_transition' PRESET_HOLD_NEXT_TRANSITION = 'next_transition'
PRESET_HOLD_INDEFINITE = 'indefinite' PRESET_HOLD_INDEFINITE = 'indefinite'
AWAY_MODE = 'awayMode' AWAY_MODE = 'awayMode'
@ -43,6 +43,25 @@ ECOBEE_HVAC_TO_HASS = collections.OrderedDict([
('auxHeatOnly', HVAC_MODE_HEAT), ('auxHeatOnly', HVAC_MODE_HEAT),
]) ])
ECOBEE_HVAC_ACTION_TO_HASS = {
# Map to None if we do not know how to represent.
"heatPump": CURRENT_HVAC_HEAT,
"heatPump2": CURRENT_HVAC_HEAT,
"heatPump3": CURRENT_HVAC_HEAT,
"compCool1": CURRENT_HVAC_COOL,
"compCool2": CURRENT_HVAC_COOL,
"auxHeat1": CURRENT_HVAC_HEAT,
"auxHeat2": CURRENT_HVAC_HEAT,
"auxHeat3": CURRENT_HVAC_HEAT,
"fan": CURRENT_HVAC_FAN,
"humidifier": None,
"dehumidifier": CURRENT_HVAC_DRY,
"ventilator": CURRENT_HVAC_FAN,
"economizer": CURRENT_HVAC_FAN,
"compHotWater": None,
"auxHotWater": None,
}
PRESET_TO_ECOBEE_HOLD = { PRESET_TO_ECOBEE_HOLD = {
PRESET_HOLD_NEXT_TRANSITION: 'nextTransition', PRESET_HOLD_NEXT_TRANSITION: 'nextTransition',
PRESET_HOLD_INDEFINITE: 'indefinite', PRESET_HOLD_INDEFINITE: 'indefinite',
@ -51,8 +70,11 @@ PRESET_TO_ECOBEE_HOLD = {
PRESET_MODES = [ PRESET_MODES = [
PRESET_NONE, PRESET_NONE,
PRESET_AWAY, PRESET_AWAY,
PRESET_TEMPERATURE,
PRESET_HOME, PRESET_HOME,
PRESET_SLEEP PRESET_SLEEP,
PRESET_HOLD_NEXT_TRANSITION,
PRESET_HOLD_INDEFINITE
] ]
SERVICE_SET_FAN_MIN_ON_TIME = 'ecobee_set_fan_min_on_time' SERVICE_SET_FAN_MIN_ON_TIME = 'ecobee_set_fan_min_on_time'
@ -140,9 +162,16 @@ class Thermostat(ClimateDevice):
self.hold_temp = hold_temp self.hold_temp = hold_temp
self.vacation = None self.vacation = None
self._climate_list = self.climate_list self._climate_list = self.climate_list
self._operation_list = [
HVAC_MODE_AUTO, HVAC_MODE_HEAT, HVAC_MODE_COOL, HVAC_MODE_OFF self._operation_list = []
] if self.thermostat['settings']['heatStages']:
self._operation_list.append(HVAC_MODE_HEAT)
if self.thermostat['settings']['coolStages']:
self._operation_list.append(HVAC_MODE_COOL)
if len(self._operation_list) == 2:
self._operation_list.insert(0, HVAC_MODE_AUTO)
self._operation_list.append(HVAC_MODE_OFF)
self._fan_modes = [FAN_AUTO, FAN_ON] self._fan_modes = [FAN_AUTO, FAN_ON]
self.update_without_throttle = False self.update_without_throttle = False
@ -247,9 +276,6 @@ class Thermostat(ClimateDevice):
self.vacation = event['name'] self.vacation = event['name']
return PRESET_VACATION return PRESET_VACATION
if self.is_aux_heat:
return PRESET_AUX_HEAT_ONLY
return None return None
@property @property
@ -277,18 +303,29 @@ class Thermostat(ClimateDevice):
@property @property
def hvac_action(self): def hvac_action(self):
"""Return current HVAC action.""" """Return current HVAC action.
status = self.thermostat['equipmentStatus']
operation = None
if status == '': Ecobee returns a CSV string with different equipment that is active.
operation = CURRENT_HVAC_OFF We are prioritizing any heating/cooling equipment, otherwase look at
elif 'Cool' in status: drying/fanning. Idle if nothing going on.
operation = CURRENT_HVAC_COOL
elif 'auxHeat' in status or 'heatPump' in status:
operation = CURRENT_HVAC_HEAT
return operation We are unable to map all actions to HA equivalents.
"""
if self.thermostat['equipmentStatus'] == "":
return CURRENT_HVAC_IDLE
actions = [
ECOBEE_HVAC_ACTION_TO_HASS[status] for status in
self.thermostat['equipmentStatus'].split(",")
if ECOBEE_HVAC_ACTION_TO_HASS[status] is not None
]
for action in (CURRENT_HVAC_HEAT, CURRENT_HVAC_COOL,
CURRENT_HVAC_DRY, CURRENT_HVAC_FAN):
if action in actions:
return action
return CURRENT_HVAC_IDLE
@property @property
def device_state_attributes(self): def device_state_attributes(self):
@ -332,13 +369,12 @@ class Thermostat(ClimateDevice):
self.thermostat_index, PRESET_TO_ECOBEE_HOLD[preset_mode], self.thermostat_index, PRESET_TO_ECOBEE_HOLD[preset_mode],
self.hold_preference()) self.hold_preference())
elif preset_mode is PRESET_NONE: elif preset_mode == PRESET_NONE:
self.data.ecobee.resume_program(self.thermostat_index) self.data.ecobee.resume_program(self.thermostat_index)
else: else:
self.data.ecobee.set_climate_hold( self.data.ecobee.set_climate_hold(
self.thermostat_index, preset_mode, self.hold_preference()) self.thermostat_index, preset_mode, self.hold_preference())
self.update_without_throttle = True
@property @property
def preset_modes(self): def preset_modes(self):

View File

@ -3,7 +3,7 @@
"name": "Ecobee", "name": "Ecobee",
"documentation": "https://www.home-assistant.io/components/ecobee", "documentation": "https://www.home-assistant.io/components/ecobee",
"requirements": [ "requirements": [
"python-ecobee-api==0.0.18" "python-ecobee-api==0.0.21"
], ],
"dependencies": ["configurator"], "dependencies": ["configurator"],
"codeowners": [] "codeowners": []

View File

@ -1438,7 +1438,7 @@ python-clementine-remote==1.0.1
python-digitalocean==1.13.2 python-digitalocean==1.13.2
# homeassistant.components.ecobee # homeassistant.components.ecobee
python-ecobee-api==0.0.18 python-ecobee-api==0.0.21
# homeassistant.components.eq3btsmart # homeassistant.components.eq3btsmart
# python-eq3bt==0.1.9 # python-eq3bt==0.1.9

View File

@ -23,6 +23,8 @@ class TestEcobee(unittest.TestCase):
'desiredCool': 200, 'desiredCool': 200,
'desiredFanMode': 'on'}, 'desiredFanMode': 'on'},
'settings': {'hvacMode': 'auto', 'settings': {'hvacMode': 'auto',
'heatStages': 1,
'coolStages': 1,
'fanMinOnTime': 10, 'fanMinOnTime': 10,
'heatCoolMinDelta': 50, 'heatCoolMinDelta': 50,
'holdAction': 'nextTransition'}, 'holdAction': 'nextTransition'},