Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ClimateEntityFeature.TURN_OFF feature & implementation #176

Merged
merged 6 commits into from
Dec 15, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ Use the standard `climate` service calls to control or automate each unit. Avail
- `climate.set_fan_mode`
- `climate.set_hvac_mode`
- `climate.set_swing_mode`
- `climate.turn_on`
- `climate.turn_off`

Specific support and behavior can vary, depending on the capabilities of your indoor unit.

Expand Down
22 changes: 17 additions & 5 deletions custom_components/kumo/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,6 @@ class KumoThermostat(CoordinatedKumoEntity, ClimateEntity):
"runstate",
]

_enable_turn_on_off_backwards_compatibility = False # can be removed once 2024.12 is no longer supported
mxr marked this conversation as resolved.
Show resolved Hide resolved

def __init__(self, coordinator: KumoDataUpdateCoordinator):
"""Initialize the thermostat."""

Expand All @@ -155,7 +153,10 @@ def __init__(self, coordinator: KumoDataUpdateCoordinator):
self._swing_modes = self._pykumo.get_vane_directions()
self._hvac_modes = [HVACMode.OFF, HVACMode.COOL]
self._supported_features = (
ClimateEntityFeature.TARGET_TEMPERATURE | ClimateEntityFeature.FAN_MODE
ClimateEntityFeature.TARGET_TEMPERATURE |
ClimateEntityFeature.FAN_MODE |
ClimateEntityFeature.TURN_OFF |
ClimateEntityFeature.TURN_ON
)
if self._pykumo.has_dry_mode():
self._hvac_modes.append(HVACMode.DRY)
Expand Down Expand Up @@ -495,7 +496,7 @@ def set_temperature(self, **kwargs):
"Kumo %s set %s temp response: %s", self._name, "cool", str(response)
)

def set_hvac_mode(self, hvac_mode):
def set_hvac_mode(self, hvac_mode, caller="set_hvac_mode"):
"""Set new target operation mode."""
try:
mode = HA_STATE_TO_KUMO[hvac_mode]
Expand All @@ -508,7 +509,7 @@ def set_hvac_mode(self, hvac_mode):

response = self._pykumo.set_mode(mode)
_LOGGER.debug(
"Kumo %s set mode %s response: %s", self._name, hvac_mode, response
"Kumo %s set mode %s (via `%s`) response: %s", self._name, hvac_mode, caller, response
)

def set_swing_mode(self, swing_mode):
Expand All @@ -528,3 +529,14 @@ def set_fan_mode(self, fan_mode):

response = self._pykumo.set_fan_speed(fan_mode)
_LOGGER.debug("Kumo %s set fan speed response: %s", self._name, response)

def turn_on(self) -> None:
"""Turn the climate on. This implements https://www.home-assistant.io/integrations/climate/#action-climateturn_on.

For now, turn it on to HVACMode.COOL which always exists in self._hvac_modes.
mxr marked this conversation as resolved.
Show resolved Hide resolved
In the future, make the default "on" mode configurable."""
self.set_hvac_mode(HVACMode.COOL, caller="turn_on")

def turn_off(self):
"""Turn the climate off. This implements https://www.home-assistant.io/integrations/climate/#action-climateturn_off."""
self.set_hvac_mode(HVACMode.OFF, caller="turn_off")
Loading