@Suty Thanks for your help. That worked!
For the record, here is my corrected Python code:
def my_function():
Fetch data from WeatherFlow
response_weatherflow = requests.get(weatherflow_url)
weatherflow_data = response_weatherflow.json()
Prepare data for Windy.com
tempheight=3
windheight=3
dewpoint=weatherflow_data['obs'][0]['dew_point']
uv=weatherflow_data['obs'][0]['uv']
ts=weatherflow_data['obs'][0]['timestamp']
winddir=weatherflow_data['obs'][0]['wind_direction']
wind=weatherflow_data['obs'][0]['wind_avg']
gust=weatherflow_data['obs'][0]['wind_gust']
windgustdir=weatherflow_data['obs'][0]['wind_direction']
winddir_avg2m=weatherflow_data['obs'][0]['wind_direction']
rh=weatherflow_data['obs'][0]['relative_humidity']
temp=weatherflow_data['obs'][0]['air_temperature']
precip=weatherflow_data['obs'][0]['precip_accum_last_1hr']
mbar=weatherflow_data['obs'][0]['station_pressure']
URL for Windy.com data
windy_url = f'https://stations.windy.com/pws/update/{windy_personal_access_key}?dewpoint={dewpoint}&uv={uv}&ts={ts}&winddir={winddir}&wind={wind}&gust={gust}&windgustdir={windgustdir}&winddir_avg2m={winddir_avg2m}&rh={rh}&temp={temp}&precip={precip}&mbar={mbar}'
Post data to Windy.com
response_windy = requests.get(url=windy_url)
Check response
if response_windy.status_code == 200:
print(current_time,"Data successfully shared with Windy.com")
else:
print("Error sharing data with Windy.com:", response_windy.text)
while True:
my_function()
time.sleep(300)