Author Topic: Problem with new WL API and Google Apps Script  (Read 523 times)

0 Members and 1 Guest are viewing this topic.

Offline sunray

  • Member
  • *
  • Posts: 1
Problem with new WL API and Google Apps Script
« on: November 16, 2018, 09:11:13 AM »
Hello,
I have a simple setup where a Google Apps script reads the data from the Weatherlink API to a Google Sheets spreadsheet using the IMPORTDATA function. I.e. the sheet looks like this:

A1 https://api.weatherlink.com/v1/NoaaExt.xml?user=DID&pass=ownerpass&apiToken=Token
A2 =importdata(A1)

This results in the WL XML "current conditions" data page being downloaded into the spreadsheet below the above mentioned rows. The data fields are then parsed to get nicely formatted data in a separate tab in the worksheet. The script for this repeats every 10 minutes.

At first sight this works OK, but I noticed a major problem: The XML page is sometimes randomly missing one or several text rows!
This results in erroneous data fields, as the data parsing functions copy the data from fixed row locations, and when there are rows missing in the XML they read the wrong data.

Anyone who has experienced this and can assist? I previously had the script simply read the old Weatherlink.com summary data page, but as the new page is password protected it's much more difficult, therefore the API route.

Offline johnd

  • Forecaster
  • *****
  • Posts: 4849
    • www.weatherstations.co.uk
Re: Problem with new WL API and Google Apps Script
« Reply #1 on: November 16, 2018, 09:59:28 AM »
If I was doing this I'd be tempted to use the JSON API for weatherlink.com and parse the JSON into the spreadsheet using some JSON library. But maybe an equivalent XML library exists and could work just as well. Assuming that the text lines in a download are always going to be consistent and unchanging is fraught with problems. Here's a link that a quick Google throws up:

https://thisdavej.com/consuming-json-web-data-using-google-sheets/
Prodata Weather Systems
Prodata's FAQ/support site for Davis stations
Includes many details on 6313 Weatherlink console.
UK Davis Premier Dealer - All Davis stations, accessories and spares
Cambridge UK

Sorry, but I don't usually have time to help with individual issues by email unless you are a Prodata customer. Please post your issue in the relevant forum section here & I will comment there if I have anything useful to add.

 

anything