Skip to content

Commit

Permalink
Rename example and various improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
jotonedev committed Oct 6, 2024
1 parent f0b081c commit d837e93
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 1 deletion.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
import logging

from pyown.client.base import BaseClient
from pyown.client import BaseClient
from pyown.messages import MessageType, DimensionRequest
from pyown.tags import Who, Where, Dimension

Expand All @@ -25,11 +25,15 @@ async def run(host: str, port: int, password: str):
)
)
)

# Parse response
for msg in resp:
# The gateway will respond with NACK when the message contains an error, or it's not supported
if msg.type == MessageType.NACK:
print("The server did not accept the request")
return
else:
# Sometimes the gateway will send with the response an ACK to confirm the request was successful
if msg.type == MessageType.ACK:
print(f"The server accepted the request")
else:
Expand Down
1 change: 1 addition & 0 deletions pyown/client/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from .base import BaseClient
1 change: 1 addition & 0 deletions pyown/client/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def __init__(
port (int): The port to connect to
password (str): The password to authenticate with
session_type (SessionType): The session type to use
loop (Optional[AbstractEventLoop]): The event loop to use
"""
self._host = host
self._port = port
Expand Down
File renamed without changes.

0 comments on commit d837e93

Please sign in to comment.