Skip to content

Commit 04934be

Browse files
committed
Break-out _get_plugwise_notifications(), replace _update_domain_objects()
1 parent 3b40c3c commit 04934be

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

plugwise/__init__.py

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -537,14 +537,18 @@ async def _smile_detect(self, result: etree, dsmrmain: etree) -> None:
537537
if result.find(locator_2) is not None:
538538
self._elga = True
539539

540-
async def _update_domain_objects(self) -> None:
541-
"""Helper-function for smile.py: full_update_device() and async_update().
542-
543-
Request domain_objects data.
544-
"""
540+
async def _full_update_device(self) -> None:
541+
"""Perform a first fetch of all XML data, needed for initialization."""
545542
self._domain_objects = await self._request(DOMAIN_OBJECTS)
543+
self._get_plugwise_notifications()
544+
self._locations = await self._request(LOCATIONS)
545+
self._modules = await self._request(MODULES)
546+
# P1 legacy has no appliances
547+
if not (self.smile_type == "power" and self._smile_legacy):
548+
self._appliances = await self._request(APPLIANCES)
546549

547-
# If Plugwise notifications present:
550+
def _get_plugwise_notifications(self) -> None:
551+
"""Collect the Plugwise notifications."""
548552
self._notifications = {}
549553
for notification in self._domain_objects.findall("./notification"):
550554
try:
@@ -559,15 +563,6 @@ async def _update_domain_objects(self) -> None:
559563
f"{self._endpoint}{DOMAIN_OBJECTS}",
560564
)
561565

562-
async def _full_update_device(self) -> None:
563-
"""Perform a first fetch of all XML data, needed for initialization."""
564-
await self._update_domain_objects()
565-
self._locations = await self._request(LOCATIONS)
566-
self._modules = await self._request(MODULES)
567-
# P1 legacy has no appliances
568-
if not (self.smile_type == "power" and self._smile_legacy):
569-
self._appliances = await self._request(APPLIANCES)
570-
571566
async def async_update(self) -> PlugwiseData:
572567
"""Perform an incremental update for updating the various device states."""
573568
# Perform a full update at day-change
@@ -585,7 +580,8 @@ async def async_update(self) -> PlugwiseData:
585580
self.get_all_devices()
586581
# Otherwise perform an incremental update
587582
else:
588-
await self._update_domain_objects()
583+
self._domain_objects = await self._request(DOMAIN_OBJECTS)
584+
self._get_plugwise_notifications()
589585
match self._target_smile:
590586
case "smile_v2":
591587
self._modules = await self._request(MODULES)

0 commit comments

Comments
 (0)