From f9363c153cedc5658117195c5736b57be63c2080 Mon Sep 17 00:00:00 2001 From: TolaMironcenko Date: Fri, 6 Sep 2024 16:21:24 +0700 Subject: [PATCH] weather ags --- ags/weather/Weather.js | 21 +- ags/weather/weather.json | 1624 +++++++++++++++++++++++++++----- ags/weather/weather_service.js | 25 +- ags/weather/wttr.py | 64 ++ ags/weather/wttr.sh | 5 + wttr.py | 0 6 files changed, 1463 insertions(+), 276 deletions(-) create mode 100755 ags/weather/wttr.py create mode 100755 ags/weather/wttr.sh create mode 100644 wttr.py diff --git a/ags/weather/Weather.js b/ags/weather/Weather.js index beb45d3..156b71f 100644 --- a/ags/weather/Weather.js +++ b/ags/weather/Weather.js @@ -1,3 +1,5 @@ +import Weather from "./weather_service.js" + export default () => Widget.Box( { class_name: "weather", @@ -146,18 +148,27 @@ export default () => Widget.Box( }, Widget.Label({ class_name: "title", - css: "color: black;font-size: 20px;", + css: "color: black;font-size: 25px;", wrap: true, - label: "", - hpack: "start" + // label: "", + hpack: "start", + setup: self => self.hook(Weather, () => { + Weather.weatherData + self.label = `${Weather._temperatureWeather.current_condition[0].weatherCode}` + }) }), Widget.Box({hexpand: true}), Widget.Label({ class_name: "title", css: "color: black;margin-right: 10px;font-size: 20px;", wrap: true, - label: "↑ 10 ↓ 4 FRI", - hpack: "end" + // label: "↑ 10 ↓ 4 FRI", + hpack: "end", + setup: self => self.hook(Weather, () => { + // self.label = "hello world" + print(Weather.weatherData) + self.label = `↑ ${Weather._temperatureWeather.weather[0].maxtempC} ↓ ${Weather._temperatureWeather.weather[0].mintempC} ${Weather._temperatureWeather.weather[0].date}` + }), }) ), Widget.Box( diff --git a/ags/weather/weather.json b/ags/weather/weather.json index aa1d75b..2c87999 100644 --- a/ags/weather/weather.json +++ b/ags/weather/weather.json @@ -1,261 +1,1367 @@ { - "lat": "56.49771N", - "lon": "84.97437E", - "elevation": 117, - "timezone": "Asia/Tomsk", - "units": "metric", - "current": { - "icon": "overcast", - "icon_num": 7, - "summary": "Overcast", - "temperature": 12.5, - "wind": { "speed": 3.8, "angle": 55, "dir": "NE" }, - "precipitation": { "total": 0.0, "type": "none" }, - "cloud_cover": 96 - }, - "hourly": { - "data": [ - { - "date": "2024-09-04T15:00:00", - "weather": "overcast", - "icon": 7, - "summary": "Overcast", - "temperature": 12.5, - "wind": { "speed": 3.8, "dir": "NE", "angle": 55 }, - "cloud_cover": { "total": 96 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-04T16:00:00", - "weather": "overcast", - "icon": 7, - "summary": "Overcast", - "temperature": 12.8, - "wind": { "speed": 3.6, "dir": "ENE", "angle": 58 }, - "cloud_cover": { "total": 96 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-04T17:00:00", - "weather": "overcast", - "icon": 7, - "summary": "Overcast", - "temperature": 12.0, - "wind": { "speed": 3.3, "dir": "ENE", "angle": 57 }, - "cloud_cover": { "total": 97 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-04T18:00:00", - "weather": "overcast", - "icon": 7, - "summary": "Overcast", - "temperature": 11.5, - "wind": { "speed": 3.1, "dir": "NE", "angle": 50 }, - "cloud_cover": { "total": 93 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-04T19:00:00", - "weather": "overcast", - "icon": 7, - "summary": "Overcast", - "temperature": 11.2, - "wind": { "speed": 2.9, "dir": "NE", "angle": 42 }, - "cloud_cover": { "total": 94 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-04T20:00:00", - "weather": "overcast", - "icon": 7, - "summary": "Overcast", - "temperature": 10.8, - "wind": { "speed": 2.5, "dir": "NE", "angle": 40 }, - "cloud_cover": { "total": 95 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-04T21:00:00", - "weather": "cloudy", - "icon": 30, - "summary": "Cloudy", - "temperature": 10.0, - "wind": { "speed": 2.4, "dir": "NE", "angle": 34 }, - "cloud_cover": { "total": 88 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-04T22:00:00", - "weather": "mostly_cloudy", - "icon": 29, - "summary": "Mostly cloudy", - "temperature": 9.5, - "wind": { "speed": 2.6, "dir": "NNE", "angle": 33 }, - "cloud_cover": { "total": 75 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-04T23:00:00", - "weather": "mostly_cloudy", - "icon": 29, - "summary": "Mostly cloudy", - "temperature": 9.0, - "wind": { "speed": 2.9, "dir": "NE", "angle": 39 }, - "cloud_cover": { "total": 73 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-05T00:00:00", - "weather": "mostly_cloudy", - "icon": 29, - "summary": "Mostly cloudy", - "temperature": 8.5, - "wind": { "speed": 2.8, "dir": "NE", "angle": 46 }, - "cloud_cover": { "total": 76 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-05T01:00:00", - "weather": "mostly_cloudy", - "icon": 29, - "summary": "Mostly cloudy", - "temperature": 8.2, - "wind": { "speed": 3.1, "dir": "NE", "angle": 48 }, - "cloud_cover": { "total": 80 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-05T02:00:00", - "weather": "overcast", - "icon": 7, - "summary": "Overcast", - "temperature": 7.8, - "wind": { "speed": 2.8, "dir": "NE", "angle": 45 }, - "cloud_cover": { "total": 91 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-05T03:00:00", - "weather": "overcast", - "icon": 7, - "summary": "Overcast", - "temperature": 7.5, - "wind": { "speed": 2.9, "dir": "NE", "angle": 43 }, - "cloud_cover": { "total": 94 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-05T04:00:00", - "weather": "overcast", - "icon": 7, - "summary": "Overcast", - "temperature": 7.2, - "wind": { "speed": 2.9, "dir": "NE", "angle": 39 }, - "cloud_cover": { "total": 94 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-05T05:00:00", - "weather": "overcast", - "icon": 7, - "summary": "Overcast", - "temperature": 7.0, - "wind": { "speed": 2.8, "dir": "NE", "angle": 37 }, - "cloud_cover": { "total": 95 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-05T06:00:00", - "weather": "overcast", - "icon": 7, - "summary": "Overcast", - "temperature": 7.0, - "wind": { "speed": 3.1, "dir": "NE", "angle": 47 }, - "cloud_cover": { "total": 99 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-05T07:00:00", - "weather": "overcast", - "icon": 7, - "summary": "Overcast", - "temperature": 7.0, - "wind": { "speed": 3.4, "dir": "NE", "angle": 42 }, - "cloud_cover": { "total": 95 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-05T08:00:00", - "weather": "overcast", - "icon": 7, - "summary": "Overcast", - "temperature": 7.5, - "wind": { "speed": 3.8, "dir": "NE", "angle": 43 }, - "cloud_cover": { "total": 93 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-05T09:00:00", - "weather": "cloudy", - "icon": 6, - "summary": "Cloudy", - "temperature": 8.5, - "wind": { "speed": 3.8, "dir": "NE", "angle": 49 }, - "cloud_cover": { "total": 90 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-05T10:00:00", - "weather": "overcast", - "icon": 7, - "summary": "Overcast", - "temperature": 9.8, - "wind": { "speed": 4.0, "dir": "NE", "angle": 55 }, - "cloud_cover": { "total": 91 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-05T11:00:00", - "weather": "cloudy", - "icon": 6, - "summary": "Cloudy", - "temperature": 11.2, - "wind": { "speed": 4.5, "dir": "ENE", "angle": 58 }, - "cloud_cover": { "total": 86 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-05T12:00:00", - "weather": "cloudy", - "icon": 6, - "summary": "Cloudy", - "temperature": 11.2, - "wind": { "speed": 4.4, "dir": "NE", "angle": 54 }, - "cloud_cover": { "total": 83 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-05T13:00:00", - "weather": "overcast", - "icon": 7, - "summary": "Overcast", - "temperature": 12.2, - "wind": { "speed": 4.4, "dir": "NE", "angle": 51 }, - "cloud_cover": { "total": 93 }, - "precipitation": { "total": 0.0, "type": "none" } - }, - { - "date": "2024-09-05T14:00:00", - "weather": "overcast", - "icon": 7, - "summary": "Overcast", - "temperature": 13.0, - "wind": { "speed": 4.1, "dir": "NE", "angle": 53 }, - "cloud_cover": { "total": 100 }, - "precipitation": { "total": 0.0, "type": "none" } - } - ] - }, - "daily": null + "current_condition": [ + { + "FeelsLikeC": "11", + "FeelsLikeF": "52", + "cloudcover": "100", + "humidity": "98", + "localObsDateTime": "2024-09-06 02:23 PM", + "observation_time": "07:23 AM", + "precipInches": "0.0", + "precipMM": "0.4", + "pressure": "1006", + "pressureInches": "30", + "temp_C": "12", + "temp_F": "53", + "uvIndex": "3", + "visibility": "10", + "visibilityMiles": "6", + "weatherCode": "353", + "weatherDesc": [ + { + "value": "Light rain shower" + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "SSW", + "winddirDegree": "198", + "windspeedKmph": "7", + "windspeedMiles": "4" + } + ], + "nearest_area": [ + { + "areaName": [ + { + "value": "Томск" + } + ], + "country": [ + { + "value": "Russia" + } + ], + "latitude": "56.500", + "longitude": "84.967", + "population": "485519", + "region": [ + { + "value": "Tomsk" + } + ], + "weatherUrl": [ + { + "value": "" + } + ] + } + ], + "request": [ + { + "query": "Lat 56.49 and Lon 84.95", + "type": "LatLon" + } + ], + "weather": [ + { + "astronomy": [ + { + "moon_illumination": "7", + "moon_phase": "Waxing Crescent", + "moonrise": "10:06 AM", + "moonset": "08:33 PM", + "sunrise": "06:33 AM", + "sunset": "08:02 PM" + } + ], + "avgtempC": "11", + "avgtempF": "52", + "date": "2024-09-06", + "hourly": [ + { + "DewPointC": "7", + "DewPointF": "44", + "FeelsLikeC": "6", + "FeelsLikeF": "43", + "HeatIndexC": "8", + "HeatIndexF": "47", + "WindChillC": "6", + "WindChillF": "43", + "WindGustKmph": "28", + "WindGustMiles": "17", + "chanceoffog": "1", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "46", + "chanceofrain": "0", + "chanceofremdry": "93", + "chanceofsnow": "0", + "chanceofsunshine": "73", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "40", + "diffRad": "0.0", + "humidity": "88", + "precipInches": "0.0", + "precipMM": "0.0", + "pressure": "1008", + "pressureInches": "30", + "shortRad": "0.0", + "tempC": "8", + "tempF": "47", + "time": "0", + "uvIndex": "1", + "visibility": "10", + "visibilityMiles": "6", + "weatherCode": "116", + "weatherDesc": [ + { + "value": "Partly Cloudy " + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "ENE", + "winddirDegree": "60", + "windspeedKmph": "16", + "windspeedMiles": "10" + }, + { + "DewPointC": "7", + "DewPointF": "45", + "FeelsLikeC": "7", + "FeelsLikeF": "45", + "HeatIndexC": "9", + "HeatIndexF": "49", + "WindChillC": "7", + "WindChillF": "45", + "WindGustKmph": "24", + "WindGustMiles": "15", + "chanceoffog": "0", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "47", + "chanceofrain": "0", + "chanceofremdry": "94", + "chanceofsnow": "0", + "chanceofsunshine": "72", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "48", + "diffRad": "28.3", + "humidity": "85", + "precipInches": "0.0", + "precipMM": "0.0", + "pressure": "1007", + "pressureInches": "30", + "shortRad": "57.8", + "tempC": "9", + "tempF": "49", + "time": "300", + "uvIndex": "1", + "visibility": "10", + "visibilityMiles": "6", + "weatherCode": "116", + "weatherDesc": [ + { + "value": "Partly Cloudy " + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "ENE", + "winddirDegree": "59", + "windspeedKmph": "16", + "windspeedMiles": "10" + }, + { + "DewPointC": "8", + "DewPointF": "47", + "FeelsLikeC": "13", + "FeelsLikeF": "55", + "HeatIndexC": "14", + "HeatIndexF": "57", + "WindChillC": "13", + "WindChillF": "55", + "WindGustKmph": "20", + "WindGustMiles": "13", + "chanceoffog": "0", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "38", + "chanceofrain": "0", + "chanceofremdry": "87", + "chanceofsnow": "0", + "chanceofsunshine": "73", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "37", + "diffRad": "98.1", + "humidity": "68", + "precipInches": "0.0", + "precipMM": "0.0", + "pressure": "1007", + "pressureInches": "30", + "shortRad": "206.4", + "tempC": "14", + "tempF": "57", + "time": "600", + "uvIndex": "1", + "visibility": "10", + "visibilityMiles": "6", + "weatherCode": "116", + "weatherDesc": [ + { + "value": "Partly Cloudy " + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "E", + "winddirDegree": "81", + "windspeedKmph": "17", + "windspeedMiles": "11" + }, + { + "DewPointC": "10", + "DewPointF": "50", + "FeelsLikeC": "17", + "FeelsLikeF": "63", + "HeatIndexC": "17", + "HeatIndexF": "63", + "WindChillC": "17", + "WindChillF": "63", + "WindGustKmph": "13", + "WindGustMiles": "8", + "chanceoffog": "0", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "94", + "chanceofrain": "80", + "chanceofremdry": "0", + "chanceofsnow": "0", + "chanceofsunshine": "0", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "100", + "diffRad": "218.7", + "humidity": "61", + "precipInches": "0.0", + "precipMM": "0.0", + "pressure": "1006", + "pressureInches": "30", + "shortRad": "487.0", + "tempC": "17", + "tempF": "63", + "time": "900", + "uvIndex": "4", + "visibility": "10", + "visibilityMiles": "6", + "weatherCode": "176", + "weatherDesc": [ + { + "value": "Patchy rain nearby" + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "ESE", + "winddirDegree": "109", + "windspeedKmph": "11", + "windspeedMiles": "7" + }, + { + "DewPointC": "12", + "DewPointF": "54", + "FeelsLikeC": "13", + "FeelsLikeF": "55", + "HeatIndexC": "13", + "HeatIndexF": "55", + "WindChillC": "13", + "WindChillF": "55", + "WindGustKmph": "10", + "WindGustMiles": "6", + "chanceoffog": "0", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "80", + "chanceofrain": "100", + "chanceofremdry": "0", + "chanceofsnow": "0", + "chanceofsunshine": "0", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "95", + "diffRad": "115.2", + "humidity": "96", + "precipInches": "0.0", + "precipMM": "1.0", + "pressure": "1006", + "pressureInches": "30", + "shortRad": "229.3", + "tempC": "13", + "tempF": "55", + "time": "1200", + "uvIndex": "3", + "visibility": "10", + "visibilityMiles": "6", + "weatherCode": "353", + "weatherDesc": [ + { + "value": "Light rain shower" + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "SSE", + "winddirDegree": "155", + "windspeedKmph": "7", + "windspeedMiles": "4" + }, + { + "DewPointC": "11", + "DewPointF": "52", + "FeelsLikeC": "10", + "FeelsLikeF": "50", + "HeatIndexC": "11", + "HeatIndexF": "52", + "WindChillC": "10", + "WindChillF": "50", + "WindGustKmph": "16", + "WindGustMiles": "10", + "chanceoffog": "2", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "86", + "chanceofrain": "100", + "chanceofremdry": "0", + "chanceofsnow": "0", + "chanceofsunshine": "0", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "100", + "diffRad": "0.8", + "humidity": "98", + "precipInches": "0.0", + "precipMM": "0.2", + "pressure": "1006", + "pressureInches": "30", + "shortRad": "1.1", + "tempC": "11", + "tempF": "52", + "time": "1500", + "uvIndex": "3", + "visibility": "10", + "visibilityMiles": "6", + "weatherCode": "353", + "weatherDesc": [ + { + "value": "Light rain shower" + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "SSW", + "winddirDegree": "214", + "windspeedKmph": "11", + "windspeedMiles": "7" + }, + { + "DewPointC": "9", + "DewPointF": "49", + "FeelsLikeC": "8", + "FeelsLikeF": "47", + "HeatIndexC": "10", + "HeatIndexF": "49", + "WindChillC": "8", + "WindChillF": "47", + "WindGustKmph": "16", + "WindGustMiles": "10", + "chanceoffog": "91", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "87", + "chanceofrain": "62", + "chanceofremdry": "0", + "chanceofsnow": "0", + "chanceofsunshine": "0", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "100", + "diffRad": "0.2", + "humidity": "98", + "precipInches": "0.0", + "precipMM": "0.0", + "pressure": "1007", + "pressureInches": "30", + "shortRad": "0.3", + "tempC": "10", + "tempF": "49", + "time": "1800", + "uvIndex": "2", + "visibility": "0", + "visibilityMiles": "0", + "weatherCode": "248", + "weatherDesc": [ + { + "value": "Fog" + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "SSW", + "winddirDegree": "198", + "windspeedKmph": "9", + "windspeedMiles": "6" + }, + { + "DewPointC": "8", + "DewPointF": "46", + "FeelsLikeC": "7", + "FeelsLikeF": "44", + "HeatIndexC": "8", + "HeatIndexF": "47", + "WindChillC": "7", + "WindChillF": "44", + "WindGustKmph": "16", + "WindGustMiles": "10", + "chanceoffog": "36", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "80", + "chanceofrain": "0", + "chanceofremdry": "90", + "chanceofsnow": "0", + "chanceofsunshine": "7", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "72", + "diffRad": "0.0", + "humidity": "96", + "precipInches": "0.0", + "precipMM": "0.0", + "pressure": "1006", + "pressureInches": "30", + "shortRad": "0.0", + "tempC": "8", + "tempF": "47", + "time": "2100", + "uvIndex": "1", + "visibility": "2", + "visibilityMiles": "1", + "weatherCode": "143", + "weatherDesc": [ + { + "value": "Mist" + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "SSW", + "winddirDegree": "197", + "windspeedKmph": "9", + "windspeedMiles": "6" + } + ], + "maxtempC": "17", + "maxtempF": "63", + "mintempC": "7", + "mintempF": "45", + "sunHour": "11.3", + "totalSnow_cm": "0.0", + "uvIndex": "3" + }, + { + "astronomy": [ + { + "moon_illumination": "13", + "moon_phase": "Waxing Crescent", + "moonrise": "11:25 AM", + "moonset": "08:38 PM", + "sunrise": "06:35 AM", + "sunset": "07:59 PM" + } + ], + "avgtempC": "10", + "avgtempF": "49", + "date": "2024-09-07", + "hourly": [ + { + "DewPointC": "7", + "DewPointF": "45", + "FeelsLikeC": "5", + "FeelsLikeF": "41", + "HeatIndexC": "7", + "HeatIndexF": "45", + "WindChillC": "5", + "WindChillF": "41", + "WindGustKmph": "19", + "WindGustMiles": "12", + "chanceoffog": "89", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "86", + "chanceofrain": "70", + "chanceofremdry": "0", + "chanceofsnow": "0", + "chanceofsunshine": "0", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "100", + "diffRad": "0.0", + "humidity": "99", + "precipInches": "0.0", + "precipMM": "0.0", + "pressure": "1006", + "pressureInches": "30", + "shortRad": "0.0", + "tempC": "7", + "tempF": "45", + "time": "0", + "uvIndex": "1", + "visibility": "0", + "visibilityMiles": "0", + "weatherCode": "248", + "weatherDesc": [ + { + "value": "Fog" + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "S", + "winddirDegree": "188", + "windspeedKmph": "12", + "windspeedMiles": "7" + }, + { + "DewPointC": "8", + "DewPointF": "46", + "FeelsLikeC": "6", + "FeelsLikeF": "43", + "HeatIndexC": "8", + "HeatIndexF": "47", + "WindChillC": "6", + "WindChillF": "43", + "WindGustKmph": "19", + "WindGustMiles": "12", + "chanceoffog": "1", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "85", + "chanceofrain": "100", + "chanceofremdry": "0", + "chanceofsnow": "0", + "chanceofsunshine": "0", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "100", + "diffRad": "6.5", + "humidity": "97", + "precipInches": "0.0", + "precipMM": "0.3", + "pressure": "1007", + "pressureInches": "30", + "shortRad": "11.1", + "tempC": "8", + "tempF": "47", + "time": "300", + "uvIndex": "1", + "visibility": "2", + "visibilityMiles": "1", + "weatherCode": "266", + "weatherDesc": [ + { + "value": "Light drizzle" + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "SSW", + "winddirDegree": "193", + "windspeedKmph": "13", + "windspeedMiles": "8" + }, + { + "DewPointC": "9", + "DewPointF": "48", + "FeelsLikeC": "8", + "FeelsLikeF": "46", + "HeatIndexC": "9", + "HeatIndexF": "49", + "WindChillC": "8", + "WindChillF": "46", + "WindGustKmph": "18", + "WindGustMiles": "11", + "chanceoffog": "0", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "87", + "chanceofrain": "100", + "chanceofremdry": "0", + "chanceofsnow": "0", + "chanceofsunshine": "0", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "100", + "diffRad": "11.6", + "humidity": "98", + "precipInches": "0.1", + "precipMM": "1.6", + "pressure": "1007", + "pressureInches": "30", + "shortRad": "17.2", + "tempC": "9", + "tempF": "49", + "time": "600", + "uvIndex": "1", + "visibility": "9", + "visibilityMiles": "5", + "weatherCode": "296", + "weatherDesc": [ + { + "value": "Light rain" + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "SSW", + "winddirDegree": "202", + "windspeedKmph": "13", + "windspeedMiles": "8" + }, + { + "DewPointC": "10", + "DewPointF": "49", + "FeelsLikeC": "9", + "FeelsLikeF": "47", + "HeatIndexC": "10", + "HeatIndexF": "50", + "WindChillC": "9", + "WindChillF": "47", + "WindGustKmph": "15", + "WindGustMiles": "9", + "chanceoffog": "0", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "92", + "chanceofrain": "100", + "chanceofremdry": "0", + "chanceofsnow": "0", + "chanceofsunshine": "0", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "100", + "diffRad": "21.6", + "humidity": "98", + "precipInches": "0.0", + "precipMM": "0.6", + "pressure": "1008", + "pressureInches": "30", + "shortRad": "29.5", + "tempC": "10", + "tempF": "50", + "time": "900", + "uvIndex": "2", + "visibility": "2", + "visibilityMiles": "1", + "weatherCode": "266", + "weatherDesc": [ + { + "value": "Light drizzle" + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "WSW", + "winddirDegree": "243", + "windspeedKmph": "10", + "windspeedMiles": "6" + }, + { + "DewPointC": "10", + "DewPointF": "50", + "FeelsLikeC": "10", + "FeelsLikeF": "51", + "HeatIndexC": "11", + "HeatIndexF": "53", + "WindChillC": "10", + "WindChillF": "51", + "WindGustKmph": "18", + "WindGustMiles": "11", + "chanceoffog": "7", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "81", + "chanceofrain": "100", + "chanceofremdry": "0", + "chanceofsnow": "0", + "chanceofsunshine": "0", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "96", + "diffRad": "63.5", + "humidity": "91", + "precipInches": "0.0", + "precipMM": "0.5", + "pressure": "1009", + "pressureInches": "30", + "shortRad": "111.9", + "tempC": "11", + "tempF": "53", + "time": "1200", + "uvIndex": "3", + "visibility": "10", + "visibilityMiles": "6", + "weatherCode": "353", + "weatherDesc": [ + { + "value": "Light rain shower" + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "SW", + "winddirDegree": "228", + "windspeedKmph": "11", + "windspeedMiles": "7" + }, + { + "DewPointC": "9", + "DewPointF": "48", + "FeelsLikeC": "9", + "FeelsLikeF": "48", + "HeatIndexC": "10", + "HeatIndexF": "50", + "WindChillC": "9", + "WindChillF": "48", + "WindGustKmph": "18", + "WindGustMiles": "11", + "chanceoffog": "13", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "90", + "chanceofrain": "100", + "chanceofremdry": "0", + "chanceofsnow": "0", + "chanceofsunshine": "0", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "100", + "diffRad": "9.5", + "humidity": "93", + "precipInches": "0.0", + "precipMM": "0.2", + "pressure": "1011", + "pressureInches": "30", + "shortRad": "19.7", + "tempC": "10", + "tempF": "50", + "time": "1500", + "uvIndex": "3", + "visibility": "10", + "visibilityMiles": "6", + "weatherCode": "353", + "weatherDesc": [ + { + "value": "Light rain shower" + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "WSW", + "winddirDegree": "245", + "windspeedKmph": "9", + "windspeedMiles": "6" + }, + { + "DewPointC": "9", + "DewPointF": "48", + "FeelsLikeC": "8", + "FeelsLikeF": "47", + "HeatIndexC": "10", + "HeatIndexF": "50", + "WindChillC": "8", + "WindChillF": "47", + "WindGustKmph": "21", + "WindGustMiles": "13", + "chanceoffog": "13", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "89", + "chanceofrain": "75", + "chanceofremdry": "0", + "chanceofsnow": "0", + "chanceofsunshine": "0", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "100", + "diffRad": "2.4", + "humidity": "93", + "precipInches": "0.0", + "precipMM": "0.0", + "pressure": "1013", + "pressureInches": "30", + "shortRad": "4.9", + "tempC": "10", + "tempF": "50", + "time": "1800", + "uvIndex": "2", + "visibility": "10", + "visibilityMiles": "6", + "weatherCode": "176", + "weatherDesc": [ + { + "value": "Patchy rain nearby" + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "SW", + "winddirDegree": "228", + "windspeedKmph": "11", + "windspeedMiles": "7" + }, + { + "DewPointC": "8", + "DewPointF": "46", + "FeelsLikeC": "7", + "FeelsLikeF": "44", + "HeatIndexC": "9", + "HeatIndexF": "48", + "WindChillC": "7", + "WindChillF": "44", + "WindGustKmph": "25", + "WindGustMiles": "16", + "chanceoffog": "0", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "87", + "chanceofrain": "0", + "chanceofremdry": "89", + "chanceofsnow": "0", + "chanceofsunshine": "6", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "97", + "diffRad": "0.0", + "humidity": "91", + "precipInches": "0.0", + "precipMM": "0.0", + "pressure": "1014", + "pressureInches": "30", + "shortRad": "0.0", + "tempC": "9", + "tempF": "48", + "time": "2100", + "uvIndex": "1", + "visibility": "10", + "visibilityMiles": "6", + "weatherCode": "122", + "weatherDesc": [ + { + "value": "Overcast " + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "SW", + "winddirDegree": "231", + "windspeedKmph": "14", + "windspeedMiles": "9" + } + ], + "maxtempC": "12", + "maxtempF": "54", + "mintempC": "7", + "mintempF": "45", + "sunHour": "9.8", + "totalSnow_cm": "0.0", + "uvIndex": "1" + }, + { + "astronomy": [ + { + "moon_illumination": "20", + "moon_phase": "Waxing Crescent", + "moonrise": "12:45 PM", + "moonset": "08:44 PM", + "sunrise": "06:37 AM", + "sunset": "07:57 PM" + } + ], + "avgtempC": "9", + "avgtempF": "48", + "date": "2024-09-08", + "hourly": [ + { + "DewPointC": "7", + "DewPointF": "45", + "FeelsLikeC": "7", + "FeelsLikeF": "44", + "HeatIndexC": "9", + "HeatIndexF": "48", + "WindChillC": "7", + "WindChillF": "44", + "WindGustKmph": "23", + "WindGustMiles": "14", + "chanceoffog": "1", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "94", + "chanceofrain": "77", + "chanceofremdry": "0", + "chanceofsnow": "0", + "chanceofsunshine": "0", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "100", + "diffRad": "0.0", + "humidity": "92", + "precipInches": "0.0", + "precipMM": "0.0", + "pressure": "1015", + "pressureInches": "30", + "shortRad": "0.0", + "tempC": "9", + "tempF": "48", + "time": "0", + "uvIndex": "1", + "visibility": "10", + "visibilityMiles": "6", + "weatherCode": "176", + "weatherDesc": [ + { + "value": "Patchy rain nearby" + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "SW", + "winddirDegree": "230", + "windspeedKmph": "14", + "windspeedMiles": "9" + }, + { + "DewPointC": "8", + "DewPointF": "47", + "FeelsLikeC": "7", + "FeelsLikeF": "44", + "HeatIndexC": "9", + "HeatIndexF": "48", + "WindChillC": "7", + "WindChillF": "44", + "WindGustKmph": "22", + "WindGustMiles": "14", + "chanceoffog": "1", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "89", + "chanceofrain": "100", + "chanceofremdry": "0", + "chanceofsnow": "0", + "chanceofsunshine": "0", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "100", + "diffRad": "7.7", + "humidity": "95", + "precipInches": "0.0", + "precipMM": "0.4", + "pressure": "1015", + "pressureInches": "30", + "shortRad": "13.5", + "tempC": "9", + "tempF": "48", + "time": "300", + "uvIndex": "1", + "visibility": "2", + "visibilityMiles": "1", + "weatherCode": "266", + "weatherDesc": [ + { + "value": "Light drizzle" + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "SW", + "winddirDegree": "228", + "windspeedKmph": "15", + "windspeedMiles": "9" + }, + { + "DewPointC": "9", + "DewPointF": "48", + "FeelsLikeC": "6", + "FeelsLikeF": "44", + "HeatIndexC": "9", + "HeatIndexF": "48", + "WindChillC": "6", + "WindChillF": "44", + "WindGustKmph": "25", + "WindGustMiles": "16", + "chanceoffog": "0", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "87", + "chanceofrain": "100", + "chanceofremdry": "0", + "chanceofsnow": "0", + "chanceofsunshine": "0", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "100", + "diffRad": "8.8", + "humidity": "97", + "precipInches": "0.0", + "precipMM": "0.7", + "pressure": "1016", + "pressureInches": "30", + "shortRad": "12.9", + "tempC": "9", + "tempF": "48", + "time": "600", + "uvIndex": "1", + "visibility": "2", + "visibilityMiles": "1", + "weatherCode": "266", + "weatherDesc": [ + { + "value": "Light drizzle" + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "SW", + "winddirDegree": "228", + "windspeedKmph": "17", + "windspeedMiles": "11" + }, + { + "DewPointC": "9", + "DewPointF": "49", + "FeelsLikeC": "7", + "FeelsLikeF": "45", + "HeatIndexC": "10", + "HeatIndexF": "49", + "WindChillC": "7", + "WindChillF": "45", + "WindGustKmph": "23", + "WindGustMiles": "14", + "chanceoffog": "0", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "89", + "chanceofrain": "100", + "chanceofremdry": "0", + "chanceofsnow": "0", + "chanceofsunshine": "0", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "100", + "diffRad": "29.3", + "humidity": "97", + "precipInches": "0.0", + "precipMM": "0.5", + "pressure": "1016", + "pressureInches": "30", + "shortRad": "44.1", + "tempC": "10", + "tempF": "49", + "time": "900", + "uvIndex": "2", + "visibility": "2", + "visibilityMiles": "1", + "weatherCode": "266", + "weatherDesc": [ + { + "value": "Light drizzle" + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "SW", + "winddirDegree": "235", + "windspeedKmph": "16", + "windspeedMiles": "10" + }, + { + "DewPointC": "9", + "DewPointF": "49", + "FeelsLikeC": "8", + "FeelsLikeF": "46", + "HeatIndexC": "10", + "HeatIndexF": "49", + "WindChillC": "8", + "WindChillF": "46", + "WindGustKmph": "20", + "WindGustMiles": "12", + "chanceoffog": "0", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "92", + "chanceofrain": "100", + "chanceofremdry": "0", + "chanceofsnow": "0", + "chanceofsunshine": "0", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "100", + "diffRad": "18.9", + "humidity": "98", + "precipInches": "0.0", + "precipMM": "0.1", + "pressure": "1016", + "pressureInches": "30", + "shortRad": "27.2", + "tempC": "10", + "tempF": "49", + "time": "1200", + "uvIndex": "2", + "visibility": "10", + "visibilityMiles": "6", + "weatherCode": "176", + "weatherDesc": [ + { + "value": "Patchy rain nearby" + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "SW", + "winddirDegree": "234", + "windspeedKmph": "13", + "windspeedMiles": "8" + }, + { + "DewPointC": "9", + "DewPointF": "48", + "FeelsLikeC": "8", + "FeelsLikeF": "46", + "HeatIndexC": "9", + "HeatIndexF": "49", + "WindChillC": "8", + "WindChillF": "46", + "WindGustKmph": "17", + "WindGustMiles": "10", + "chanceoffog": "77", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "90", + "chanceofrain": "72", + "chanceofremdry": "0", + "chanceofsnow": "0", + "chanceofsunshine": "0", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "100", + "diffRad": "2.7", + "humidity": "98", + "precipInches": "0.0", + "precipMM": "0.0", + "pressure": "1016", + "pressureInches": "30", + "shortRad": "4.8", + "tempC": "9", + "tempF": "49", + "time": "1500", + "uvIndex": "2", + "visibility": "0", + "visibilityMiles": "0", + "weatherCode": "248", + "weatherDesc": [ + { + "value": "Fog" + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "SW", + "winddirDegree": "234", + "windspeedKmph": "11", + "windspeedMiles": "7" + }, + { + "DewPointC": "8", + "DewPointF": "47", + "FeelsLikeC": "7", + "FeelsLikeF": "44", + "HeatIndexC": "9", + "HeatIndexF": "48", + "WindChillC": "7", + "WindChillF": "44", + "WindGustKmph": "19", + "WindGustMiles": "12", + "chanceoffog": "76", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "87", + "chanceofrain": "0", + "chanceofremdry": "85", + "chanceofsnow": "0", + "chanceofsunshine": "17", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "100", + "diffRad": "0.7", + "humidity": "98", + "precipInches": "0.0", + "precipMM": "0.0", + "pressure": "1016", + "pressureInches": "30", + "shortRad": "1.2", + "tempC": "9", + "tempF": "48", + "time": "1800", + "uvIndex": "2", + "visibility": "0", + "visibilityMiles": "0", + "weatherCode": "248", + "weatherDesc": [ + { + "value": "Fog" + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "SW", + "winddirDegree": "229", + "windspeedKmph": "11", + "windspeedMiles": "7" + }, + { + "DewPointC": "8", + "DewPointF": "46", + "FeelsLikeC": "6", + "FeelsLikeF": "43", + "HeatIndexC": "8", + "HeatIndexF": "47", + "WindChillC": "6", + "WindChillF": "43", + "WindGustKmph": "20", + "WindGustMiles": "12", + "chanceoffog": "25", + "chanceoffrost": "0", + "chanceofhightemp": "0", + "chanceofovercast": "93", + "chanceofrain": "62", + "chanceofremdry": "0", + "chanceofsnow": "0", + "chanceofsunshine": "0", + "chanceofthunder": "0", + "chanceofwindy": "0", + "cloudcover": "83", + "diffRad": "0.0", + "humidity": "97", + "precipInches": "0.0", + "precipMM": "0.0", + "pressure": "1015", + "pressureInches": "30", + "shortRad": "0.0", + "tempC": "8", + "tempF": "47", + "time": "2100", + "uvIndex": "1", + "visibility": "2", + "visibilityMiles": "1", + "weatherCode": "143", + "weatherDesc": [ + { + "value": "Mist" + } + ], + "weatherIconUrl": [ + { + "value": "" + } + ], + "winddir16Point": "SW", + "winddirDegree": "230", + "windspeedKmph": "12", + "windspeedMiles": "8" + } + ], + "maxtempC": "10", + "maxtempF": "49", + "mintempC": "8", + "mintempF": "47", + "sunHour": "9.8", + "totalSnow_cm": "0.0", + "uvIndex": "1" + } + ] } diff --git a/ags/weather/weather_service.js b/ags/weather/weather_service.js index 77d7d86..9b02760 100644 --- a/ags/weather/weather_service.js +++ b/ags/weather/weather_service.js @@ -11,21 +11,22 @@ class Weather extends Service { } get weatherData() { - Utils.execAsync(['bash', '-c', "openweathermap ags"]).catch(print); + this._temperatureWeather = JSON.parse(Utils.exec(['python', "wttr.py"])) // .then(temp => {console.log(temp)}).catch(print); + return this._temperatureWeather } - get temperatureWeather() { - return this._temperatureWeather; - } - setTemperatureWeather(temp) { - this._temperatureWeather = temp; - this.emit('changed'); - } + // get temperatureWeather() { + // return this._temperatureWeather; + // } + // setTemperatureWeather(temp) { + // this._temperatureWeather = temp; + // this.emit('changed'); + // } - get tooltip() { - return this._tooltip; - } - setTooltip(text) { this._tooltip = text } + // get tooltip() { + // return this._tooltip; + // } + // setTooltip(text) { this._tooltip = text } } export default new Weather(); \ No newline at end of file diff --git a/ags/weather/wttr.py b/ags/weather/wttr.py new file mode 100755 index 0000000..5fd2a23 --- /dev/null +++ b/ags/weather/wttr.py @@ -0,0 +1,64 @@ +#!/bin/python + +import json +import requests +from datetime import datetime + +WEATHER_CODES = { + '113': '☀️', + '116': '⛅️', + '119': '☁️', + '122': '☁️', + '143': '🌫', + '176': '🌦', + '179': '🌧', + '182': '🌧', + '185': '🌧', + '200': '⛈', + '227': '🌨', + '230': '❄️', + '248': '🌫', + '260': '🌫', + '263': '🌦', + '266': '🌦', + '281': '🌧', + '284': '🌧', + '293': '🌦', + '296': '🌦', + '299': '🌧', + '302': '🌧', + '305': '🌧', + '308': '🌧', + '311': '🌧', + '314': '🌧', + '317': '🌧', + '320': '🌨', + '323': '🌨', + '326': '🌨', + '329': '❄️', + '332': '❄️', + '335': '❄️', + '338': '❄️', + '350': '🌧', + '353': '🌦', + '356': '🌧', + '359': '🌧', + '362': '🌧', + '365': '🌧', + '368': '🌨', + '371': '❄️', + '374': '🌧', + '377': '🌧', + '386': '⛈', + '389': '🌩', + '392': '⛈', + '395': '❄️' +} + +weather: json = requests.get("https://wttr.in/tomsk?format=j1").json() + +# data = json.load(weather) + +weather['current_condition'][0]['weatherCode'] = WEATHER_CODES[weather['current_condition'][0]['weatherCode']] + +print(json.dumps(weather)) diff --git a/ags/weather/wttr.sh b/ags/weather/wttr.sh new file mode 100755 index 0000000..89a0c44 --- /dev/null +++ b/ags/weather/wttr.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +weather=$(curl wttr.in/tomsk\?format\=j1) + +echo weather diff --git a/wttr.py b/wttr.py new file mode 100644 index 0000000..e69de29