From 767b5390eaa374845f0f105218658d4d1c9c0339 Mon Sep 17 00:00:00 2001 From: Leo Herzog Date: Mon, 2 Dec 2024 16:57:50 -0500 Subject: [PATCH 1/5] Initial Stab at Ecowitt Support --- README.md | 65 +++++++++++++++++------------- code.gs | 117 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 152 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 585805c..4f1e2c1 100644 --- a/README.md +++ b/README.md @@ -79,14 +79,23 @@ and periodically sends it on to - Set your `ambientWeatherStationName` on line 27 - Set your `ambientWeatherApiKey` on Line 28 +
+ Ecowitt + + Uses the [Ecowitt.net](https://www.ecowitt.net/) API. + + - Set the `datasource` to `ecowitt` on Line 10 + - Set your `ecowittAPIKey` from your [Ecowitt.net Private Center](https://www.ecowitt.net/home/user) on Line 30 + - Set your `ecowittMacAddress` (find in your [Device List](https://www.ecowitt.net/home/manage)) on Line 31 +
aprs.fi (CWOP) Uses the [aprs.fi API](https://aprs.fi/page/api) to fetch APRS packet data from a CWOP station. - Set the `datasource` to `aprs` on Line 10 - - Set your `aprsStationID` on line 30 - - Set your `aprsApiKey` on Line 31 from [your aprs.fi account](https://aprs.fi/account/) + - Set your `aprsStationID` on line 33 + - Set your `aprsApiKey` on Line 34 from [your aprs.fi account](https://aprs.fi/account/)
Custom Data Source @@ -94,7 +103,7 @@ and periodically sends it on to Send weather station readings from any system in [RTL_433 JSON format](https://www.triq.org/rtl_433/DATA_FORMAT.html). - Set the `datasource` to `custom` on Line 10 - - Set your station's latitude and longitude on lines 33 and 34 in decimal degrees + - Set your station's latitude and longitude on lines 36 and 37 in decimal degrees - Click `Deploy ▼` → New deployment → '⚙' → Web app, and change 'Who has access' to 'Anyone' and press 'Deploy' - Begin HTTP POSTing JSON data to the `https://script.google.com/macros/...` URL provided in the confirmation dialog
@@ -106,27 +115,27 @@ and periodically sends it on to To send to [Wunderground](https://support.weather.com/s/article/PWS-Upload-Protocol): - - Set `updateWunderground` to `true` on Line 38 - - Set your `wundergroundAPIKey` on Line 39 - - Set your `wundergroundStationID` on line 40 + - Set `updateWunderground` to `true` on Line 41 + - Set your `wundergroundAPIKey` on Line 42 + - Set your `wundergroundStationID` on line 43
Windy.com To send to [Windy.com](https://community.windy.com/topic/8168/report-your-weather-station-data-to-windy): - - Set `updateWindy` to `true` on Line 42 - - Set your `windyAPIKey` on Line 43 - - Set your `windyStationID` on line 44. It's likely `0`, `1`, `2`, etc. + - Set `updateWindy` to `true` on Line 45 + - Set your `windyAPIKey` on Line 46 + - Set your `windyStationID` on line 47. It's likely `0`, `1`, `2`, etc.
Aeris PWSWeather To send to [PWSWeather](https://dashboard.pwsweather.com/): - - Set `updatePWSWeather` to `true` on Line 46 - - Set your `pwsWeatherAPIKey` from your station's profile page on line 47 - - Set your `pwsWeatherStationID` on Line 48 + - Set `updatePWSWeather` to `true` on Line 49 + - Set your `pwsWeatherAPIKey` from your station's profile page on line 50 + - Set your `pwsWeatherStationID` on Line 51
WeatherCloud @@ -135,19 +144,19 @@ and periodically sends it on to Retrieve your station's ID and API Key by going to [your Devices](https://app.weathercloud.net/devices), then clicking Settings → 🔌 Link on your station. - - Set `updateWeatherCloud` to `true` on Line 50 - - Set your `weathercloudAPIKey` on Line 51 - - Set your `weathercloudID` on Line 52 - - Set whether or not you have a WeatherCloud Pro or Premium account with `hasWeatherCloudPro` as `true` or `false` on line 53 + - Set `updateWeatherCloud` to `true` on Line 53 + - Set your `weathercloudAPIKey` on Line 54 + - Set your `weathercloudID` on Line 55 + - Set whether or not you have a WeatherCloud Pro or Premium account with `hasWeatherCloudPro` as `true` or `false` on line 56
OpenWeatherMap Creation of a new OpenWeatherMap station must be done by API, not on the OpenWeatherMap website. More information is available in [the OpenWeatherMap Station API documentation](https://openweathermap.org/stations#create_station). The basic concept for what must be done is available in the `createNewOWMStation_()` function. Remove the `_` character from the name of that function to make it selectable from the `▷ Run` button in the toolbar. If you do so, make sure you note your new station's ID and other details in the log (available in the Executions tab in the sidebar after running!), then: - - Set `updateOpenWeatherMap` to `true` on Line 55 - - Set `openWeatherMapAPIKey` to your [API Key](https://home.openweathermap.org/api_keys) on Line 56 - - Set your `openWeatherMapStationId` to [your OpenWeatherMap station's `external_id`](https://openweathermap.org/stations#create_station) on line 57 + - Set `updateOpenWeatherMap` to `true` on Line 58 + - Set `openWeatherMapAPIKey` to your [API Key](https://home.openweathermap.org/api_keys) on Line 59 + - Set your `openWeatherMapStationId` to [your OpenWeatherMap station's `external_id`](https://openweathermap.org/stations#create_station) on line 60
WindGuru @@ -156,9 +165,9 @@ and periodically sends it on to Start by [registering a new "Other / Upload API" station](https://stations.windguru.cz/register.php?id_type=16), then: - - Set `updateWindGuru` to `true` on Line 59 - - Set `windGuruStationUID` to your chosen [station UID](https://stations.windguru.cz/) on Line 60 - - Set your `windGuruStationPassword` to your chosen [station API password](https://stations.windguru.cz/) (note, not your _account's_ password) on line 61 + - Set `updateWindGuru` to `true` on Line 62 + - Set `windGuruStationUID` to your chosen [station UID](https://stations.windguru.cz/) on Line 63 + - Set your `windGuruStationPassword` to your chosen [station API password](https://stations.windguru.cz/) (note, not your _account's_ password) on line 64
Met (UK) WOW @@ -167,18 +176,18 @@ and periodically sends it on to Start by [registering a new Site](https://wow.metoffice.gov.uk/sites/create). During registration, one of the fields in your Site's options is "Authentication Key". Choose any 6-Digit number. Then: - - Set `updateWOW` to `true` on Line 63 - - Set `wowSiteID` to the generated [Site ID](https://wow.metoffice.gov.uk/sites) on Line 64 - - Set `wowAuthKey` to your chosen [6-Digit Authentication Key](https://wow.metoffice.gov.uk/sites) that you chose when creating or editing the Site on line 65 + - Set `updateWOW` to `true` on Line 66 + - Set `wowSiteID` to the generated [Site ID](https://wow.metoffice.gov.uk/sites) on Line 67 + - Set `wowAuthKey` to your chosen [6-Digit Authentication Key](https://wow.metoffice.gov.uk/sites) that you chose when creating or editing the Site on line 68
NOAA Citizen Weather Observer Program (CWOP) Send to [CWOP](https://madis.ncep.noaa.gov/madis_cwop.shtml). Start by [registering for a new station](https://madis.ncep.noaa.gov/madis_cwop.shtml), then when you receive your email: - - Set `updateCWOP` to `true` on Line 67 - - Set `cwopStationIDOrHamCallsign` to your assigned CWOP station ID that you received via email on Line 68 - - If you are using your ham radio callsign as your station ID and you have received a validation code from NOAA CWOP support, set `cwopValidationCode` to your validation code on Line 69 + - Set `updateCWOP` to `true` on Line 70 + - Set `cwopStationIDOrHamCallsign` to your assigned CWOP station ID that you received via email on Line 71 + - If you are using your ham radio callsign as your station ID and you have received a validation code from NOAA CWOP support, set `cwopValidationCode` to your validation code on Line 72
4. Run the "Schedule" function (not the "doPost" function) by selecting "Schedule" in the dropdown and pressing the `▷ Run` button in the toolbar. You're done! You can see it periodically running in the `☰▶` Executions tab on the left sidebar. This code is executed on Google's servers and does not require a computer to remain on. diff --git a/code.gs b/code.gs index e19be8d..49390f4 100644 --- a/code.gs +++ b/code.gs @@ -7,7 +7,7 @@ // Getting data -const datasource = 'weatherflow'; // 'ibm' (wunderground), 'acurite' (myacurite), 'davis' (weatherlink), 'weatherflow' (tempestwx), 'ambient' (ambient weather), 'aprs' (aprs.fi), or 'custom' (custom webhook in rtl_433 format) +const datasource = 'weatherflow'; // 'ibm' (wunderground), 'acurite' (myacurite), 'davis' (weatherlink), 'weatherflow' (tempestwx), 'ambient' (ambient weather), 'ecowitt', 'aprs' (aprs.fi), or 'custom' (custom webhook in rtl_433 format) const ibmAPIKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; const ibmStationID = 'KXXXXXXXXXX'; @@ -27,6 +27,9 @@ const weatherflowStationId = 'xxxxx'; const ambientWeatherStationName = 'xxxxxx'; const ambientWeatherApiKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; // or +const ecowittAPIKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; +const ecowittMacAddress = 'XX:XX:XX:XX:XX:XX'; +// or const aprsStationID = 'xxxxxx'; const aprsApiKey = 'xxxxxx.xxxxxxxxxxxxxxxx'; // or @@ -79,7 +82,7 @@ const cwopValidationCode = null; */ -let version = 'v2.8.2'; +let version = 'v2.9.0b1'; function Schedule() { if (updateWunderground && datasource === 'ibm' && ibmStationID === wundergroundStationID) throw 'Error: You are currently set to pull data from Wunderground and also send data to Wunderground. Please disable one or the other to avoid duplicate data.'; @@ -106,6 +109,10 @@ function Schedule() { refreshFromAmbientWeather_(); ScriptApp.newTrigger('refreshFromAmbientWeather_').timeBased().everyMinutes(1).create(); break; + case 'ecowitt': + refreshFromEcowitt_(); + ScriptApp.newTrigger('refreshFromEcowitt_').timeBased().everyMinutes(1).create(); + break; case 'aprs': refreshFromAPRSFI_(); ScriptApp.newTrigger('refreshFromAPRSFI_').timeBased().everyMinutes(1).create(); @@ -631,6 +638,112 @@ function refreshFromAmbientWeather_() { } +// doc.ecowitt.net +function refreshFromEcowitt_() { + + let ecowittConditions = fetchJSON_('https://api.ecowitt.net/api/v3/device/real_time?application_key=' + Utilities.newBlob(Utilities.base64Decode('MzA5RjIyQjRDM0NEQzQ4MUI2QjI2RUYyRTJEMUM3N0Q=')).getDataAsString() + '&api_key=' + ecowittAPIKey + '&mac=' + ecowittMacAddress + '&call_back=all&temp_unitid=2&pressure_unitid=4&wind_speed_unitid=9&rainfall_unitid=13&solar_irradiance_unitid=16'); + if (!ecowittConditions || ecowittConditions.code !== 0) return false; // still no luck? give up + // console.log(JSON.stringify(ecowittConditions)); + + let conditions = {}; + conditions.time = new Date(Number(ecowittConditions.time) * 1000).getTime(); + if (ecowittConditions.data?.outdoor) { + let outdoor = ecowittConditions.data.outdoor; + if (outdoor.temperature?.value) { + conditions.temp = { + "f": Number(outdoor.temperature.value).toFixedNumber(2), + "c": Number(outdoor.temperature.value).fToC().toFixedNumber(2) + }; + } + if (outdoor.dew_point?.value) { + conditions.dewpoint = { + "f": Number(outdoor.dew_point.value).toFixedNumber(2), + "c": Number(outdoor.dew_point.value).fToC().toFixedNumber(2) + }; + } + if (outdoor.humidity?.value) { + conditions.humidity = Number(outdoor.humidity.value).toFixedNumber(0); + } + } + if (ecowittConditions.data?.wind) { + let wind = ecowittConditions.data.wind; + if (wind.wind_speed?.value) { + conditions.windSpeed = { + "mph": Number(wind.wind_speed.value).toFixedNumber(2), + "mps": Number(wind.wind_speed.value).mphToMPS().toFixedNumber(2), + "kph": Number(wind.wind_speed.value).mphToKPH().toFixedNumber(2), + "knots": Number(wind.wind_speed.value).mphToKnots().toFixedNumber(2) + }; + } + if (wind.wind_gust?.value) { + conditions.windGust = { + "mph": Number(wind.wind_gust.value).toFixedNumber(2), + "mps": Number(wind.wind_gust.value).mphToMPS().toFixedNumber(2), + "kph": Number(wind.wind_gust.value).mphToKPH().toFixedNumber(2), + "knots": Number(wind.wind_gust.value).mphToKnots().toFixedNumber(2) + }; + } + if (wind.wind_direction?.value) { + conditions.winddir = Number(wind.wind_direction.value); + } + } + if (ecowittConditions.data?.pressure?.relative?.value) { + conditions.pressure = { + "inHg": Number(ecowittConditions.data.pressure.relative.value).toFixedNumber(3), + "hPa": Number(ecowittConditions.data.pressure.relative.value).inHgTohPa().toFixedNumber(0) + }; + } + if (ecowittConditions.data?.solar_and_uvi) { + let solar = ecowittConditions.data.solar_and_uvi; + if (solar.solar?.value) { + conditions.solarRadiation = Number(solar.solar.value); + } + if (solar.uvi?.value) { + conditions.uv = Number(solar.uvi.value); + } + } + if (ecowittConditions.data?.rainfall) { + let rain = ecowittConditions.data.rainfall; + if (rain.rain_rate?.value) { + conditions.precipRate = { + "in": Number(rain.rain_rate.value).toFixedNumber(3), + "mm": Number(rain.rain_rate.value).inTomm().toFixedNumber(2) + }; + } + if (rain.daily?.value) { + conditions.precipSinceMidnight = { + "in": Number(rain.daily.value).toFixedNumber(3), + "mm": Number(rain.daily.value).inTomm().toFixedNumber(2) + }; + } + if (rain.hourly?.value) { + conditions.precipLastHour = { + "in": Number(rain.hourly.value).toFixedNumber(3), + "mm": Number(rain.hourly.value).inTomm().toFixedNumber(2) + }; + } + } + if (conditions.temp && conditions.windSpeed) { + conditions.windChill = { + "f": conditions.temp.f.windChillF(conditions.windSpeed.mph).toFixedNumber(2), + "c": conditions.temp.c.windChillC(conditions.windSpeed.kph).toFixedNumber(2) + }; + } + if (conditions.temp && conditions.humidity) { + conditions.heatIndex = { + "f": conditions.temp.f.heatIndex(conditions.humidity, 'F').toFixedNumber(2), + "c": conditions.temp.c.heatIndex(conditions.humidity, 'C').toFixedNumber(2) + }; + } + + console.log(JSON.stringify(conditions)); + + CacheService.getScriptCache().put('conditions', JSON.stringify(conditions), 21600); + + return JSON.stringify(conditions); + +} + // https://aprs.fi/page/api function refreshFromAPRSFI() { From 8994c9495379efe22332d34ce24e6b39ea96de21 Mon Sep 17 00:00:00 2001 From: Leo Herzog Date: Mon, 2 Dec 2024 17:02:33 -0500 Subject: [PATCH 2/5] Add Ecowitt to Supported List --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4f1e2c1..2edac38 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ This code is built to be hosted on the free [Google Apps Script](https://develop - [Davis WeatherLink](https://weatherlink.com/), - [WeatherFlow Tempest](https://tempestwx.com/), - [Ambient Weather](https://ambientweather.net/), +- [Ecowitt](https://ecowitt.net/), - [aprs.fi (CWOP)](https://aprs.fi/), or - a custom data source in [RTL_433 JSON format](https://www.triq.org/rtl_433/DATA_FORMAT.html), From 709e7af774c04f3e36da8c6d3be87e19a876db6a Mon Sep 17 00:00:00 2001 From: Leo Herzog Date: Sat, 14 Dec 2024 18:58:19 -0500 Subject: [PATCH 3/5] Switch to User-Supplied Application Key --- README.md | 59 ++++++++++++++++++++++++++++--------------------------- code.gs | 5 +++-- 2 files changed, 33 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 2edac38..43416d3 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,8 @@ and periodically sends it on to - Set the `datasource` to `ecowitt` on Line 10 - Set your `ecowittAPIKey` from your [Ecowitt.net Private Center](https://www.ecowitt.net/home/user) on Line 30 - - Set your `ecowittMacAddress` (find in your [Device List](https://www.ecowitt.net/home/manage)) on Line 31 + - Set your `ecowittApplicationKey` from your [Ecowitt.net Private Center](https://www.ecowitt.net/home/user) on Line 32 + - Set your `ecowittMacAddress` (find in your [Device List](https://www.ecowitt.net/home/manage)) on Line 32
aprs.fi (CWOP) @@ -95,8 +96,8 @@ and periodically sends it on to Uses the [aprs.fi API](https://aprs.fi/page/api) to fetch APRS packet data from a CWOP station. - Set the `datasource` to `aprs` on Line 10 - - Set your `aprsStationID` on line 33 - - Set your `aprsApiKey` on Line 34 from [your aprs.fi account](https://aprs.fi/account/) + - Set your `aprsStationID` on line 34 + - Set your `aprsApiKey` on Line 35 from [your aprs.fi account](https://aprs.fi/account/)
Custom Data Source @@ -104,7 +105,7 @@ and periodically sends it on to Send weather station readings from any system in [RTL_433 JSON format](https://www.triq.org/rtl_433/DATA_FORMAT.html). - Set the `datasource` to `custom` on Line 10 - - Set your station's latitude and longitude on lines 36 and 37 in decimal degrees + - Set your station's latitude and longitude on lines 37 and 38 in decimal degrees - Click `Deploy ▼` → New deployment → '⚙' → Web app, and change 'Who has access' to 'Anyone' and press 'Deploy' - Begin HTTP POSTing JSON data to the `https://script.google.com/macros/...` URL provided in the confirmation dialog
@@ -116,27 +117,27 @@ and periodically sends it on to To send to [Wunderground](https://support.weather.com/s/article/PWS-Upload-Protocol): - - Set `updateWunderground` to `true` on Line 41 - - Set your `wundergroundAPIKey` on Line 42 - - Set your `wundergroundStationID` on line 43 + - Set `updateWunderground` to `true` on Line 42 + - Set your `wundergroundAPIKey` on Line 43 + - Set your `wundergroundStationID` on line 44
Windy.com To send to [Windy.com](https://community.windy.com/topic/8168/report-your-weather-station-data-to-windy): - - Set `updateWindy` to `true` on Line 45 - - Set your `windyAPIKey` on Line 46 - - Set your `windyStationID` on line 47. It's likely `0`, `1`, `2`, etc. + - Set `updateWindy` to `true` on Line 46 + - Set your `windyAPIKey` on Line 47 + - Set your `windyStationID` on line 48. It's likely `0`, `1`, `2`, etc.
Aeris PWSWeather To send to [PWSWeather](https://dashboard.pwsweather.com/): - - Set `updatePWSWeather` to `true` on Line 49 - - Set your `pwsWeatherAPIKey` from your station's profile page on line 50 - - Set your `pwsWeatherStationID` on Line 51 + - Set `updatePWSWeather` to `true` on Line 50 + - Set your `pwsWeatherAPIKey` from your station's profile page on line 51 + - Set your `pwsWeatherStationID` on Line 52
WeatherCloud @@ -145,19 +146,19 @@ and periodically sends it on to Retrieve your station's ID and API Key by going to [your Devices](https://app.weathercloud.net/devices), then clicking Settings → 🔌 Link on your station. - - Set `updateWeatherCloud` to `true` on Line 53 - - Set your `weathercloudAPIKey` on Line 54 - - Set your `weathercloudID` on Line 55 - - Set whether or not you have a WeatherCloud Pro or Premium account with `hasWeatherCloudPro` as `true` or `false` on line 56 + - Set `updateWeatherCloud` to `true` on Line 54 + - Set your `weathercloudAPIKey` on Line 55 + - Set your `weathercloudID` on Line 56 + - Set whether or not you have a WeatherCloud Pro or Premium account with `hasWeatherCloudPro` as `true` or `false` on line 57
OpenWeatherMap Creation of a new OpenWeatherMap station must be done by API, not on the OpenWeatherMap website. More information is available in [the OpenWeatherMap Station API documentation](https://openweathermap.org/stations#create_station). The basic concept for what must be done is available in the `createNewOWMStation_()` function. Remove the `_` character from the name of that function to make it selectable from the `▷ Run` button in the toolbar. If you do so, make sure you note your new station's ID and other details in the log (available in the Executions tab in the sidebar after running!), then: - - Set `updateOpenWeatherMap` to `true` on Line 58 - - Set `openWeatherMapAPIKey` to your [API Key](https://home.openweathermap.org/api_keys) on Line 59 - - Set your `openWeatherMapStationId` to [your OpenWeatherMap station's `external_id`](https://openweathermap.org/stations#create_station) on line 60 + - Set `updateOpenWeatherMap` to `true` on Line 59 + - Set `openWeatherMapAPIKey` to your [API Key](https://home.openweathermap.org/api_keys) on Line 60 + - Set your `openWeatherMapStationId` to [your OpenWeatherMap station's `external_id`](https://openweathermap.org/stations#create_station) on line 61
WindGuru @@ -166,9 +167,9 @@ and periodically sends it on to Start by [registering a new "Other / Upload API" station](https://stations.windguru.cz/register.php?id_type=16), then: - - Set `updateWindGuru` to `true` on Line 62 - - Set `windGuruStationUID` to your chosen [station UID](https://stations.windguru.cz/) on Line 63 - - Set your `windGuruStationPassword` to your chosen [station API password](https://stations.windguru.cz/) (note, not your _account's_ password) on line 64 + - Set `updateWindGuru` to `true` on Line 63 + - Set `windGuruStationUID` to your chosen [station UID](https://stations.windguru.cz/) on Line 64 + - Set your `windGuruStationPassword` to your chosen [station API password](https://stations.windguru.cz/) (note, not your _account's_ password) on line 65
Met (UK) WOW @@ -177,18 +178,18 @@ and periodically sends it on to Start by [registering a new Site](https://wow.metoffice.gov.uk/sites/create). During registration, one of the fields in your Site's options is "Authentication Key". Choose any 6-Digit number. Then: - - Set `updateWOW` to `true` on Line 66 - - Set `wowSiteID` to the generated [Site ID](https://wow.metoffice.gov.uk/sites) on Line 67 - - Set `wowAuthKey` to your chosen [6-Digit Authentication Key](https://wow.metoffice.gov.uk/sites) that you chose when creating or editing the Site on line 68 + - Set `updateWOW` to `true` on Line 67 + - Set `wowSiteID` to the generated [Site ID](https://wow.metoffice.gov.uk/sites) on Line 68 + - Set `wowAuthKey` to your chosen [6-Digit Authentication Key](https://wow.metoffice.gov.uk/sites) that you chose when creating or editing the Site on line 69
NOAA Citizen Weather Observer Program (CWOP) Send to [CWOP](https://madis.ncep.noaa.gov/madis_cwop.shtml). Start by [registering for a new station](https://madis.ncep.noaa.gov/madis_cwop.shtml), then when you receive your email: - - Set `updateCWOP` to `true` on Line 70 - - Set `cwopStationIDOrHamCallsign` to your assigned CWOP station ID that you received via email on Line 71 - - If you are using your ham radio callsign as your station ID and you have received a validation code from NOAA CWOP support, set `cwopValidationCode` to your validation code on Line 72 + - Set `updateCWOP` to `true` on Line 71 + - Set `cwopStationIDOrHamCallsign` to your assigned CWOP station ID that you received via email on Line 72 + - If you are using your ham radio callsign as your station ID and you have received a validation code from NOAA CWOP support, set `cwopValidationCode` to your validation code on Line 73
4. Run the "Schedule" function (not the "doPost" function) by selecting "Schedule" in the dropdown and pressing the `▷ Run` button in the toolbar. You're done! You can see it periodically running in the `☰▶` Executions tab on the left sidebar. This code is executed on Google's servers and does not require a computer to remain on. diff --git a/code.gs b/code.gs index 49390f4..0609577 100644 --- a/code.gs +++ b/code.gs @@ -27,7 +27,8 @@ const weatherflowStationId = 'xxxxx'; const ambientWeatherStationName = 'xxxxxx'; const ambientWeatherApiKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; // or -const ecowittAPIKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; +const ecowittAPIKey = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'; +const ecowittApplicationKey = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; const ecowittMacAddress = 'XX:XX:XX:XX:XX:XX'; // or const aprsStationID = 'xxxxxx'; @@ -641,7 +642,7 @@ function refreshFromAmbientWeather_() { // doc.ecowitt.net function refreshFromEcowitt_() { - let ecowittConditions = fetchJSON_('https://api.ecowitt.net/api/v3/device/real_time?application_key=' + Utilities.newBlob(Utilities.base64Decode('MzA5RjIyQjRDM0NEQzQ4MUI2QjI2RUYyRTJEMUM3N0Q=')).getDataAsString() + '&api_key=' + ecowittAPIKey + '&mac=' + ecowittMacAddress + '&call_back=all&temp_unitid=2&pressure_unitid=4&wind_speed_unitid=9&rainfall_unitid=13&solar_irradiance_unitid=16'); + let ecowittConditions = fetchJSON_('https://api.ecowitt.net/api/v3/device/real_time?application_key=' + ecowittApplicationKey + '&api_key=' + ecowittAPIKey + '&mac=' + ecowittMacAddress + '&call_back=all&temp_unitid=2&pressure_unitid=4&wind_speed_unitid=9&rainfall_unitid=13&solar_irradiance_unitid=16'); if (!ecowittConditions || ecowittConditions.code !== 0) return false; // still no luck? give up // console.log(JSON.stringify(ecowittConditions)); From aabe56354314fa01012a1754f0659a2b2ab8ade8 Mon Sep 17 00:00:00 2001 From: Leo Herzog Date: Sat, 14 Dec 2024 18:59:08 -0500 Subject: [PATCH 4/5] aprs.fi oversight bugfix --- code.gs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code.gs b/code.gs index 0609577..3dc0d8e 100644 --- a/code.gs +++ b/code.gs @@ -746,7 +746,7 @@ function refreshFromEcowitt_() { } // https://aprs.fi/page/api -function refreshFromAPRSFI() { +function refreshFromAPRSFI_() { let aprsStations = fetchJSON_('https://api.aprs.fi/api/get?name=' + aprsStationID + '&what=wx&format=json&apikey=' + aprsApiKey); if (!aprsStations || !aprsStations?.entries || !aprsStations?.entries.length) return false; // still no luck? give up From 86e2f7e2ee23488c70a3c48a10765be4dab1afde Mon Sep 17 00:00:00 2001 From: Leo Herzog Date: Sat, 14 Dec 2024 18:59:29 -0500 Subject: [PATCH 5/5] Version Bump --- code.gs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code.gs b/code.gs index 3dc0d8e..5bd34d0 100644 --- a/code.gs +++ b/code.gs @@ -83,7 +83,7 @@ const cwopValidationCode = null; */ -let version = 'v2.9.0b1'; +let version = 'v2.9.0'; function Schedule() { if (updateWunderground && datasource === 'ibm' && ibmStationID === wundergroundStationID) throw 'Error: You are currently set to pull data from Wunderground and also send data to Wunderground. Please disable one or the other to avoid duplicate data.';