Skip to content

Commit

Permalink
Merge pull request #55 from mill1000/feature/better_translations
Browse files Browse the repository at this point in the history
Support translating swing modes and fan speeds
  • Loading branch information
mill1000 authored Nov 22, 2023
2 parents 803196a + 44c930c commit 15648fc
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 79 deletions.
12 changes: 7 additions & 5 deletions custom_components/midea_ac/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

_LOGGER = logging.getLogger(__name__)

_FAN_CUSTOM = "Custom"
_FAN_CUSTOM = "custom"

# Dictionaries to convert from Midea mode to HA mode
_OPERATIONAL_MODE_TO_HVAC_MODE: dict[AC.OperationalMode, HVACMode] = {
Expand Down Expand Up @@ -81,6 +81,8 @@ async def async_setup_entry(
class MideaClimateACDevice(MideaCoordinatorEntity, ClimateEntity):
"""Climate entity for Midea AC device."""

_attr_translation_key = DOMAIN

def __init__(self,
hass: HomeAssistant,
coordinator: MideaDeviceUpdateCoordinator,
Expand Down Expand Up @@ -144,7 +146,7 @@ def __init__(self,
self._device, "supported_fan_speeds", AC.FanSpeed.list())

# Convert Midea swing modes to strings
self._fan_modes = [m.name.capitalize()
self._fan_modes = [m.name.lower()
for m in supported_fan_speeds]

# Fetch supported swing modes
Expand All @@ -156,7 +158,7 @@ def __init__(self,
self._supported_features |= SUPPORT_SWING_MODE

# Convert Midea swing modes to strings
self._swing_modes = [m.name.capitalize()
self._swing_modes = [m.name.lower()
for m in supported_swing_modes]

# Dump all supported modes for debug
Expand Down Expand Up @@ -281,7 +283,7 @@ def swing_modes(self) -> list[str]:
@property
def swing_mode(self) -> str:
"""Return the current swing mode."""
return self._device.swing_mode.name.capitalize()
return self._device.swing_mode.name.lower()

async def async_set_swing_mode(self, swing_mode: str) -> None:
"""Set the swing mode."""
Expand All @@ -307,7 +309,7 @@ def fan_mode(self) -> str:
fan_speed = self._device.fan_speed

if isinstance(fan_speed, AC.FanSpeed):
return fan_speed.name.capitalize()
return fan_speed.name.lower()
elif isinstance(fan_speed, int):
return _FAN_CUSTOM

Expand Down
74 changes: 0 additions & 74 deletions custom_components/midea_ac/strings.json

This file was deleted.

26 changes: 26 additions & 0 deletions custom_components/midea_ac/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,31 @@
}
}
}
},
"entity": {
"climate": {
"midea_ac": {
"state_attributes": {
"fan_mode": {
"state": {
"silent": "Silent",
"low": "Low",
"medium": "Medium",
"high": "High",
"auto": "Auto",
"custom": "Custom"
}
},
"swing_mode": {
"state": {
"off": "Off",
"vertical": "Vertical",
"horizontal": "Horizontal",
"both": "Both"
}
}
}
}
}
}
}

0 comments on commit 15648fc

Please sign in to comment.