Skip to content

Commit

Permalink
Fix index issue with WEEK_PROGRAM_POINTER (#2027)
Browse files Browse the repository at this point in the history
* Use ParamsetKey enum in tests

* Fix index issue with WEEK_PROGRAM_POINTER
  • Loading branch information
SukramJ authored Jan 30, 2025
1 parent 18eaecb commit e175f34
Show file tree
Hide file tree
Showing 14 changed files with 224 additions and 179 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# Version 2025.1.20 (2025-01-30)

- Fix index issue with WEEK_PROGRAM_POINTER
- Use ParamsetKey enum in tests

# Version 2025.1.19 (2025-01-29)

- Don't read on unavailable devices
Expand Down
2 changes: 1 addition & 1 deletion hahomematic/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import re
from typing import Any, Final, NamedTuple, Required, TypedDict

VERSION: Final = "2025.1.19"
VERSION: Final = "2025.1.20"

# default
DEFAULT_CUSTOM_ID: Final = "custom_id"
Expand Down
2 changes: 1 addition & 1 deletion hahomematic/model/custom/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ async def set_profile(self, profile: ClimateProfile, collector: CallParameterCol
if self.mode != ClimateMode.AUTO:
await self.set_mode(mode=ClimateMode.AUTO, collector=collector)
await self._dp_boost_mode.send_value(value=False, collector=collector)
if profile_idx := self._profiles.get(profile):
if (profile_idx := self._profiles.get(profile)) is not None:
await self._dp_week_program_pointer.send_value(
value=_HM_WEEK_PROFILE_POINTERS_TO_NAMES[profile_idx], collector=collector
)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from hahomematic.central import CentralUnit
from hahomematic.client import Client
from hahomematic.const import DataPointUsage
from hahomematic.const import DataPointUsage, ParamsetKey
from hahomematic.model.generic import DpAction

from tests import helper
Expand Down Expand Up @@ -52,14 +52,14 @@ async def test_hmaction(
await action.send_value("OPEN")
assert mock_client.method_calls[-1] == call.set_value(
channel_address="VCU9724704:1",
paramset_key="VALUES",
paramset_key=ParamsetKey.VALUES,
parameter="LOCK_TARGET_LEVEL",
value=2,
)
await action.send_value(1)
assert mock_client.method_calls[-1] == call.set_value(
channel_address="VCU9724704:1",
paramset_key="VALUES",
paramset_key=ParamsetKey.VALUES,
parameter="LOCK_TARGET_LEVEL",
value=1,
)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_button.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

from hahomematic.central import CentralUnit
from hahomematic.client import Client
from hahomematic.const import DataPointUsage, ProgramData
from hahomematic.const import DataPointUsage, ParamsetKey, ProgramData
from hahomematic.model.generic import DpButton
from hahomematic.model.hub import ProgramDpButton

Expand Down Expand Up @@ -54,7 +54,7 @@ async def test_hmbutton(
await button.press()
assert mock_client.method_calls[-1] == call.set_value(
channel_address="VCU1437294:1",
paramset_key="VALUES",
paramset_key=ParamsetKey.VALUES,
parameter="RESET_MOTION",
value=True,
)
Expand Down
62 changes: 31 additions & 31 deletions tests/test_central.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,20 @@ async def test_identify_ip_addr(
@pytest.mark.parametrize(
("line", "parameter", "channel_no", "paramset_key", "expected_result"),
[
("", "LEVEL", 1, "VALUES", False),
("LEVEL", "LEVEL", 1, "VALUES", True),
("VALVE_ADAPTION", "VALVE_ADAPTION", 1, "VALUES", True),
("ACTIVE_PROFILE", "ACTIVE_PROFILE", 1, "VALUES", True),
("LEVEL@HmIP-eTRV-2:1:VALUES", "LEVEL", 1, "VALUES", False),
("LEVEL@HmIP-eTRV-2", "LEVEL", 1, "VALUES", False),
("LEVEL@@HmIP-eTRV-2", "LEVEL", 1, "VALUES", False),
("HmIP-eTRV-2:1:MASTER", "LEVEL", 1, "VALUES", False),
("LEVEL:VALUES@all:all", "LEVEL", 1, "VALUES", True),
("LEVEL:VALUES@HmIP-eTRV-2:all", "LEVEL", 1, "VALUES", True),
("LEVEL:VALUES@all:1", "LEVEL", 1, "VALUES", True),
("LEVEL:VALUES@all", "LEVEL", 1, "VALUES", False),
("LEVEL::VALUES@all:1", "LEVEL", 1, "VALUES", False),
("LEVEL:VALUES@all::1", "LEVEL", 1, "VALUES", False),
("", "LEVEL", 1, ParamsetKey.VALUES, False),
("LEVEL", "LEVEL", 1, ParamsetKey.VALUES, True),
("VALVE_ADAPTION", "VALVE_ADAPTION", 1, ParamsetKey.VALUES, True),
("ACTIVE_PROFILE", "ACTIVE_PROFILE", 1, ParamsetKey.VALUES, True),
("LEVEL@HmIP-eTRV-2:1:VALUES", "LEVEL", 1, ParamsetKey.VALUES, False),
("LEVEL@HmIP-eTRV-2", "LEVEL", 1, ParamsetKey.VALUES, False),
("LEVEL@@HmIP-eTRV-2", "LEVEL", 1, ParamsetKey.VALUES, False),
("HmIP-eTRV-2:1:MASTER", "LEVEL", 1, ParamsetKey.VALUES, False),
("LEVEL:VALUES@all:all", "LEVEL", 1, ParamsetKey.VALUES, True),
("LEVEL:VALUES@HmIP-eTRV-2:all", "LEVEL", 1, ParamsetKey.VALUES, True),
("LEVEL:VALUES@all:1", "LEVEL", 1, ParamsetKey.VALUES, True),
("LEVEL:VALUES@all", "LEVEL", 1, ParamsetKey.VALUES, False),
("LEVEL::VALUES@all:1", "LEVEL", 1, ParamsetKey.VALUES, False),
("LEVEL:VALUES@all::1", "LEVEL", 1, ParamsetKey.VALUES, False),
],
)
@pytest.mark.asyncio
Expand Down Expand Up @@ -203,12 +203,12 @@ async def test_device_un_ignore_etrv(
@pytest.mark.parametrize(
("line", "parameter", "channel_no", "paramset_key", "expected_result"),
[
("LEVEL", "LEVEL", 3, "VALUES", True),
("LEVEL@HmIP-BROLL:3:VALUES", "LEVEL", 3, "VALUES", False),
("LEVEL:VALUES@HmIP-BROLL:3", "LEVEL", 3, "VALUES", True),
("LEVEL:VALUES@all:3", "LEVEL", 3, "VALUES", True),
("LEVEL:VALUES@all:3", "LEVEL", 4, "VALUES", False),
("LEVEL:VALUES@HmIP-BROLL:all", "LEVEL", 3, "VALUES", True),
("LEVEL", "LEVEL", 3, ParamsetKey.VALUES, True),
("LEVEL@HmIP-BROLL:3:VALUES", "LEVEL", 3, ParamsetKey.VALUES, False),
("LEVEL:VALUES@HmIP-BROLL:3", "LEVEL", 3, ParamsetKey.VALUES, True),
("LEVEL:VALUES@all:3", "LEVEL", 3, ParamsetKey.VALUES, True),
("LEVEL:VALUES@all:3", "LEVEL", 4, ParamsetKey.VALUES, False),
("LEVEL:VALUES@HmIP-BROLL:all", "LEVEL", 3, ParamsetKey.VALUES, True),
],
)
@pytest.mark.asyncio
Expand Down Expand Up @@ -247,7 +247,7 @@ async def test_device_un_ignore_broll(
"GLOBAL_BUTTON_LOCK:MASTER@HM-TC-IT-WM-W-EU:",
"GLOBAL_BUTTON_LOCK",
None,
"MASTER",
ParamsetKey.MASTER,
True,
),
],
Expand Down Expand Up @@ -284,15 +284,15 @@ async def test_device_un_ignore_hm(
@pytest.mark.parametrize(
("lines", "parameter", "channel_no", "paramset_key", "expected_result"),
[
(["DECISION_VALUE:VALUES@all:all"], "DECISION_VALUE", 3, "VALUES", True),
(["INHIBIT:VALUES@HM-ES-PMSw1-Pl:1"], "INHIBIT", 1, "VALUES", True),
(["WORKING:VALUES@all:all"], "WORKING", 1, "VALUES", True),
(["AVERAGING:MASTER@HM-ES-PMSw1-Pl:2"], "AVERAGING", 2, "MASTER", True),
(["DECISION_VALUE:VALUES@all:all"], "DECISION_VALUE", 3, ParamsetKey.VALUES, True),
(["INHIBIT:VALUES@HM-ES-PMSw1-Pl:1"], "INHIBIT", 1, ParamsetKey.VALUES, True),
(["WORKING:VALUES@all:all"], "WORKING", 1, ParamsetKey.VALUES, True),
(["AVERAGING:MASTER@HM-ES-PMSw1-Pl:2"], "AVERAGING", 2, ParamsetKey.MASTER, True),
(
["DECISION_VALUE:VALUES@all:all", "AVERAGING:MASTER@HM-ES-PMSw1-Pl:2"],
"DECISION_VALUE",
3,
"VALUES",
ParamsetKey.VALUES,
True,
),
(
Expand All @@ -304,7 +304,7 @@ async def test_device_un_ignore_hm(
],
"DECISION_VALUE",
3,
"VALUES",
ParamsetKey.VALUES,
True,
),
(
Expand All @@ -316,21 +316,21 @@ async def test_device_un_ignore_hm(
],
"AVERAGING",
2,
"MASTER",
ParamsetKey.MASTER,
True,
),
(
["DECISION_VALUE", "INHIBIT:VALUES", "WORKING", "AVERAGING:MASTER@HM-ES-PMSw1-Pl:2"],
"AVERAGING",
2,
"MASTER",
ParamsetKey.MASTER,
True,
),
(
["DECISION_VALUE", "INHIBIT:VALUES", "WORKING", "AVERAGING:MASTER@HM-ES-PMSw1-Pl:2"],
"DECISION_VALUE",
3,
"VALUES",
ParamsetKey.VALUES,
True,
),
],
Expand Down Expand Up @@ -794,7 +794,7 @@ async def test_central_services(
values={"LEVEL": 1.0},
)
assert mock_client.method_calls[-1] == call.put_paramset(
channel_address="123", paramset_key_or_link_address="VALUES", values={"LEVEL": 1.0}
channel_address="123", paramset_key_or_link_address=ParamsetKey.VALUES, values={"LEVEL": 1.0}
)
assert len(mock_client.method_calls) == 65
with pytest.raises(HaHomematicException):
Expand Down
Loading

0 comments on commit e175f34

Please sign in to comment.