Skip to content

Commit

Permalink
Allow partial profiles (#1765)
Browse files Browse the repository at this point in the history
  • Loading branch information
SukramJ authored Oct 11, 2024
1 parent 54d6e46 commit 1959e0c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 16 deletions.
10 changes: 2 additions & 8 deletions hahomematic/platforms/custom/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -444,11 +444,9 @@ def _validate_and_convert_simple_to_profile(
) -> PROFILE_DICT:
"""Convert simple profile dict to profile dict."""
profile_dict: PROFILE_DICT = {}
for day in ScheduleWeekday:
if day not in simple_profile_data:
raise ValidationException(f"VALIDATE_SIMPLE_PROFILE: {day} missing in profile")
for day, simple_weekday_list in simple_profile_data.items():
profile_dict[day] = self._validate_and_convert_simple_to_profile_weekday(
base_temperature=base_temperature, simple_weekday_list=simple_profile_data[day]
base_temperature=base_temperature, simple_weekday_list=simple_weekday_list
)
return profile_dict

Expand Down Expand Up @@ -509,10 +507,6 @@ def _validate_and_convert_simple_to_profile_weekday(

def _validate_profile(self, profile: ScheduleProfile, profile_data: PROFILE_DICT) -> None:
"""Validate the profile."""
for day in ScheduleWeekday:
if day not in profile_data:
raise ValidationException(f"VALIDATE_PROFILE: {day} missing in profile")

for weekday, weekday_data in profile_data.items():
self._validate_profile_weekday(
profile=profile, weekday=weekday, weekday_data=weekday_data
Expand Down
15 changes: 7 additions & 8 deletions tests/test_climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,11 +685,10 @@ async def test_climate_ip_with_pydevccu(central_unit_mini) -> None:
},
)

with pytest.raises(ValidationException):
await climate_bwth.set_simple_profile(
profile="P1",
base_temperature=16.0,
simple_profile_data={
"MONDAY": [],
},
)
await climate_bwth.set_simple_profile(
profile="P1",
base_temperature=16.0,
simple_profile_data={
"MONDAY": [],
},
)

0 comments on commit 1959e0c

Please sign in to comment.