Add support for swing horizontal mode for mqtt climate (#139303)

* Add support for swing horizontal mode for mqtt climate

* Fix import
This commit is contained in:
Jan Bouwhuis
2025-02-26 15:44:16 +01:00
committed by GitHub
parent 7e97ef588b
commit 5324f3e542
5 changed files with 174 additions and 4 deletions

View File

@@ -11,6 +11,7 @@ from homeassistant.components.climate import (
ATTR_HUMIDITY,
ATTR_HVAC_MODE,
ATTR_PRESET_MODE,
ATTR_SWING_HORIZONTAL_MODE,
ATTR_SWING_MODE,
ATTR_TARGET_TEMP_HIGH,
ATTR_TARGET_TEMP_LOW,
@@ -20,10 +21,11 @@ from homeassistant.components.climate import (
SERVICE_SET_HUMIDITY,
SERVICE_SET_HVAC_MODE,
SERVICE_SET_PRESET_MODE,
SERVICE_SET_SWING_HORIZONTAL_MODE,
SERVICE_SET_SWING_MODE,
SERVICE_SET_TEMPERATURE,
HVACMode,
)
from homeassistant.components.climate.const import HVACMode
from homeassistant.const import (
ATTR_ENTITY_ID,
ATTR_TEMPERATURE,
@@ -211,6 +213,20 @@ def set_operation_mode(
hass.services.call(DOMAIN, SERVICE_SET_HVAC_MODE, data)
async def async_set_swing_horizontal_mode(
hass: HomeAssistant, swing_horizontal_mode: str, entity_id: str = ENTITY_MATCH_ALL
) -> None:
"""Set new target swing horizontal mode."""
data = {ATTR_SWING_HORIZONTAL_MODE: swing_horizontal_mode}
if entity_id is not None:
data[ATTR_ENTITY_ID] = entity_id
await hass.services.async_call(
DOMAIN, SERVICE_SET_SWING_HORIZONTAL_MODE, data, blocking=True
)
async def async_set_swing_mode(
hass: HomeAssistant, swing_mode: str, entity_id: str = ENTITY_MATCH_ALL
) -> None: