Skip to content

Instantly share code, notes, and snippets.

@tomvdb
Created July 15, 2022 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomvdb/ad80d1a0d6bcf3a12c725b1c398ba65b to your computer and use it in GitHub Desktop.
Save tomvdb/ad80d1a0d6bcf3a12c725b1c398ba65b to your computer and use it in GitHub Desktop.
Longmynd Websocket send command example
# example python script for sending commands to client websocket - https://github.com/philcrump/longmynd
# zr6tg
import websockets
import asyncio
import json
class LongmyndControl:
def __init__(self):
self.websocket = None
async def start(self):
self.websocket = await websockets.connect("ws://192.168.0.35:8080", subprotocols=['control'])
async def sendCommand(self, cmd):
await self.websocket.send(cmd)
async def main():
lm = LongmyndControl()
await lm.start()
# commands found in : https://github.com/philcrump/longmynd/blob/master/web/web.c
# command examples:
#print("Change RF Port to 0")
#await lm.sendCommand("T0")
#print("Change Frequency")
#await lm.sendCommand("C741521,1500")
#await lm.sendCommand("F1,10499250,333,9749982")
#await lm.sendCommand("F2,10491535,1500,9749982")
await lm.sendCommand("U3,192.168.0.105")
while True:
await asyncio.sleep(1)
if __name__ == "__main__":
asyncio.run(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment