Skip to content

Commit

Permalink
Update docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
denpamusic committed Oct 30, 2024
1 parent 8051350 commit 04657eb
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions docs/source/connecting.rst
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,22 @@ working with device classes and queues.
async def main():
"""Open a connection and request alerts."""
async with pyplumio.open_tcp_connection(
host="localhost", port=8899, protocol=pyplumio.DummyProtocol
host="localhost", port=8899, protocol=pyplumio.DummyProtocol()
) as connection:
await connection.writer.write(
requests.AlertsRequest(recipient=DeviceType.ECOMAX, start=0, count=5)
)
while connection.connected:
if isinstance(
(frame := await connection.reader.read()), responses.AlertsResponse
):
print(frame.data)
break
try:
if isinstance(
(frame := await connection.reader.read()), responses.AlertsResponse
):
print(frame.data)
break
except pyplumio.ProtocolError:
# Skip protocol errors and read the next frame.
pass
asyncio.run(main())
Expand Down

0 comments on commit 04657eb

Please sign in to comment.