Skip to content

Commit

Permalink
Make validation for climate schedules optional (#1775)
Browse files Browse the repository at this point in the history
  • Loading branch information
SukramJ authored Oct 15, 2024
1 parent 518b94c commit 41d74a6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 9 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Version 2024.10.8 (2024-10-12)
# Version 2024.10.8 (2024-10-15)

- Add services to copy climate schedules
- Make validation for climate schedules optional

# Version 2024.10.7 (2024-10-12)

Expand Down
8 changes: 7 additions & 1 deletion hahomematic/central/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,13 @@ def get_device(self, address: str) -> HmDevice | None:
d_address = get_device_address(address=address)
return self._devices.get(d_address)

def get_entity_by_custom_id(self, custom_id: str) -> CallbackEntity | None:
"""Return homematic entity by custom_id."""
for entity in self.get_entities(registered=True):
if entity.custom_id == custom_id:
return entity
return None

def get_entities(
self,
platform: HmPlatform | None = None,
Expand All @@ -670,7 +677,6 @@ def get_entities(
platform=platform, exclude_no_create=exclude_no_create, registered=registered
)
)

return tuple(all_entities)

def get_readable_generic_entities(
Expand Down
26 changes: 19 additions & 7 deletions hahomematic/platforms/custom/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ async def copy_schedule_profile(
target_channel_address=target_climate_entity.channel.address,
profile=target_profile,
profile_data=source_profile_data,
do_validate=False,
)

@service()
Expand Down Expand Up @@ -466,20 +467,26 @@ async def _get_schedule_profile(

@service()
async def set_schedule_profile(
self, profile: ScheduleProfile, profile_data: PROFILE_DICT
self, profile: ScheduleProfile, profile_data: PROFILE_DICT, do_validate: bool = True
) -> None:
"""Set a profile to device."""
await self._set_schedule_profile(
target_channel_address=self._channel.address,
profile=profile,
profile_data=profile_data,
do_validate=do_validate,
)

async def _set_schedule_profile(
self, target_channel_address: str, profile: ScheduleProfile, profile_data: PROFILE_DICT
self,
target_channel_address: str,
profile: ScheduleProfile,
profile_data: PROFILE_DICT,
do_validate: bool,
) -> None:
"""Set a profile to device."""
self._validate_schedule_profile(profile=profile, profile_data=profile_data)
if do_validate:
self._validate_schedule_profile(profile=profile, profile_data=profile_data)
schedule_data: _SCHEDULE_DICT = {}
for weekday, weekday_data in profile_data.items():
for slot_no, slot in weekday_data.items():
Expand Down Expand Up @@ -513,12 +520,17 @@ async def set_simple_schedule_profile(

@service()
async def set_schedule_profile_weekday(
self, profile: ScheduleProfile, weekday: ScheduleWeekday, weekday_data: WEEKDAY_DICT
self,
profile: ScheduleProfile,
weekday: ScheduleWeekday,
weekday_data: WEEKDAY_DICT,
do_validate: bool = True,
) -> None:
"""Store a profile to device."""
self._validate_schedule_profile_weekday(
profile=profile, weekday=weekday, weekday_data=weekday_data
)
if do_validate:
self._validate_schedule_profile_weekday(
profile=profile, weekday=weekday, weekday_data=weekday_data
)
schedule_data: _SCHEDULE_DICT = {}
for slot_no, slot in weekday_data.items():
for slot_type, slot_value in slot.items():
Expand Down

0 comments on commit 41d74a6

Please sign in to comment.