Skip to content

Commit

Permalink
Merge pull request #28 from FrancisLab/master
Browse files Browse the repository at this point in the history
Fix set_temperature for heat_cool mode
  • Loading branch information
dlarrick authored May 24, 2020
2 parents 73f2f80 + 7865f0c commit 99c6225
Showing 1 changed file with 39 additions and 28 deletions.
67 changes: 39 additions & 28 deletions custom_components/kumo/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,33 +51,42 @@
}
)

KUMO_STATE_AUTO = "auto"
KUMO_STATE_AUTO_COOL = "autoCool"
KUMO_STATE_AUTO_HEAT = "autoHeat"
KUMO_STATE_COOL = "cool"
KUMO_STATE_HEAT = "heat"
KUMO_STATE_DRY = "dry"
KUMO_STATE_VENT = "vent"
KUMO_STATE_OFF = "off"

HA_STATE_TO_KUMO = {
HVAC_MODE_HEAT_COOL: "auto",
HVAC_MODE_COOL: "cool",
HVAC_MODE_HEAT: "heat",
HVAC_MODE_DRY: "dry",
HVAC_MODE_FAN_ONLY: "vent",
HVAC_MODE_OFF: "off",
HVAC_MODE_HEAT_COOL: KUMO_STATE_AUTO,
HVAC_MODE_COOL: KUMO_STATE_COOL,
HVAC_MODE_HEAT: KUMO_STATE_HEAT,
HVAC_MODE_DRY: KUMO_STATE_DRY,
HVAC_MODE_FAN_ONLY: KUMO_STATE_VENT,
HVAC_MODE_OFF: KUMO_STATE_OFF,
}
KUMO_STATE_TO_HA = {
"auto": HVAC_MODE_HEAT_COOL,
"autoCool": HVAC_MODE_HEAT_COOL,
"autoHeat": HVAC_MODE_HEAT_COOL,
"cool": HVAC_MODE_COOL,
"heat": HVAC_MODE_HEAT,
"dry": HVAC_MODE_DRY,
"vent": HVAC_MODE_FAN_ONLY,
"off": HVAC_MODE_OFF,
KUMO_STATE_AUTO: HVAC_MODE_HEAT_COOL,
KUMO_STATE_AUTO_COOL: HVAC_MODE_HEAT_COOL,
KUMO_STATE_AUTO_HEAT: HVAC_MODE_HEAT_COOL,
KUMO_STATE_COOL: HVAC_MODE_COOL,
KUMO_STATE_HEAT: HVAC_MODE_HEAT,
KUMO_STATE_DRY: HVAC_MODE_DRY,
KUMO_STATE_VENT: HVAC_MODE_FAN_ONLY,
KUMO_STATE_OFF: HVAC_MODE_OFF,
}
KUMO_STATE_TO_HA_ACTION = {
"auto": CURRENT_HVAC_IDLE,
"autoCool": CURRENT_HVAC_COOL,
"autoHeat": CURRENT_HVAC_HEAT,
"cool": CURRENT_HVAC_COOL,
"heat": CURRENT_HVAC_HEAT,
"dry": CURRENT_HVAC_DRY,
"vent": CURRENT_HVAC_IDLE,
"off": CURRENT_HVAC_OFF,
KUMO_STATE_AUTO: CURRENT_HVAC_IDLE,
KUMO_STATE_AUTO_COOL: CURRENT_HVAC_COOL,
KUMO_STATE_AUTO_HEAT: CURRENT_HVAC_HEAT,
KUMO_STATE_COOL: CURRENT_HVAC_COOL,
KUMO_STATE_HEAT: CURRENT_HVAC_HEAT,
KUMO_STATE_DRY: CURRENT_HVAC_DRY,
KUMO_STATE_VENT: CURRENT_HVAC_IDLE,
KUMO_STATE_OFF: CURRENT_HVAC_OFF,
}


Expand Down Expand Up @@ -412,23 +421,25 @@ def set_temperature(self, **kwargs):
mode_to_set = None

if mode_to_set is None:
mode_to_set = self.hvac_mode
mode_to_set = HA_STATE_TO_KUMO[self.hvac_mode]

if mode_to_set not in (HVAC_MODE_HEAT_COOL, HVAC_MODE_COOL, HVAC_MODE_HEAT):
if mode_to_set not in (KUMO_STATE_AUTO, KUMO_STATE_COOL, KUMO_STATE_HEAT):
_LOGGER.warning(
"Kumo %s not setting target temperature for mode %s",
self._name,
mode_to_set,
)
return

if mode_to_set == HVAC_MODE_HEAT:
if mode_to_set == KUMO_STATE_HEAT:
response = self._pykumo.set_heat_setpoint(target["setpoint"])
elif mode_to_set == HVAC_MODE_COOL:
elif mode_to_set == KUMO_STATE_COOL:
response = self._pykumo.set_cool_setpoint(target["setpoint"])
else:
response = self._pykumo.set_heat_setpoint(target["heat"])
response += " " + self._pykumo.set_cool_setpoint(["cool"])
heat_response = self._pykumo.set_heat_setpoint(target["heat"])
cool_response = self._pykumo.set_cool_setpoint(target["cool"])
response = {"heat" : heat_response, "cool" : cool_response}

_LOGGER.debug("Kumo %s set temp: %s C", self._name, target)
_LOGGER.debug("Kumo %s set temp response: %s", self._name, response)

Expand Down

0 comments on commit 99c6225

Please sign in to comment.