Skip to content

Commit

Permalink
Remove "Include "Off" State" integration option.
Browse files Browse the repository at this point in the history
The option no longer makes sense as there is no other means to turn off a climate entity other than via it's HVACMode.

It appears there used to be a SUPPORT_ON_OFF feature but it was removed in this PR 4 years ago: home-assistant/core#23899
  • Loading branch information
mill1000 committed Nov 13, 2023
1 parent e04d897 commit ef0d3d4
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 20 deletions.
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ Name | Default | Description
:--- | :--- | :---
**Beep** | True | Enable beep on setting changes.
**Temperature Step** | 1.0 | Step size for temperature set point.
**Include "Off" State** | True | Include "Off" as a valid device state.
**Use Fan-only Workaround** | False | Enable this option if device updates cause the device to turn on and switch to fan-only.
**Show All Presets** | False | Show all presets regardless of device's reported capabilities.
**Additional Operation Modes** | Empty | Additional HVAC modes to make available in case the device's capabilities are incorrect.
Expand Down
17 changes: 6 additions & 11 deletions custom_components/midea_ac/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@

from . import helpers
from .const import (CONF_ADDITIONAL_OPERATION_MODES, CONF_BEEP,
CONF_INCLUDE_OFF_AS_STATE, CONF_SHOW_ALL_PRESETS,
CONF_TEMP_STEP, CONF_USE_FAN_ONLY_WORKAROUND, DOMAIN)
CONF_SHOW_ALL_PRESETS, CONF_TEMP_STEP,
CONF_USE_FAN_ONLY_WORKAROUND, DOMAIN)
from .coordinator import MideaCoordinatorEntity, MideaDeviceUpdateCoordinator

_LOGGER = logging.getLogger(__name__)
Expand Down Expand Up @@ -94,7 +94,6 @@ def __init__(self,
# Apply options
self._device.beep = options.get(CONF_BEEP, False)
self._target_temperature_step = options.get(CONF_TEMP_STEP)
self._include_off_as_state = options.get(CONF_INCLUDE_OFF_AS_STATE)
self._use_fan_only_workaround = options.get(
CONF_USE_FAN_ONLY_WORKAROUND, False)

Expand Down Expand Up @@ -131,10 +130,7 @@ def __init__(self,
# Convert from Midea operational modes to HA HVAC mode
self._hvac_modes = [_OPERATIONAL_MODE_TO_HVAC_MODE[m]
for m in supported_op_modes]

# Include off mode if requested
if self._include_off_as_state:
self._hvac_modes.append(HVACMode.OFF)
self._hvac_modes.append(HVACMode.OFF)

# Append additional operation modes as needed
additional_modes = options.get(CONF_ADDITIONAL_OPERATION_MODES) or ""
Expand Down Expand Up @@ -336,18 +332,17 @@ def hvac_modes(self) -> list[HVACMode]:
@property
def hvac_mode(self) -> HVACMode:
"""Return current HVAC mode."""
if self._include_off_as_state and not self._device.power_state:
if not self._device.power_state:
return HVACMode.OFF

return _OPERATIONAL_MODE_TO_HVAC_MODE.get(self._device.operational_mode, HVACMode.OFF)

async def async_set_hvac_mode(self, hvac_mode: HVACMode) -> None:
"""Set the HVAC mode."""
if self._include_off_as_state and hvac_mode == HVACMode.OFF:
if hvac_mode == HVACMode.OFF:
self._device.power_state = False
else:
if self._include_off_as_state:
self._device.power_state = True
self._device.power_state = True

self._device.operational_mode = _HVAC_MODE_TO_OPERATIONAL_MODE.get(
hvac_mode, self._device.operational_mode)
Expand Down
6 changes: 1 addition & 5 deletions custom_components/midea_ac/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
from msmart.device import AirConditioner as AC
from msmart.discover import Discover

from .const import (CONF_ADDITIONAL_OPERATION_MODES, CONF_BEEP,
CONF_INCLUDE_OFF_AS_STATE, CONF_KEY,
from .const import (CONF_ADDITIONAL_OPERATION_MODES, CONF_BEEP, CONF_KEY,
CONF_MAX_CONNECTION_LIFETIME, CONF_SHOW_ALL_PRESETS,
CONF_TEMP_STEP, CONF_USE_FAN_ONLY_WORKAROUND, DOMAIN)

_DEFAULT_OPTIONS = {
CONF_BEEP: True,
CONF_TEMP_STEP: 1.0,
CONF_INCLUDE_OFF_AS_STATE: True,
CONF_USE_FAN_ONLY_WORKAROUND: False,
CONF_SHOW_ALL_PRESETS: False,
CONF_ADDITIONAL_OPERATION_MODES: None,
Expand Down Expand Up @@ -227,8 +225,6 @@ async def async_step_init(self, user_input=None) -> FlowResult:
default=options.get(CONF_BEEP, True)): cv.boolean,
vol.Optional(CONF_TEMP_STEP,
default=options.get(CONF_TEMP_STEP, 1.0)): vol.All(vol.Coerce(float), vol.Range(min=0.5, max=5)),
vol.Optional(CONF_INCLUDE_OFF_AS_STATE,
default=options.get(CONF_INCLUDE_OFF_AS_STATE, True)): cv.boolean,
vol.Optional(CONF_USE_FAN_ONLY_WORKAROUND,
default=options.get(CONF_USE_FAN_ONLY_WORKAROUND, False)): cv.boolean,
vol.Optional(CONF_SHOW_ALL_PRESETS,
Expand Down
1 change: 0 additions & 1 deletion custom_components/midea_ac/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
CONF_KEY = "k1"
CONF_BEEP = "prompt_tone"
CONF_TEMP_STEP = "temp_step"
CONF_INCLUDE_OFF_AS_STATE = "include_off_as_state"
CONF_USE_FAN_ONLY_WORKAROUND = "use_fan_only_workaround"
CONF_ADDITIONAL_OPERATION_MODES = "additional_operation_modes"
CONF_SHOW_ALL_PRESETS = "show_all_presets"
Expand Down
1 change: 0 additions & 1 deletion custom_components/midea_ac/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"data": {
"prompt_tone": "Enable Beep",
"temp_step": "Temperature Step",
"include_off_as_state": "Include \"Off\" State",
"use_fan_only_workaround": "Use Fan-only Workaround",
"show_all_presets": "Show All Presets",
"additional_operation_modes": "Additional Operation Modes",
Expand Down
1 change: 0 additions & 1 deletion custom_components/midea_ac/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"data": {
"prompt_tone": "Enable Beep",
"temp_step": "Temperature Step",
"include_off_as_state": "Include \"Off\" State",
"use_fan_only_workaround": "Use Fan-only Workaround",
"show_all_presets": "Show All Presets",
"additional_operation_modes": "Additional Operation Modes",
Expand Down

0 comments on commit ef0d3d4

Please sign in to comment.