diff --git a/pyproject.toml b/pyproject.toml index a50df8e..9446c28 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "tadoasync" -version = "0.1.19" +version = "0.1.20" authors = ["Erwin Douna "] classifiers = [ "Development Status :: 5 - Production/Stable", diff --git a/src/tadoasync/models.py b/src/tadoasync/models.py index 9a3d1c1..b621de5 100644 --- a/src/tadoasync/models.py +++ b/src/tadoasync/models.py @@ -3,6 +3,7 @@ from __future__ import annotations from dataclasses import dataclass, field +from enum import Enum from typing import Any from mashumaro import field_options @@ -301,29 +302,79 @@ class Capabilities(DataClassORJSONMixin): heat: HeatAC | None = field(metadata=field_options(alias="HEAT"), default=None) +class VerticalSwing(Enum): + """VerticalSwing model represents the vertical swing modes of a zone.""" + + OFF = "OFF" + MID_UP = "MID_UP" + MID_DOWN = "MID_DOWN" + ON = "ON" + DOWN = "DOWN" + UP = "UP" + MID = "MID" + + +class HorizontalSwing(Enum): + """HorizontalSwing model represents the horizontal swing modes of a zone.""" + + OFF = "OFF" + ON = "ON" + RIGHT = "RIGHT" + LEFT = "LEFT" + MID_RIGHT = "MID_RIGHT" + MID_LEFT = "MID_LEFT" + + +class FanLevel(Enum): + """FanLevel model represents the fan levels of a zone.""" + + AUTO = "AUTO" + LEVEL1 = "LEVEL1" + LEVEL2 = "LEVEL2" + LEVEL3 = "LEVEL3" + LEVEL4 = "LEVEL4" + LEVEL5 = "LEVEL5" + SILENT = "SILENT" + + +class Light(Enum): + """Light model represents the light settings of a zone.""" + + ON = "ON" + OFF = "OFF" + + @dataclass class AutoAC(DataClassORJSONMixin): """AutoAC model represents the auto AC capabilities of a zone.""" - fan_speeds: list[str] | None = field( - default=None, metadata=field_options(alias="fanSpeeds") + fan_level: list[FanLevel] | None = field( + default=None, metadata=field_options(alias="fanLevel") ) - swing_modes: list[str] | None = field( - default=None, metadata=field_options(alias="swings") + vertical_swing: list[VerticalSwing] | None = field( + default=None, metadata=field_options(alias="verticalSwing") ) - light: str | None = None + horizontal_swing: list[HorizontalSwing] | None = field( + default=None, metadata=field_options(alias="horizontalSwing") + ) + light: list[Light] | None = None + temperatures: Temperatures | None = None @dataclass class CoolAC(DataClassORJSONMixin): """CoolAC model represents the cool AC capabilities of a zone.""" - fan_speeds: list[str] | None = field( - default=None, metadata=field_options(alias="fanSpeeds") + fan_level: list[FanLevel] | None = field( + default=None, metadata=field_options(alias="fanLevel") ) - swing_modes: list[str] | None = field( - default=None, metadata=field_options(alias="swings") + vertical_swing: list[VerticalSwing] | None = field( + default=None, metadata=field_options(alias="verticalSwing") + ) + horizontal_swing: list[HorizontalSwing] | None = field( + default=None, metadata=field_options(alias="horizontalSwing") ) + light: list[Light] | None = None temperatures: Temperatures | None = None @@ -331,33 +382,50 @@ class CoolAC(DataClassORJSONMixin): class DryAC(DataClassORJSONMixin): """DryAC model represents the dry AC capabilities of a zone.""" - swing_modes: list[str] | None = field( - default=None, metadata=field_options(alias="swings") + fan_level: list[FanLevel] | None = field( + default=None, metadata=field_options(alias="fanLevel") ) + vertical_swing: list[VerticalSwing] | None = field( + default=None, metadata=field_options(alias="verticalSwing") + ) + horizontal_swing: list[HorizontalSwing] | None = field( + default=None, metadata=field_options(alias="horizontalSwing") + ) + light: list[Light] | None = None + temperatures: Temperatures | None = None @dataclass class FanAC(DataClassORJSONMixin): """FanAC model represents the fan AC capabilities of a zone.""" - fan_speeds: list[str] | None = field( - default=None, metadata=field_options(alias="fanSpeeds") + fan_level: list[FanLevel] | None = field( + default=None, metadata=field_options(alias="fanLevel") ) - swing_modes: list[str] | None = field( - default=None, metadata=field_options(alias="swings") + vertical_swing: list[VerticalSwing] | None = field( + default=None, metadata=field_options(alias="verticalSwing") ) + horizontal_swing: list[HorizontalSwing] | None = field( + default=None, metadata=field_options(alias="horizontalSwing") + ) + light: list[Light] | None = None + temperatures: Temperatures | None = None @dataclass class HeatAC(DataClassORJSONMixin): """HeatAC model represents the heat AC capabilities of a zone.""" - fan_speeds: list[str] | None = field( - default=None, metadata=field_options(alias="fanSpeeds") + fan_level: list[FanLevel] | None = field( + default=None, metadata=field_options(alias="fanLevel") + ) + vertical_swing: list[VerticalSwing] | None = field( + default=None, metadata=field_options(alias="verticalSwing") ) - swing_modes: list[str] | None = field( - default=None, metadata=field_options(alias="swings") + horizontal_swing: list[HorizontalSwing] | None = field( + default=None, metadata=field_options(alias="horizontalSwing") ) + light: list[Light] | None = None temperatures: Temperatures | None = None diff --git a/src/tadoasync/tadoasync.py b/src/tadoasync/tadoasync.py index d7423d2..713ac7b 100644 --- a/src/tadoasync/tadoasync.py +++ b/src/tadoasync/tadoasync.py @@ -581,6 +581,7 @@ async def update_zone_data(self, data: ZoneState) -> None: # pylint: disable=to ) else: data.current_hvac_mode = CONST_MODE_SMART_SCHEDULE + data.overlay_active = False # Default to false if no overlay data.connection = ( getattr(data.connection_state, "value", None) diff --git a/tests/__snapshots__/test_tado.ambr b/tests/__snapshots__/test_tado.ambr index 64010a0..63c2326 100644 --- a/tests/__snapshots__/test_tado.ambr +++ b/tests/__snapshots__/test_tado.ambr @@ -39,71 +39,267 @@ # name: test_get_capabilities_ac dict({ 'auto': dict({ - 'fan_speeds': list([ - 'AUTO', - 'HIGH', - 'MIDDLE', - 'LOW', - ]), + 'fan_level': None, + 'horizontal_swing': None, + 'light': None, + 'temperatures': None, + 'vertical_swing': None, + }), + 'can_set_temperature': None, + 'cool': dict({ + 'fan_level': None, + 'horizontal_swing': None, + 'light': None, + 'temperatures': dict({ + 'celsius': dict({ + 'max': 30.0, + 'min': 18.0, + 'step': 1.0, + }), + 'fahrenheit': dict({ + 'max': 86.0, + 'min': 64.0, + 'step': 1.0, + }), + }), + 'vertical_swing': None, + }), + 'dry': dict({ + 'fan_level': None, + 'horizontal_swing': None, + 'light': None, + 'temperatures': None, + 'vertical_swing': None, + }), + 'fan': dict({ + 'fan_level': None, + 'horizontal_swing': None, 'light': None, - 'swing_modes': list([ - 'OFF', - 'ON', + 'temperatures': None, + 'vertical_swing': None, + }), + 'heat': dict({ + 'fan_level': None, + 'horizontal_swing': None, + 'light': None, + 'temperatures': dict({ + 'celsius': dict({ + 'max': 30.0, + 'min': 16.0, + 'step': 1.0, + }), + 'fahrenheit': dict({ + 'max': 86.0, + 'min': 61.0, + 'step': 1.0, + }), + }), + 'vertical_swing': None, + }), + 'temperatures': None, + 'type': 'AIR_CONDITIONING', + }) +# --- +# name: test_get_capabilities_ac_new + dict({ + 'auto': dict({ + 'fan_level': list([ + , + , + , + , + , + , + , + ]), + 'horizontal_swing': list([ + , + , + , + , + , + , + ]), + 'light': list([ + , + , + ]), + 'temperatures': dict({ + 'celsius': dict({ + 'max': 30.0, + 'min': 16.0, + 'step': 1.0, + }), + 'fahrenheit': dict({ + 'max': 86.0, + 'min': 61.0, + 'step': 1.0, + }), + }), + 'vertical_swing': list([ + , + , + , + , + , + , + , ]), }), 'can_set_temperature': None, 'cool': dict({ - 'fan_speeds': list([ - 'AUTO', - 'HIGH', - 'MIDDLE', - 'LOW', + 'fan_level': list([ + , + , + , + , + , + , + , ]), - 'swing_modes': list([ - 'OFF', - 'ON', + 'horizontal_swing': list([ + , + , + , + , + , + , + ]), + 'light': list([ + , + , ]), 'temperatures': dict({ 'celsius': dict({ 'max': 30.0, - 'min': 18.0, + 'min': 16.0, 'step': 1.0, }), 'fahrenheit': dict({ 'max': 86.0, - 'min': 64.0, + 'min': 61.0, 'step': 1.0, }), }), + 'vertical_swing': list([ + , + , + , + , + , + , + , + ]), }), 'dry': dict({ - 'swing_modes': list([ - 'OFF', - 'ON', + 'fan_level': list([ + , + , + , + , + , + , + , + ]), + 'horizontal_swing': list([ + , + , + , + , + , + , + ]), + 'light': list([ + , + , + ]), + 'temperatures': dict({ + 'celsius': dict({ + 'max': 30.0, + 'min': 16.0, + 'step': 1.0, + }), + 'fahrenheit': dict({ + 'max': 86.0, + 'min': 61.0, + 'step': 1.0, + }), + }), + 'vertical_swing': list([ + , + , + , + , + , + , + , ]), }), 'fan': dict({ - 'fan_speeds': list([ - 'AUTO', - 'HIGH', - 'MIDDLE', - 'LOW', + 'fan_level': list([ + , + , + , + , + , + , + , + ]), + 'horizontal_swing': list([ + , + , + , + , + , + , ]), - 'swing_modes': list([ - 'OFF', - 'ON', + 'light': list([ + , + , + ]), + 'temperatures': dict({ + 'celsius': dict({ + 'max': 30.0, + 'min': 16.0, + 'step': 1.0, + }), + 'fahrenheit': dict({ + 'max': 86.0, + 'min': 61.0, + 'step': 1.0, + }), + }), + 'vertical_swing': list([ + , + , + , + , + , + , + , ]), }), 'heat': dict({ - 'fan_speeds': list([ - 'AUTO', - 'HIGH', - 'MIDDLE', - 'LOW', + 'fan_level': list([ + , + , + , + , + , + , + , + ]), + 'horizontal_swing': list([ + , + , + , + , + , + , ]), - 'swing_modes': list([ - 'OFF', - 'ON', + 'light': list([ + , + , ]), 'temperatures': dict({ 'celsius': dict({ @@ -117,6 +313,15 @@ 'step': 1.0, }), }), + 'vertical_swing': list([ + , + , + , + , + , + , + , + ]), }), 'temperatures': None, 'type': 'AIR_CONDITIONING', @@ -1397,7 +1602,7 @@ 'open_window_attr': None, 'open_window_detected': False, 'overlay': None, - 'overlay_active': True, + 'overlay_active': False, 'overlay_termination_timestamp': None, 'overlay_termination_type': None, 'overlay_type': None, @@ -1607,7 +1812,7 @@ 'open_window_attr': None, 'open_window_detected': False, 'overlay': None, - 'overlay_active': True, + 'overlay_active': False, 'overlay_termination_timestamp': None, 'overlay_termination_type': None, 'overlay_type': None, @@ -1715,7 +1920,7 @@ 'open_window_attr': None, 'open_window_detected': False, 'overlay': None, - 'overlay_active': True, + 'overlay_active': False, 'overlay_termination_timestamp': None, 'overlay_termination_type': None, 'overlay_type': None, @@ -2498,7 +2703,7 @@ 'open_window_attr': None, 'open_window_detected': False, 'overlay': None, - 'overlay_active': True, + 'overlay_active': False, 'overlay_termination_timestamp': None, 'overlay_termination_type': None, 'overlay_type': None, diff --git a/tests/fixtures/capabilities_ac_new.json b/tests/fixtures/capabilities_ac_new.json new file mode 100644 index 0000000..cebb38b --- /dev/null +++ b/tests/fixtures/capabilities_ac_new.json @@ -0,0 +1,93 @@ +{ + "type": "AIR_CONDITIONING", + "AUTO": { + "fanLevel": [ "AUTO", "LEVEL1", "LEVEL2", "LEVEL3", "LEVEL4", "LEVEL5", "SILENT" ], + "verticalSwing": ["OFF", "MID_UP", "MID_DOWN", "ON", "DOWN", "UP", "MID"], + "horizontalSwing": ["OFF", "ON", "RIGHT", "LEFT", "MID_RIGHT", "MID_LEFT"], + "light": ["OFF", "ON"], + "temperatures": { + "celsius": { + "min": 16, + "max": 30, + "step": 1.0 + }, + "fahrenheit": { + "min": 61, + "max": 86, + "step": 1.0 + } + } + }, + "COOL": { + "fanLevel": [ "AUTO", "LEVEL1", "LEVEL2", "LEVEL3", "LEVEL4", "LEVEL5", "SILENT" ], + "verticalSwing": ["OFF", "MID_UP", "MID_DOWN", "ON", "DOWN", "UP", "MID"], + "horizontalSwing": ["OFF", "ON", "RIGHT", "LEFT", "MID_RIGHT", "MID_LEFT"], + "light": ["OFF", "ON"], + "temperatures": { + "celsius": { + "min": 16, + "max": 30, + "step": 1.0 + }, + "fahrenheit": { + "min": 61, + "max": 86, + "step": 1.0 + } + } + }, + "DRY": { + "fanLevel": [ "AUTO", "LEVEL1", "LEVEL2", "LEVEL3", "LEVEL4", "LEVEL5", "SILENT" ], + "verticalSwing": ["OFF", "MID_UP", "MID_DOWN", "ON", "DOWN", "UP", "MID"], + "horizontalSwing": ["OFF", "ON", "RIGHT", "LEFT", "MID_RIGHT", "MID_LEFT"], + "light": ["OFF", "ON"], + "temperatures": { + "celsius": { + "min": 16, + "max": 30, + "step": 1.0 + }, + "fahrenheit": { + "min": 61, + "max": 86, + "step": 1.0 + } + } + }, + "FAN": { + "fanLevel": [ "AUTO", "LEVEL1", "LEVEL2", "LEVEL3", "LEVEL4", "LEVEL5", "SILENT" ], + "verticalSwing": ["OFF", "MID_UP", "MID_DOWN", "ON", "DOWN", "UP", "MID"], + "horizontalSwing": ["OFF", "ON", "RIGHT", "LEFT", "MID_RIGHT", "MID_LEFT"], + "light": ["OFF", "ON"], + "temperatures": { + "celsius": { + "min": 16, + "max": 30, + "step": 1.0 + }, + "fahrenheit": { + "min": 61, + "max": 86, + "step": 1.0 + } + } + }, + "HEAT": { + "fanLevel": [ "AUTO", "LEVEL1", "LEVEL2", "LEVEL3", "LEVEL4", "LEVEL5", "SILENT" ], + "verticalSwing": ["OFF", "MID_UP", "MID_DOWN", "ON", "DOWN", "UP", "MID"], + "horizontalSwing": ["OFF", "ON", "RIGHT", "LEFT", "MID_RIGHT", "MID_LEFT"], + "light": ["OFF", "ON"], + "temperatures": { + "celsius": { + "min": 16, + "max": 30, + "step": 1.0 + }, + "fahrenheit": { + "min": 61, + "max": 86, + "step": 1.0 + } + } + } +} diff --git a/tests/test_tado.py b/tests/test_tado.py index f34ef7d..fed6c5e 100644 --- a/tests/test_tado.py +++ b/tests/test_tado.py @@ -339,6 +339,18 @@ async def test_get_capabilities_ac( assert await python_tado.get_capabilities(1) == snapshot +async def test_get_capabilities_ac_new( + python_tado: Tado, responses: aioresponses, snapshot: SnapshotAssertion +) -> None: + """Test get capabilities.""" + responses.get( + f"{TADO_API_URL}/homes/1/zones/1/capabilities", + status=200, + body=load_fixture("capabilities_ac_new.json"), + ) + assert await python_tado.get_capabilities(1) == snapshot + + async def test_reset_zone_overlay_success( python_tado: Tado, responses: aioresponses ) -> None: