Author Topic: Apps Script from Wunderground to Windy.com, PWSWeather, OWM, WindGuru, and CWOP  (Read 3514 times)

0 Members and 1 Guest are viewing this topic.

Offline xd1936

  • Member
  • *
  • Posts: 27
    • About Me
Hello all!

I've built a solution that periodically grabs data directly from the new Wunderground API and forwards it on to Windy.com, PWSWeather, OpenWeatherMap, WindGuru, and/or NOAA CWOP. It's built on the free Google Apps Script infrastructure and is available on Github:

https://github.com/leoherzog/WundergroundStationForwarder

I've been developing and using it for a few years now and it's pretty battle-tested. Give it a try and let me know your thoughts!
« Last Edit: July 17, 2023, 12:05:14 PM by xd1936 »

Offline wxarrmgt

  • Member
  • *
  • Posts: 9
Great idea. Myacurite question:  Hub/Station info is needed. I tried
   const acuriteUsername = 'xxxxxxx@gmail.com';
   const acuritePassword = 'xxxxxxxxx';
   const acuriteHubName = 'Access';
   const acuriteStationName = 'Atlas';
Get following:
   Problem with the received payload: "undefined" is not valid JSON
I've tried using MAC address names in the myacurite app to no avail.


Offline wxarrmgt

  • Member
  • *
  • Posts: 9
Using the MyAcurite app: This (device names in app) doesn't work either (same error):
  const acuriteHubName = 'Access1667';
  const acuriteStationName = 'AcuRite Atlas';

But now the "schedule" run works showing data.

Offline wxarrmgt

  • Member
  • *
  • Posts: 9
Data is being transferred to CWOP and MyAcurite even with that error persisting.

Offline xd1936

  • Member
  • *
  • Posts: 27
    • About Me
@wxarrmgt If you uncomment Lines 230, 277, and 284 (remove the `//`), and look in the logs again (in the ☰▶ Executions tab) for the `refreshFromAcurite_` function runs, what do you see?

Offline wxarrmgt

  • Member
  • *
  • Posts: 9
"Running" and then "completed. But the execution log still has the error (Problem with the received payload: "undefined" is not valid JSON).

I note that the lines I uncomented were one line off from the line numbers you indicated.

Offline DoctorKnow

  • Forecaster
  • *****
  • Posts: 2067
Why not take out the myacurite and put in the IBM column above your Wunderground account and API key? Log into your wunderground account and go to member settings, then click the API keys tab.

Offline xd1936

  • Member
  • *
  • Posts: 27
    • About Me
If you are using the MyAcurite integration with Wunderground, then yes, @DoctorKnow's suggestion could also work... but IBM rotates those keys every few months and does other user-hostile BS. I'm currently using the MyAcurite data source in one of my instances of this code and it's still working...

@wxarrmgt, to be clear, the only line is the red error line? If so, that means that it's not getting a token... Double-check your email address and password for MyAcurite are correct.

Offline wxarrmgt

  • Member
  • *
  • Posts: 9
Everything seems to work except for getting the same red line error. I'll keep checking everything.
And thank you very much for this script!!

Offline wxarrmgt

  • Member
  • *
  • Posts: 9
One other thing. I'm at 7200 ft elevation, and the acurite access box reports station pressure rather than sea level pressure. I have to add about 6.88 inHg to the value to make it sea-level pressure (approximately since that offset is temperature dependent) which I think CWOP wants (looking at other close-by stations). I modified the block at about line 320 in Code.gs:

if (pressure != null) {
  let addedPressure = Number(pressure.last_reading_value) + 6.88;
  conditions.pressure = {
    "inHg": pressure.chart_unit === 'inHg' ? addedPressure.toFixedNumber(3) : addedPressure.hPaToinHg().toFixedNumber(3),
    "hPa": pressure.chart_unit === 'hPa' ? addedPressure.toFixedNumber(0) : addedPressure.inHgTohPa().toFixedNumber(0)
  };
}

Seems to work ok.

Offline xd1936

  • Member
  • *
  • Posts: 27
    • About Me
@wxarrmgt Wait, so it's working but you're still getting the errors? Are there failures in the Execution log?

 [ You are not allowed to view attachments ]

vs.

 [ You are not allowed to view attachments ]

Offline wxarrmgt

  • Member
  • *
  • Posts: 9
Yup. The only time I see the error is once when I click "Run". Here's [ You are not allowed to view attachments ]  my Executions page:

Offline xd1936

  • Member
  • *
  • Posts: 27
    • About Me
@wxarrmgt Are you selecting "Schedule" or "doPost" from the dropdown before clicking "▷ Run"?

Offline wxarrmgt

  • Member
  • *
  • Posts: 9
DoPost. When I select "schedule" and run, it outputs data without errors.

Offline xd1936

  • Member
  • *
  • Posts: 27
    • About Me
@wxarrmgt No need to select the doPost one, that's only used if you need to use a custom data source. "Schedule" is the one that you want. Cool, I'll clarify that in the instructions.

Offline wxarrmgt

  • Member
  • *
  • Posts: 9
Thanks again for the assistance!