Skip to content

Commit

Permalink
Add noise API transport support (#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
OttoWinter authored Sep 8, 2021
1 parent 5065638 commit 015e9c8
Show file tree
Hide file tree
Showing 5 changed files with 308 additions and 63 deletions.
5 changes: 5 additions & 0 deletions aioesphomeapi/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ def __init__(
client_info: str = "aioesphomeapi",
keepalive: float = 15.0,
zeroconf_instance: ZeroconfInstanceType = None,
noise_psk: Optional[str] = None,
):
self._params = ConnectionParams(
eventloop=eventloop,
Expand All @@ -133,6 +134,7 @@ def __init__(
client_info=client_info,
keepalive=keepalive,
zeroconf_instance=zeroconf_instance,
noise_psk=noise_psk,
)
self._connection: Optional[APIConnection] = None
self._cached_name: Optional[str] = None
Expand Down Expand Up @@ -305,6 +307,7 @@ async def subscribe_logs(
self,
on_log: Callable[[SubscribeLogsResponse], None],
log_level: Optional[LogLevel] = None,
dump_config: Optional[bool] = None,
) -> None:
self._check_authenticated()

Expand All @@ -315,6 +318,8 @@ def on_msg(msg: message.Message) -> None:
req = SubscribeLogsRequest()
if log_level is not None:
req.level = log_level
if dump_config is not None:
req.dump_config = dump_config
assert self._connection is not None
await self._connection.send_message_callback_response(req, on_msg)

Expand Down
Loading

0 comments on commit 015e9c8

Please sign in to comment.