From af951ff0d46a7d2c10432eb76a648f785ee4e8ce Mon Sep 17 00:00:00 2001 From: LG-ThinQ-Integration Date: Sat, 23 Aug 2025 20:24:10 +0900 Subject: [PATCH] Modified to use built-in fan modes for "mid". (#150927) Co-authored-by: yunseon.park --- homeassistant/components/lg_thinq/climate.py | 20 ++++++++++++++++--- homeassistant/components/lg_thinq/icons.json | 2 +- .../components/lg_thinq/strings.json | 2 +- .../lg_thinq/snapshots/test_climate.ambr | 6 +++--- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/homeassistant/components/lg_thinq/climate.py b/homeassistant/components/lg_thinq/climate.py index 4810336c6e0..67539cbee1e 100644 --- a/homeassistant/components/lg_thinq/climate.py +++ b/homeassistant/components/lg_thinq/climate.py @@ -12,6 +12,7 @@ from homeassistant.components.climate import ( ATTR_HVAC_MODE, ATTR_TARGET_TEMP_HIGH, ATTR_TARGET_TEMP_LOW, + FAN_MEDIUM, PRESET_NONE, SWING_OFF, SWING_ON, @@ -64,6 +65,12 @@ STR_TO_SWING = { 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__) @@ -124,7 +131,9 @@ class ThinQClimateEntity(ThinQEntity, ClimateEntity): self._attr_supported_features |= ClimateEntityFeature.PRESET_MODE # 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: self._attr_supported_features |= ClimateEntityFeature.FAN_MODE @@ -148,7 +157,9 @@ class ThinQClimateEntity(ThinQEntity, ClimateEntity): # Update fan, hvac and preset 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: self._attr_swing_mode = STR_TO_SWING.get(self.data.swing_mode) if self.supported_features & ClimateEntityFeature.SWING_HORIZONTAL_MODE: @@ -266,7 +277,10 @@ class ThinQClimateEntity(ThinQEntity, ClimateEntity): fan_mode, ) 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: diff --git a/homeassistant/components/lg_thinq/icons.json b/homeassistant/components/lg_thinq/icons.json index 303660aef75..1eb96b71f4a 100644 --- a/homeassistant/components/lg_thinq/icons.json +++ b/homeassistant/components/lg_thinq/icons.json @@ -92,7 +92,7 @@ "state": { "slow": "mdi:fan-chevron-down", "low": "mdi:fan-speed-1", - "mid": "mdi:fan-speed-2", + "medium": "mdi:fan-speed-2", "high": "mdi:fan-speed-3", "power": "mdi:fan-chevron-up", "auto": "mdi:fan-auto" diff --git a/homeassistant/components/lg_thinq/strings.json b/homeassistant/components/lg_thinq/strings.json index 735d1dbf890..1d48a065915 100644 --- a/homeassistant/components/lg_thinq/strings.json +++ b/homeassistant/components/lg_thinq/strings.json @@ -120,7 +120,7 @@ "state": { "slow": "Slow", "low": "[%key:common::state::low%]", - "mid": "[%key:common::state::medium%]", + "medium": "[%key:common::state::medium%]", "high": "[%key:common::state::high%]", "power": "[%key:component::lg_thinq::entity::sensor::current_job_mode::state::high%]", "auto": "[%key:common::state::auto%]" diff --git a/tests/components/lg_thinq/snapshots/test_climate.ambr b/tests/components/lg_thinq/snapshots/test_climate.ambr index 754969ff549..66d842050ab 100644 --- a/tests/components/lg_thinq/snapshots/test_climate.ambr +++ b/tests/components/lg_thinq/snapshots/test_climate.ambr @@ -8,7 +8,7 @@ 'fan_modes': list([ 'low', 'high', - 'mid', + 'medium', ]), 'hvac_modes': list([ , @@ -65,11 +65,11 @@ 'attributes': ReadOnlyDict({ 'current_humidity': 40, 'current_temperature': 77, - 'fan_mode': 'mid', + 'fan_mode': 'medium', 'fan_modes': list([ 'low', 'high', - 'mid', + 'medium', ]), 'friendly_name': 'Test air conditioner', 'hvac_modes': list([