mirror of
https://github.com/home-assistant/core.git
synced 2025-04-23 16:57:53 +00:00
Add climate's swing mode to LG ThinQ (#137619)
Co-authored-by: yunseon.park <yunseon.park@lge.com>
This commit is contained in:
parent
cea5cda881
commit
bc7f5f3981
@ -12,6 +12,8 @@ from thinqconnect.integration import ExtendedProperty
|
||||
from homeassistant.components.climate import (
|
||||
ATTR_TARGET_TEMP_HIGH,
|
||||
ATTR_TARGET_TEMP_LOW,
|
||||
SWING_OFF,
|
||||
SWING_ON,
|
||||
ClimateEntity,
|
||||
ClimateEntityDescription,
|
||||
ClimateEntityFeature,
|
||||
@ -73,6 +75,13 @@ HVAC_TO_STR: dict[HVACMode, str] = {
|
||||
|
||||
THINQ_PRESET_MODE: list[str] = ["air_clean", "aroma", "energy_saving"]
|
||||
|
||||
STR_TO_SWING = {
|
||||
"true": SWING_ON,
|
||||
"false": SWING_OFF,
|
||||
}
|
||||
|
||||
SWING_TO_STR = {v: k for k, v in STR_TO_SWING.items()}
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
|
||||
|
||||
@ -142,6 +151,14 @@ class ThinQClimateEntity(ThinQEntity, ClimateEntity):
|
||||
self._attr_supported_features |= (
|
||||
ClimateEntityFeature.TARGET_TEMPERATURE_RANGE
|
||||
)
|
||||
# Supports swing mode.
|
||||
if self.data.swing_modes:
|
||||
self._attr_swing_modes = [SWING_ON, SWING_OFF]
|
||||
self._attr_supported_features |= ClimateEntityFeature.SWING_MODE
|
||||
|
||||
if self.data.swing_horizontal_modes:
|
||||
self._attr_swing_horizontal_modes = [SWING_ON, SWING_OFF]
|
||||
self._attr_supported_features |= ClimateEntityFeature.SWING_HORIZONTAL_MODE
|
||||
|
||||
def _update_status(self) -> None:
|
||||
"""Update status itself."""
|
||||
@ -150,6 +167,13 @@ 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
|
||||
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:
|
||||
self._attr_swing_horizontal_mode = STR_TO_SWING.get(
|
||||
self.data.swing_horizontal_mode
|
||||
)
|
||||
|
||||
if self.data.is_on:
|
||||
hvac_mode = self._requested_hvac_mode or self.data.hvac_mode
|
||||
if hvac_mode in STR_TO_HVAC:
|
||||
@ -268,6 +292,34 @@ class ThinQClimateEntity(ThinQEntity, ClimateEntity):
|
||||
self.coordinator.api.async_set_fan_mode(self.property_id, fan_mode)
|
||||
)
|
||||
|
||||
async def async_set_swing_mode(self, swing_mode: str) -> None:
|
||||
"""Set new swing mode."""
|
||||
_LOGGER.debug(
|
||||
"[%s:%s] async_set_swing_mode: %s",
|
||||
self.coordinator.device_name,
|
||||
self.property_id,
|
||||
swing_mode,
|
||||
)
|
||||
await self.async_call_api(
|
||||
self.coordinator.api.async_set_swing_mode(
|
||||
self.property_id, SWING_TO_STR.get(swing_mode)
|
||||
)
|
||||
)
|
||||
|
||||
async def async_set_swing_horizontal_mode(self, swing_horizontal_mode: str) -> None:
|
||||
"""Set new swing horizontal mode."""
|
||||
_LOGGER.debug(
|
||||
"[%s:%s] async_set_swing_horizontal_mode: %s",
|
||||
self.coordinator.device_name,
|
||||
self.property_id,
|
||||
swing_horizontal_mode,
|
||||
)
|
||||
await self.async_call_api(
|
||||
self.coordinator.api.async_set_swing_horizontal_mode(
|
||||
self.property_id, SWING_TO_STR.get(swing_horizontal_mode)
|
||||
)
|
||||
)
|
||||
|
||||
def _round_by_step(self, temperature: float) -> float:
|
||||
"""Round the value by step."""
|
||||
if (
|
||||
|
@ -20,6 +20,14 @@
|
||||
'preset_modes': list([
|
||||
'air_clean',
|
||||
]),
|
||||
'swing_horizontal_modes': list([
|
||||
'on',
|
||||
'off',
|
||||
]),
|
||||
'swing_modes': list([
|
||||
'on',
|
||||
'off',
|
||||
]),
|
||||
'target_temp_step': 1,
|
||||
}),
|
||||
'config_entry_id': <ANY>,
|
||||
@ -44,7 +52,7 @@
|
||||
'original_name': None,
|
||||
'platform': 'lg_thinq',
|
||||
'previous_unique_id': None,
|
||||
'supported_features': <ClimateEntityFeature: 411>,
|
||||
'supported_features': <ClimateEntityFeature: 955>,
|
||||
'translation_key': <ExtendedProperty.CLIMATE_AIR_CONDITIONER: 'climate_air_conditioner'>,
|
||||
'unique_id': 'MW2-2E247F93-B570-46A6-B827-920E9E10F966_climate_air_conditioner',
|
||||
'unit_of_measurement': None,
|
||||
@ -73,7 +81,17 @@
|
||||
'preset_modes': list([
|
||||
'air_clean',
|
||||
]),
|
||||
'supported_features': <ClimateEntityFeature: 411>,
|
||||
'supported_features': <ClimateEntityFeature: 955>,
|
||||
'swing_horizontal_mode': 'off',
|
||||
'swing_horizontal_modes': list([
|
||||
'on',
|
||||
'off',
|
||||
]),
|
||||
'swing_mode': 'off',
|
||||
'swing_modes': list([
|
||||
'on',
|
||||
'off',
|
||||
]),
|
||||
'target_temp_high': None,
|
||||
'target_temp_low': None,
|
||||
'target_temp_step': 1,
|
||||
|
Loading…
x
Reference in New Issue
Block a user