Skip to content

Commit

Permalink
Updates to set_fan_mode/set_climate_hold
Browse files Browse the repository at this point in the history
set_fan_hold
    - Make optional parameters (holdHours, coolHoldTemp, heatHoldTemp)
        - holdHours must be set if holdType is set to holdHours.
        - coolHoldTemp and heatHoldTemp are optional. Setting these
          values in set_fan_hold can lead to unexpected behavior
          This behavior has an issue in the HA repo (home-assistant/core#40087)
set_climate_hold
    - Fix comparison which was throwing a python warning.
  • Loading branch information
bjpetit authored and nkgilley committed Mar 18, 2021
1 parent 840a044 commit f164c64
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions pyecobee/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,9 +256,8 @@ def set_fan_mode(
self,
index: int,
fan_mode: str,
cool_temp: int,
heat_temp: int,
hold_type: str = "nextTransition",
hold_type: str,
**optional_arg,
) -> None:
"""Sets the fan mode (auto, minontime, on)."""
body = {
Expand All @@ -271,13 +270,22 @@ def set_fan_mode(
"type": "setHold",
"params": {
"holdType": hold_type,
"coolHoldTemp": int(cool_temp * 10),
"heatHoldTemp": int(heat_temp * 10),
"fan": fan_mode,
},
}
],
}

# Set the optional args
if "holdHours" in optional_arg:
# Required if and only if hold_type == holdHours
if hold_type == "holdHours":
body["functions"][0]["params"]["holdHours"] = int(optional_arg["holdHours"])
if "coolHoldTemp" in optional_arg:
body["functions"][0]["params"]["coolHoldTemp"] = int(optional_arg["coolHoldTemp"]) * 10
if "heatHoldTemp" in optional_arg:
body["functions"][0]["params"]["heatHoldTemp"] = int(optional_arg["heatHoldTemp"]) * 10

log_msg_action = "set fan mode"

try:
Expand Down Expand Up @@ -353,7 +361,7 @@ def set_climate_hold(
],
}

if hold_type is not "holdHours":
if hold_type != "holdHours":
del body["functions"][0]["params"]["holdHours"]

log_msg_action = "set climate hold"
Expand Down

0 comments on commit f164c64

Please sign in to comment.