Modified to use built-in fan modes for "mid". (#150927)

Co-authored-by: yunseon.park <yunseon.park@lge.com>
This commit is contained in:
LG-ThinQ-Integration
2025-08-23 20:24:10 +09:00
committed by GitHub
parent 207e2f61ea
commit af951ff0d4
4 changed files with 22 additions and 8 deletions

View File

@@ -12,6 +12,7 @@ from homeassistant.components.climate import (
ATTR_HVAC_MODE, ATTR_HVAC_MODE,
ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_HIGH,
ATTR_TARGET_TEMP_LOW, ATTR_TARGET_TEMP_LOW,
FAN_MEDIUM,
PRESET_NONE, PRESET_NONE,
SWING_OFF, SWING_OFF,
SWING_ON, SWING_ON,
@@ -64,6 +65,12 @@ STR_TO_SWING = {
SWING_TO_STR = {v: k for k, v in STR_TO_SWING.items()} SWING_TO_STR = {v: k for k, v in STR_TO_SWING.items()}
STR_TO_HA_FAN: dict[str, str] = {
"mid": FAN_MEDIUM,
}
HA_FAN_TO_STR = {v: k for k, v in STR_TO_HA_FAN.items()}
_LOGGER = logging.getLogger(__name__) _LOGGER = logging.getLogger(__name__)
@@ -124,7 +131,9 @@ class ThinQClimateEntity(ThinQEntity, ClimateEntity):
self._attr_supported_features |= ClimateEntityFeature.PRESET_MODE self._attr_supported_features |= ClimateEntityFeature.PRESET_MODE
# Set up fan modes. # Set up fan modes.
self._attr_fan_modes = self.data.fan_modes self._attr_fan_modes = [
STR_TO_HA_FAN.get(fan, fan) for fan in self.data.fan_modes
]
if self.fan_modes: if self.fan_modes:
self._attr_supported_features |= ClimateEntityFeature.FAN_MODE self._attr_supported_features |= ClimateEntityFeature.FAN_MODE
@@ -148,7 +157,9 @@ class ThinQClimateEntity(ThinQEntity, ClimateEntity):
# Update fan, hvac and preset mode. # Update fan, hvac and preset mode.
if self.supported_features & ClimateEntityFeature.FAN_MODE: if self.supported_features & ClimateEntityFeature.FAN_MODE:
self._attr_fan_mode = self.data.fan_mode self._attr_fan_mode = STR_TO_HA_FAN.get(
self.data.fan_mode, self.data.fan_mode
)
if self.supported_features & ClimateEntityFeature.SWING_MODE: if self.supported_features & ClimateEntityFeature.SWING_MODE:
self._attr_swing_mode = STR_TO_SWING.get(self.data.swing_mode) self._attr_swing_mode = STR_TO_SWING.get(self.data.swing_mode)
if self.supported_features & ClimateEntityFeature.SWING_HORIZONTAL_MODE: if self.supported_features & ClimateEntityFeature.SWING_HORIZONTAL_MODE:
@@ -266,7 +277,10 @@ class ThinQClimateEntity(ThinQEntity, ClimateEntity):
fan_mode, fan_mode,
) )
await self.async_call_api( await self.async_call_api(
self.coordinator.api.async_set_fan_mode(self.property_id, fan_mode) self.coordinator.api.async_set_fan_mode(
self.property_id,
HA_FAN_TO_STR.get(fan_mode, fan_mode),
)
) )
async def async_set_swing_mode(self, swing_mode: str) -> None: async def async_set_swing_mode(self, swing_mode: str) -> None:

View File

@@ -92,7 +92,7 @@
"state": { "state": {
"slow": "mdi:fan-chevron-down", "slow": "mdi:fan-chevron-down",
"low": "mdi:fan-speed-1", "low": "mdi:fan-speed-1",
"mid": "mdi:fan-speed-2", "medium": "mdi:fan-speed-2",
"high": "mdi:fan-speed-3", "high": "mdi:fan-speed-3",
"power": "mdi:fan-chevron-up", "power": "mdi:fan-chevron-up",
"auto": "mdi:fan-auto" "auto": "mdi:fan-auto"

View File

@@ -120,7 +120,7 @@
"state": { "state": {
"slow": "Slow", "slow": "Slow",
"low": "[%key:common::state::low%]", "low": "[%key:common::state::low%]",
"mid": "[%key:common::state::medium%]", "medium": "[%key:common::state::medium%]",
"high": "[%key:common::state::high%]", "high": "[%key:common::state::high%]",
"power": "[%key:component::lg_thinq::entity::sensor::current_job_mode::state::high%]", "power": "[%key:component::lg_thinq::entity::sensor::current_job_mode::state::high%]",
"auto": "[%key:common::state::auto%]" "auto": "[%key:common::state::auto%]"

View File

@@ -8,7 +8,7 @@
'fan_modes': list([ 'fan_modes': list([
'low', 'low',
'high', 'high',
'mid', 'medium',
]), ]),
'hvac_modes': list([ 'hvac_modes': list([
<HVACMode.OFF: 'off'>, <HVACMode.OFF: 'off'>,
@@ -65,11 +65,11 @@
'attributes': ReadOnlyDict({ 'attributes': ReadOnlyDict({
'current_humidity': 40, 'current_humidity': 40,
'current_temperature': 77, 'current_temperature': 77,
'fan_mode': 'mid', 'fan_mode': 'medium',
'fan_modes': list([ 'fan_modes': list([
'low', 'low',
'high', 'high',
'mid', 'medium',
]), ]),
'friendly_name': 'Test air conditioner', 'friendly_name': 'Test air conditioner',
'hvac_modes': list([ 'hvac_modes': list([