From dfd04df0f3d6237559e8319957eca9c0c5021f39 Mon Sep 17 00:00:00 2001 From: David Peer Date: Wed, 12 Jan 2022 07:20:08 +0100 Subject: [PATCH] Fixed weather --- apps/lcars/lcars.app.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/apps/lcars/lcars.app.js b/apps/lcars/lcars.app.js index 0005e9016..2674d323f 100644 --- a/apps/lcars/lcars.app.js +++ b/apps/lcars/lcars.app.js @@ -138,7 +138,7 @@ function printData(key, y, c){ } else if (key == "TEMP"){ var weather = getWeather(); - value = locale.temp(parseInt(weather.temp-273.15)); + value = weather.temp; } else if (key == "HUMIDITY"){ text = "HUM"; @@ -423,14 +423,7 @@ function getSteps() { function getWeather(){ - var weather = { - temp: 0, - hum: 0, - txt: "", - wind: 0, - wdir: 0, - wrose: "" - }; + var weather; try { weather = require('weather').get(); @@ -438,6 +431,19 @@ function getWeather(){ // Return default } + if (weather === undefined){ + weather = { + temp: "-", + hum: "-", + txt: "-", + wind: "-", + wdir: "-", + wrose: "-" + }; + } else { + weather.temp = locale.temp(parseInt(weather.temp-273.15)) + } + return weather; }