diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ea8cea..4205454 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +# Changelog + +## [1.1.7] - Unreleased +### Added +- Added support for 5 fixed vertical vane positions: position1 to position5 +- Improved swing mode control to handle both swing motion and fixed positions + ## [1.1.6] - 2024-11-11 ### Fixed - Fixed connection test logic in configuration flow diff --git a/custom_components/intesishome_local/climate.py b/custom_components/intesishome_local/climate.py index 47193e6..a4ceb41 100644 --- a/custom_components/intesishome_local/climate.py +++ b/custom_components/intesishome_local/climate.py @@ -2,8 +2,6 @@ from __future__ import annotations import logging -import asyncio -from random import randrange from typing import NamedTuple from pyintesishome import ( @@ -45,6 +43,15 @@ _LOGGER = logging.getLogger(__name__) +# Added preset positions mapping +VANE_POSITIONS = { + "position1": "manual1", + "position2": "manual2", + "position3": "manual3", + "position4": "manual4", + "position5": "manual5" +} + class SwingSettings(NamedTuple): """Settings for swing mode.""" vvane: str @@ -69,11 +76,18 @@ class SwingSettings(NamedTuple): IH_SWING_STOP = "auto/stop" IH_SWING_SWING = "swing" + +# Updated swing mapping to include all positions MAP_SWING_TO_IH = { SWING_OFF: SwingSettings(vvane=IH_SWING_STOP, hvane=IH_SWING_STOP), SWING_BOTH: SwingSettings(vvane=IH_SWING_SWING, hvane=IH_SWING_SWING), SWING_HORIZONTAL: SwingSettings(vvane=IH_SWING_STOP, hvane=IH_SWING_SWING), SWING_VERTICAL: SwingSettings(vvane=IH_SWING_SWING, hvane=IH_SWING_STOP), + "position1": SwingSettings(vvane="manual1", hvane=IH_SWING_STOP), + "position2": SwingSettings(vvane="manual2", hvane=IH_SWING_STOP), + "position3": SwingSettings(vvane="manual3", hvane=IH_SWING_STOP), + "position4": SwingSettings(vvane="manual4", hvane=IH_SWING_STOP), + "position5": SwingSettings(vvane="manual5", hvane=IH_SWING_STOP), } MAP_STATE_ICONS = { @@ -110,6 +124,7 @@ async def async_setup_entry( ], update_before_add=True, ) + class IntesisAC(ClimateEntity): """Represents an Intesishome air conditioning device.""" @@ -169,9 +184,16 @@ def __init__( self._attr_supported_features |= ClimateEntityFeature.TURN_ON self._attr_supported_features |= ClimateEntityFeature.TURN_OFF - # Setup swing list + # Setup swing list with positions if controller.has_vertical_swing(ih_device_id): - self._swing_list.append(SWING_VERTICAL) + self._swing_list.extend([ + SWING_VERTICAL, + "position1", + "position2", + "position3", + "position4", + "position5" + ]) if controller.has_horizontal_swing(ih_device_id): self._swing_list.append(SWING_HORIZONTAL) if SWING_HORIZONTAL in self._swing_list and SWING_VERTICAL in self._swing_list: @@ -433,19 +455,6 @@ def fan_mode(self): """Return whether the fan is on.""" return self._fan_speed - @property - def swing_mode(self): - """Return current swing mode.""" - if self._vvane == IH_SWING_SWING and self._hvane == IH_SWING_SWING: - swing = SWING_BOTH - elif self._vvane == IH_SWING_SWING: - swing = SWING_VERTICAL - elif self._hvane == IH_SWING_SWING: - swing = SWING_HORIZONTAL - else: - swing = SWING_OFF - return swing - @property def fan_modes(self): """List of available fan modes.""" @@ -456,6 +465,21 @@ def swing_modes(self): """List of available swing positions.""" return self._swing_list + @property + def swing_mode(self): + """Return current swing mode.""" + if self._vvane == IH_SWING_SWING and self._hvane == IH_SWING_SWING: + return SWING_BOTH + elif self._vvane == IH_SWING_SWING: + return SWING_VERTICAL + elif self._hvane == IH_SWING_SWING: + return SWING_HORIZONTAL + elif self._vvane in ["manual1", "manual2", "manual3", "manual4", "manual5"]: + for position, value in VANE_POSITIONS.items(): + if value == self._vvane: + return position + return SWING_OFF + @property def available(self) -> bool: """If the device hasn't been able to connect, mark as unavailable.""" diff --git a/custom_components/intesishome_local/manifest.json b/custom_components/intesishome_local/manifest.json index f9a2d70..d3b5ecd 100644 --- a/custom_components/intesishome_local/manifest.json +++ b/custom_components/intesishome_local/manifest.json @@ -9,5 +9,5 @@ "issue_tracker": "https://github.com/donfrensis/HA-intesishome-local/issues", "loggers": ["pyintesishome"], "requirements": ["pyintesishome==1.8.5"], - "version": "1.1.6" + "version": "1.1.7" } \ No newline at end of file