Last active
August 10, 2022 16:56
-
-
Save csteinlehner/6208ce202f6ffcdd710d32a47152f41f to your computer and use it in GitHub Desktop.
Revisions
-
csteinlehner revised this gist
Aug 10, 2022 . 1 changed file with 0 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -41,8 +41,6 @@ tempC.font = Font.mediumRoundedSystemFont(detailFontSize) tempC.textColor = cColor; tempC.centerAlignText(); // Show temp in F let tempFVal = Math.round(tempValK * 1.8 - 459.67).toString() + "º F"; let tempF = widget.addText(tempFVal); -
csteinlehner renamed this gist
Aug 10, 2022 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
csteinlehner created this gist
Aug 10, 2022 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ // Variables used by Scriptable. // These must be at the very top of the file. Do not edit. // icon-color: red; icon-glyph: magic; // OpenWeatherMap API 2.5 Key const apiKey = "__YOUR_API_KEY__"; // Config sizes & colors let detailFontSize = 40 let cColor = Color.white(); let fColor = Color.orange(); // Get current location Location.setAccuracyToKilometer(); const loc = await Location.current(); // Get Weather data async function getCurrentTemp() { let currentTemp = 0 try { let weatherReq = "https://api.openweathermap.org/data/2.5/onecall?lat=" + loc.latitude + "&lon=" + loc.longitude + "&exclude=minutely,hourly,daily,alerts" + "&appid=" + apiKey let weatherData = await new Request(weatherReq).loadJSON(); let currentTemp = weatherData.current.temp; return currentTemp; } catch (error) { } } // Fill widget let widget = new ListWidget(); widget.backgroundColor = Color.black(); // Get temp in Kelvin let tempValK = await getCurrentTemp(); // Show temp in C let tempCVal = Math.round(tempValK - 273.15).toString() + "º C"; let tempC = widget.addText(tempCVal); tempC.font = Font.mediumRoundedSystemFont(detailFontSize) tempC.textColor = cColor; tempC.centerAlignText(); widget.addSpacer() // Show temp in F let tempFVal = Math.round(tempValK * 1.8 - 459.67).toString() + "º F"; let tempF = widget.addText(tempFVal); tempF.font = Font.mediumRoundedSystemFont(detailFontSize) tempF.textColor = fColor; tempF.centerAlignText(); // Close Widget Script.setWidget(widget); widget.presentSmall(); Script.complete();