-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding logging to the sensor_service.py
- Loading branch information
Joshua Mulliken
committed
Jun 30, 2021
1 parent
281b5e7
commit abdf02b
Showing
3 changed files
with
7 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
[metadata] | ||
# replace with your username: | ||
name = wyzeapy | ||
version = 0.1.0-beta.17 | ||
version = 0.1.0-beta.18 | ||
author = Mulliken LLC | ||
author_email = [email protected] | ||
description = Python client for private Wyze API | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,13 +4,16 @@ | |
# the license with this file. If not, please write to: | ||
# [email protected] to receive a copy | ||
import asyncio | ||
import logging | ||
import time | ||
from threading import Thread | ||
from typing import List, Callable, Tuple, Optional | ||
|
||
from wyzeapy.services.base_service import BaseService | ||
from wyzeapy.types import Device, PropertyIDs | ||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
class Sensor(Device): | ||
detected: bool = False | ||
|
@@ -38,6 +41,7 @@ async def update(self, sensor: Sensor) -> Sensor: | |
return sensor | ||
|
||
async def register_for_updates(self, sensor: Sensor, callback: Callable[[Sensor], None]): | ||
_LOGGER.debug(f"Registering sensor: {sensor.nickname} for updates") | ||
if not self._updater_thread: | ||
self._updater_thread = Thread(target=self.update_worker, daemon=True) | ||
|
||
|
@@ -50,6 +54,7 @@ def update_worker(self): | |
time.sleep(0.1) | ||
else: | ||
for sensor, callback in self._subscribers: | ||
_LOGGER.debug(f"Providing update for {sensor.nickname}") | ||
callback(asyncio.run_coroutine_threadsafe(self.update(sensor), loop).result()) | ||
|
||
async def get_sensors(self) -> List[Sensor]: | ||
|