Skip to content

Commit

Permalink
New way to check for a valid login + fix for no event_loop in the upd…
Browse files Browse the repository at this point in the history
…ater thread
  • Loading branch information
Joshua Mulliken committed Jun 30, 2021
1 parent fc94ba0 commit 9fcf372
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
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.19
version = 0.1.0-beta.20
author = Mulliken LLC
author_email = [email protected]
description = Python client for private Wyze API
Expand Down
2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ sonar.organization=joshuamulliken

# This is the name and version displayed in the SonarCloud UI.
sonar.projectName=wyzeapy
sonar.projectVersion=0.1.0-beta.19
sonar.projectVersion=0.1.0-beta.20

# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows.
#sonar.sources=.
Expand Down
7 changes: 5 additions & 2 deletions src/wyzeapy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ async def login(self, email, password):
self._token['access_token'] = self._client.net_client.access_token
self._token['refresh_token'] = self._client.net_client.refresh_token

@property
async def valid_login(self):
@classmethod
async def valid_login(cls, email: str, password: str) -> bool:
self = cls()
self._client = Client(email, password)
await self._client.async_init()
return self._client.valid_login

@property
Expand Down
2 changes: 1 addition & 1 deletion src/wyzeapy/services/sensor_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ async def register_for_updates(self, sensor: Sensor, callback: Callable[[Sensor]
self._subscribers.append((sensor, callback))

def update_worker(self):
loop = asyncio.get_event_loop()
loop = asyncio.new_event_loop()
while True:
if len(self._subscribers) < 1:
time.sleep(0.1)
Expand Down

0 comments on commit 9fcf372

Please sign in to comment.