Skip to content

Commit

Permalink
Merge pull request #1 from donfrensis/feature-v1.1.7-vertical-position
Browse files Browse the repository at this point in the history
Add support for 5 fixed vertical vane positions
  • Loading branch information
donfrensis authored Nov 13, 2024
2 parents 2326cec + 570eda6 commit 2e9e33e
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 18 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
58 changes: 41 additions & 17 deletions custom_components/intesishome_local/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
from __future__ import annotations

import logging
import asyncio
from random import randrange
from typing import NamedTuple

from pyintesishome import (
Expand Down Expand Up @@ -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
Expand All @@ -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 = {
Expand Down Expand Up @@ -110,6 +124,7 @@ async def async_setup_entry(
],
update_before_add=True,
)

class IntesisAC(ClimateEntity):
"""Represents an Intesishome air conditioning device."""

Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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."""
Expand All @@ -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."""
Expand Down
2 changes: 1 addition & 1 deletion custom_components/intesishome_local/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit 2e9e33e

Please sign in to comment.