Skip to content

Commit

Permalink
Merge pull request #176 from mxr/turn-on-off-feature-flags
Browse files Browse the repository at this point in the history
Add `ClimateEntityFeature.TURN_OFF` feature & implementation
  • Loading branch information
dlarrick authored Dec 15, 2024
2 parents 151be99 + 7e96632 commit 7d559b0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ 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_off`

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

Expand Down
12 changes: 9 additions & 3 deletions custom_components/kumo/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,9 @@ 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
)
if self._pykumo.has_dry_mode():
self._hvac_modes.append(HVACMode.DRY)
Expand Down Expand Up @@ -495,7 +497,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 +510,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 +530,7 @@ 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_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")

0 comments on commit 7d559b0

Please sign in to comment.