I’m relatively new to Python and wondered whether anyone could point me to a very basic example of retrieving current data from my Tempest using Python websockets. To get started, all I want to do is open a socket, get the current data from my Tempest in the console and close the socket. I’ve been trying to use the online documentation, but I haven’t been successful. There’s something missing in my understanding of the process and I’m hoping a simple example will get me over the the hump. Thanks for any help provided!
This is the simplest example I could come up with. It will connect to the Websocket, start listening for Tempest messages, and then disconnect once it has received a single data message:
from websocket import create_connection
personal_token = ' '
tempest_ID = ' '
print('Opening Websocket connection...')
ws = create_connection('wss://ws.weatherflow.com/swd/data?api_key=' + personal_token)
result = ws.recv()
print("Received '%s'" % result)
print('')
print('Listening to Tempest endpoint...')
ws.send('{"type":"listen_start",' + ' "device_id":' + tempest_ID + ',' + ' "id":"Tempest"}')
result = ws.recv()
print("Received '%s'" % result)
print('')
print('Receiving Tempest data...')
result = ws.recv()
print("Received '%s'" % result)
print('')
ws.close()
You need to install the Python websockets module with python3 -m pip install websocket-client (https://pypi.org/project/websocket_client/) and in the code above you need to enter a personal access token and device ID of your Tempest as strings. Hope this help
That’s a BIG help…thanks! I got it working just fine. Now that I see how it works, I think the online documentation will make more sense to me. I really appreciate the help!
Did you ever get this working? Not working for me. I’m trying to get the data from my station, which I can see is uploading wind data every few seconds:
But this slightly modified version of the above Python script never gets any data, it just sits on “Listening to Tempest endpoint…”
#!/usr/bin/python
# pip install websocket-client
import websocket
personal_token = '[REMOVED]'
tempest_ID = '54330'
print('Opening Websocket connection...')
# I added this line, turns on extra logging -wb
websocket.enableTrace(True)
ws = websocket.create_connection('wss://ws.weatherflow.com/swd/data?api_key=' + personal_token)
result = ws.recv()
print("Received '%s'" % result)
print('')
print('Listening to Tempest endpoint...')
ws.send('{"type":"listen_start",' + ' "device_id":' + tempest_ID + ',' + ' "id":"2098388936"}') # changed id from "Tempest" -wb
result = ws.recv()
print("Received '%s'" % result)
print('')
print('Receiving Tempest data...')
result = ws.recv()
print("Received '%s'" % result)
print('')
ws.close()
I tried changing the “tempest_ID” from “Tempest” to “2098388936”, which the docs say will return all data:
But no luck. Here’s the output. Note that I turned on “enableTrace” so this has more output than the original example:
[iad1-shared-b7-30]$ ./tempestReader.py
Opening Websocket connection...
--- request header ---
GET /swd/data?api_key=[REMOVED] HTTP/1.1
Upgrade: websocket
Host: ws.weatherflow.com
Origin: https://ws.weatherflow.com
Sec-WebSocket-Key: [REMOVED]
Sec-WebSocket-Version: 13
Connection: Upgrade
-----------------------
--- response header ---
HTTP/1.1 101 Web Socket Protocol Handshake
Date: Sun, 21 Dec 2025 21:21:17 GMT
Connection: upgrade
Server: Payara Server 6.2023.2 #badassfish
X-Powered-By: Servlet/6.0 JSP/3.1 (Payara Server 6.2023.2 #badassfish Java/Amazon.com Inc./11)
Sec-WebSocket-Accept: IOid/LUoqdN/3cIowhCccH/PlUM=
Upgrade: websocket
-----------------------
++Rcv raw: b'\x81\x1c{"type":"connection_opened"}'
++Rcv decoded: fin=1 opcode=1 data=b'{"type":"connection_opened"}'
Received '{"type":"connection_opened"}'
Listening to Tempest endpoint...
++Sent raw: b'\x81\xbd\xc7\xbd\x18e\xbc\x9fl\x1c\xb7\xd8:_\xe5\xd1q\x16\xb3\xd8v:\xb4\xc9y\x17\xb3\x9f4E\xe5\xd9}\x13\xae\xde}:\xae\xd9:_\xf2\x89+V\xf7\x918G\xae\xd9:_\xe5\x8f(\\\xff\x8e ]\xfe\x8e.G\xba'
++Sent decoded: fin=1 opcode=1 data=b'{"type":"listen_start", "device_id":54330, "id":"2098388936"}'
Or maybe I’m misunderstanding what the websocket method is supposed to do? Ultimately I’m trying to build a small display that shows the wind data every few seconds, like a standard weather station physical display.
Yes, I was able to get my Python script to work. It gets Tempest data and then uses that data to calculate ET0. You can see my Python script here:
Thanks for that. Looks like you abandoned the websockets method. I was just doing the same when you responded. Oh well, back to good ol polling. And thanks for your script.
And are you able to get frequent updates? Looking at my public dashboard I can see the wind speed changing every 3 or so seconds. But when polling the API I only get an update about once a minute.
I’m using obs[0][“wind_avg”] for the wind speed.
Here’s a sample reply from my weather station:
My Python script runs only once per hour. Since you’re using wind_avg data from the Tempest, I wonder how often it’s actually polling the wind speed sensor.
Tried using wind_gust too, which shouldn’t be averages, but it’s only updating once per minute as well.
Have you tried folks at Tempest to see if they can tell you how often data is updated?
Looks like the API is limited to 1 minute updates. Oh well, I guess they’re worried about server load. Can get more frequent updates if you’re on the same LAN as the weather station using other methods though.
Good to know…thanks!
The websocket integration only sends observation data back once per minute. Rain and lightning events are triggered whenever they happen.
To get wind readings in real time, you need to sniff the UDP messages from your hub which are broadcast over your local network. Here is a sample Python program Simple-WeatherFlow-Python-Listener/weatherflow_listener.py at master · MABeatty1978/Simple-WeatherFlow-Python-Listener · GitHub