Advertisement
tomstevens

python simple websockets listener

Nov 26th, 2022
1,023
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | Software | 0 0
  1. # C:\temp\python3.9\Scripts> pip install websockets
  2. # used for debuging Shelly 1 plus device
  3. # turn on Device -> Debug -> Websocket debug:
  4.  
  5. import websockets
  6. import asyncio
  7.  
  8. print("Hello!")
  9.  
  10. async def listen():
  11.     url = "ws://192.168.0.199/debug/log"
  12.     async with websockets.connect(url) as ws:
  13.         while True:
  14.             msg = await ws.recv()
  15.             print(msg)
  16.  
  17. asyncio.get_event_loop().run_until_complete(listen())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement