From 5cf4fb9a7045e080461afcb80333ed6935b5fc99 Mon Sep 17 00:00:00 2001 From: Joshua Mulliken Date: Thu, 17 Jun 2021 23:48:58 -0400 Subject: [PATCH] Adding logging to publish/subscribe --- setup.cfg | 2 +- sonar-project.properties | 2 +- src/wyzeapy/client.py | 5 +++++ 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/setup.cfg b/setup.cfg index 954479b..20b9dd4 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,7 +1,7 @@ [metadata] # replace with your username: name = wyzeapy -version = 0.0.31-beta.18 +version = 0.0.31-beta.19 author = Mulliken LLC author_email = joshua@mulliken.net description = Python client for private Wyze API diff --git a/sonar-project.properties b/sonar-project.properties index f7a77ff..f3e3f05 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -3,7 +3,7 @@ sonar.organization=joshuamulliken # This is the name and version displayed in the SonarCloud UI. sonar.projectName=wyzeapy -sonar.projectVersion=0.0.31-beta.18 +sonar.projectVersion=0.0.31-beta.19 # Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. #sonar.sources=. diff --git a/src/wyzeapy/client.py b/src/wyzeapy/client.py index 32e3452..19a1b0c 100644 --- a/src/wyzeapy/client.py +++ b/src/wyzeapy/client.py @@ -7,6 +7,7 @@ import logging import time from asyncio import Task +from builtins import function from typing import Any, Optional, List, Tuple, Iterable, Dict from .base_client import NetClient @@ -149,11 +150,13 @@ async def register_for_sensor_updates(self, callback, sensor): async def sensor_update_publisher(self): while True: + _LOGGER.debug("Updating sensors") sensors = await self.get_sensors(force_update=True) for callback, sensor in self._subscribers: for i in sensors: if i.mac == sensor.mac: + _LOGGER.debug(f"Updating {i.mac}") callback(i) raise RuntimeError(f"Unable to find sensor with mac: {sensor.mac}") @@ -284,11 +287,13 @@ async def register_for_event_updates(self, callback, device): async def event_update_publisher(self): while True: + _LOGGER.debug("Updating events") raw_events = (await self.net_client.get_full_event_list(10))['data']['event_list'] latest_events = [Event(raw_event) for raw_event in raw_events] for callback, device in self._event_subscribers: if event := self.return_event_for_device(device, latest_events) is not None: + _LOGGER.debug(f"Updating {device.mac}") callback(event) async def get_latest_event(self, device: Device) -> Optional[Event]: