It looks like you may have based your code off the snippet I shared here: Basic Python websockets example to retrieve current Tempest data. If that is the case, the code I shared was not designed to receive multiple messages from the Websocket, and the same is true in the code you shared. Once you have sent the listen command, ws.recv() is only called once, and therefore you will only receive a single message.
If you want to remain connected and listen to new messages continuously, you need to wrap ws.recv() inside a while loop. Something like this will work (don’t forget to enter values for the personal_token and tempest_ID):
Sorry to butt in with a question from left field. Am I interpreting this code correctly when I ask: It appears to me that this is setting up a listening socket… this seems to imply that the device is sending data instead of reacting to a connection and sent data. Is this correct? Is the remote device (the weatherflow server) doing a push instead of the local device doing a pull, so to speak? If so, is there setup involved to make this happen?
Thank you Gary… out of curiosity, does the hub send the UDP packets or does the server at the weatherflow facility send the packets after communicating with the hub?
The hub sends the UDP packets. I had to tell my Wi-Fi access points to broadcast them so my Meteobridge and ArchiveWS on an RPi could receive them since they were not wired.
The code snippet I shared above creates a client connection to the WeatherFlow websocket server (different to UDP). Once the connection is set up, new messages are pushed automatically to the client by the remote server. There is no ongoing requirement for the client to issue data requests to the server. If you want the client to use a pull model instead, then the REST API is the place to go. For both the Websocket and REST API the data flow is:
Device (Tempest/Sky etc) → Hub → (internet) → WeatherFlow server → (internet, push or pull) → Client
If you don’t want the internet to be involved at all, then instead you can listen for the UDP messages that are broadcast by the hub over the local network it is connected to. This is a push model similar to the Websocket. For UDP, the data flow is: