From bcab5aa8ed9747e33fea2cfa59efd51a6de74c0d Mon Sep 17 00:00:00 2001 From: dacarson <44933987+dacarson@users.noreply.github.com> Date: Wed, 4 Dec 2024 11:30:01 -0800 Subject: [PATCH] Fix threshold triggers #296 Fix issue with threshold triggers and WeatherUnderground. In 3.3.4, WeatherUnderground API call was modified and incorrectly return values in km, and km/h --- CHANGELOG.md | 1 + apis/weatherunderground.js | 7 ++----- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bdd2eab..bb25ca6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -298,3 +298,4 @@ ## 3.3.6 * The fix in 3.3.4 for tile naming in Home app was not supported with HomeBridge. Add setting of Name property back for HomeBridge compatibility. +* Fix issue with threshold triggers and WeatherUnderground. In 3.3.4, WeatherUnderground API call was modified and incorrectly return values in km, and km/h. diff --git a/apis/weatherunderground.js b/apis/weatherunderground.js index 3b1942c..a41e77b 100644 --- a/apis/weatherunderground.js +++ b/apis/weatherunderground.js @@ -29,9 +29,6 @@ class WundergroundAPI this.location = location; this.apiKey = apiKey; - - // Get observation values only in si 's' for now. - this.units = 's'; } update(forecastDays, callback) @@ -40,7 +37,7 @@ class WundergroundAPI let weather = {}; let that = this; - const queryUri = "https://api.weather.com/v2/pws/observations/current?apiKey=" + this.apiKey + "&stationId=" + this.location + "&format=json&units=m" + '&numericPrecision=decimal'; + const queryUri = "https://api.weather.com/v2/pws/observations/current?apiKey=" + this.apiKey + "&stationId=" + this.location + "&format=json&units=s" + '&numericPrecision=decimal'; request(encodeURI(queryUri), function (err, response, body) { if (!err && body.length > 0) @@ -90,7 +87,7 @@ class WundergroundAPI try { let observation = json.observations[0]; - let values = observation.metric; + let values = observation.metric_si; report.ObservationStation = observation.stationID + " : " + observation.neighborhood; report.ObservationTime = moment(Date.parse(observation.obsTimeUtc)).format('HH:mm:ss');