Skip to content

Commit

Permalink
Add config option to reverse labels on horizontal swing angle
Browse files Browse the repository at this point in the history
  • Loading branch information
mill1000 committed Feb 27, 2025
1 parent 6986047 commit 09df8b2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
7 changes: 5 additions & 2 deletions custom_components/midea_ac/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@
CONF_CLOUD_COUNTRY_CODES, CONF_DEFAULT_CLOUD_COUNTRY,
CONF_ENERGY_FORMAT, CONF_FAN_SPEED_STEP, CONF_KEY,
CONF_MAX_CONNECTION_LIFETIME, CONF_SHOW_ALL_PRESETS,
CONF_TEMP_STEP, CONF_USE_FAN_ONLY_WORKAROUND, DOMAIN,
UPDATE_INTERVAL, EnergyFormat)
CONF_SWING_ANGLE_RTL, CONF_TEMP_STEP,
CONF_USE_FAN_ONLY_WORKAROUND, DOMAIN, UPDATE_INTERVAL,
EnergyFormat)

_DEFAULT_OPTIONS = {
CONF_BEEP: True,
Expand All @@ -38,6 +39,7 @@
CONF_ADDITIONAL_OPERATION_MODES: None,
CONF_MAX_CONNECTION_LIFETIME: None,
CONF_ENERGY_FORMAT: EnergyFormat.DEFAULT,
CONF_SWING_ANGLE_RTL: False
}

_CLOUD_CREDENTIALS = {
Expand Down Expand Up @@ -278,6 +280,7 @@ async def async_step_init(self, user_input=None) -> FlowResult:
mode=SelectSelectorMode.DROPDOWN,
)
),
vol.Optional(CONF_SWING_ANGLE_RTL): cv.boolean,
}), self.config_entry.options)

return self.async_show_form(step_id="init", data_schema=data_schema)
1 change: 1 addition & 0 deletions custom_components/midea_ac/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
CONF_ENERGY_FORMAT = "energy_format"
CONF_CLOUD_COUNTRY_CODES = ["DE", "KR", "US"]
CONF_DEFAULT_CLOUD_COUNTRY = "US"
CONF_SWING_ANGLE_RTL = "swing_angle_rtl"

PRESET_IECO = "ieco"

Expand Down
22 changes: 12 additions & 10 deletions custom_components/midea_ac/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from msmart.device import AirConditioner as AC
from msmart.utils import MideaIntEnum

from .const import DOMAIN
from .const import CONF_SWING_ANGLE_RTL, DOMAIN
from .coordinator import MideaCoordinatorEntity, MideaDeviceUpdateCoordinator

_LOGGER = logging.getLogger(__name__)
Expand All @@ -34,28 +34,30 @@ async def async_setup_entry(
if coordinator.device.supports_vertical_swing_angle:
entities.append(MideaEnumSelect(coordinator,
"vertical_swing_angle",
AC.SwingAngle,
"vertical_swing_angle"))
AC.SwingAngle
))

if coordinator.device.supports_horizontal_swing_angle:
entities.append(MideaEnumSelect(coordinator,
"horizontal_swing_angle",
AC.SwingAngle,
"horizontal_swing_angle"))
translation_key="horizontal_swing_angle_rtl" if config_entry.options.get(
CONF_SWING_ANGLE_RTL) else None
))

if (supported_rates := coordinator.device.supported_rate_selects) != [AC.RateSelect.OFF]:
entities.append(MideaEnumSelect(coordinator,
"rate_select",
AC.RateSelect,
"rate_select",
options=supported_rates))
options=supported_rates
))

if (supported_aux_modes := coordinator.device.supported_aux_modes) != [AC.AuxHeatMode.OFF]:
entities.append(MideaEnumSelect(coordinator,
"aux_mode",
AC.AuxHeatMode,
"aux_mode",
options=supported_aux_modes))
options=supported_aux_modes
))

add_entities(entities)

Expand All @@ -67,14 +69,14 @@ def __init__(self,
coordinator: MideaDeviceUpdateCoordinator,
prop: str,
enum_class: MideaIntEnum,
translation_key: Optional[str] = None,
*,
translation_key: Optional[str] = None,
options: Optional[List[MideaIntEnum]] = None) -> None:
MideaCoordinatorEntity.__init__(self, coordinator)

self._prop = prop
self._enum_class = enum_class
self._attr_translation_key = translation_key
self._attr_translation_key = translation_key if translation_key is not None else prop
self._options = options

@property
Expand Down
14 changes: 13 additions & 1 deletion custom_components/midea_ac/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,8 @@
"show_all_presets": "Show All Presets",
"additional_operation_modes": "Additional Operation Modes",
"max_connection_lifetime": "Maximum Connection Lifetime",
"energy_format": "Energy Format"
"energy_format": "Energy Format",
"swing_angle_rtl": "Right-to-left Horizontal Swing Angle"
},
"data_description": {
"temp_step": "Step size for temperature set point",
Expand Down Expand Up @@ -156,6 +157,17 @@
"pos_5": "Right"
}
},
"horizontal_swing_angle_rtl": {
"name": "Horizontal swing angle",
"state": {
"off": "Off",
"pos_1": "Right",
"pos_2": "Right-center",
"pos_3": "Center",
"pos_4": "Left-center",
"pos_5": "Left"
}
},
"rate_select": {
"name": "Rate select",
"state": {
Expand Down

0 comments on commit 09df8b2

Please sign in to comment.