From 42ccd573be63814dea2f3d9170f431ee3febafad Mon Sep 17 00:00:00 2001 From: Jas Singh Date: Sat, 27 Jul 2024 13:07:25 -0700 Subject: [PATCH] Updated the default weather template and the weather logic to handle errors better --- lib/types/defaults/weather.ts | 1262 +++++++++++------------ modules/menus/calendar/weather/index.ts | 13 +- 2 files changed, 642 insertions(+), 633 deletions(-) diff --git a/lib/types/defaults/weather.ts b/lib/types/defaults/weather.ts index 4e9d54f..ed4443e 100644 --- a/lib/types/defaults/weather.ts +++ b/lib/types/defaults/weather.ts @@ -12,37 +12,37 @@ export const DEFAULT_WEATHER = { "current": { "last_updated_epoch": 1721980800, "last_updated": "2024-07-26 01:00", - "temp_c": 30.7, - "temp_f": 87.3, + "temp_c": 0, + "temp_f": 0, "is_day": 0, "condition": { "text": "Clear", "icon": "//cdn.weatherapi.com/weather/64x64/night/113.png", "code": 1000 }, - "wind_mph": 13.2, - "wind_kph": 21.2, - "wind_degree": 311, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, "wind_dir": "NW", - "pressure_mb": 1010.0, - "pressure_in": 29.84, + "pressure_mb": 0, + "pressure_in": 0, "precip_mm": 0.0, "precip_in": 0.0, - "humidity": 17, - "cloud": 5, - "feelslike_c": 28.6, - "feelslike_f": 83.5, - "windchill_c": 30.7, - "windchill_f": 87.3, - "heatindex_c": 28.6, - "heatindex_f": 83.5, - "dewpoint_c": 2.9, - "dewpoint_f": 37.2, - "vis_km": 10.0, - "vis_miles": 6.0, - "uv": 1.0, - "gust_mph": 18.9, - "gust_kph": 30.4 + "humidity": 0, + "cloud": 0, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, + "vis_km": 0, + "vis_miles": 0, + "uv": 0, + "gust_mph": 0, + "gust_kph": 0, }, "forecast": { "forecastday": [ @@ -50,20 +50,20 @@ export const DEFAULT_WEATHER = { "date": "2024-07-26", "date_epoch": 1721952000, "day": { - "maxtemp_c": 42.7, - "maxtemp_f": 108.9, - "mintemp_c": 26.3, - "mintemp_f": 79.3, - "avgtemp_c": 33.1, - "avgtemp_f": 91.5, - "maxwind_mph": 22.1, - "maxwind_kph": 35.6, - "totalprecip_mm": 0.0, - "totalprecip_in": 0.0, - "totalsnow_cm": 0.0, - "avgvis_km": 10.0, - "avgvis_miles": 6.0, - "avghumidity": 15, + "maxtemp_c": 0, + "maxtemp_f": 0, + "mintemp_c": 0, + "mintemp_f": 0, + "avgtemp_c": 0, + "avgtemp_f": 0, + "maxwind_mph": 0, + "maxwind_kph": 0, + "totalprecip_mm": 0, + "totalprecip_in": 0, + "totalsnow_cm": 0, + "avgvis_km": 0, + "avgvis_miles": 0, + "avghumidity": 0, "daily_will_it_rain": 0, "daily_chance_of_rain": 0, "daily_will_it_snow": 0, @@ -73,7 +73,7 @@ export const DEFAULT_WEATHER = { "icon": "//cdn.weatherapi.com/weather/64x64/day/113.png", "code": 1000 }, - "uv": 11.0 + "uv": 0, }, "astro": { "sunrise": "06:01 AM", @@ -81,969 +81,969 @@ export const DEFAULT_WEATHER = { "moonrise": "11:32 PM", "moonset": "12:01 PM", "moon_phase": "Waning Gibbous", - "moon_illumination": 74, + "moon_illumination": 0, "is_moon_up": 0, - "is_sun_up": 1 + "is_sun_up": 0, }, "hour": [ { "time_epoch": 1721977200, "time": "2024-07-26 00:00", - "temp_c": 32.2, - "temp_f": 89.9, + "temp_c": 0, + "temp_f": 0, "is_day": 0, "condition": { "text": "Clear ", "icon": "//cdn.weatherapi.com/weather/64x64/night/113.png", "code": 1000 }, - "wind_mph": 14.1, - "wind_kph": 22.7, - "wind_degree": 313, - "wind_dir": "NW", - "pressure_mb": 1011.0, - "pressure_in": 29.84, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 15, - "cloud": 5, - "feelslike_c": 30.1, - "feelslike_f": 86.2, - "windchill_c": 32.2, - "windchill_f": 89.9, - "heatindex_c": 30.1, - "heatindex_f": 86.2, - "dewpoint_c": 2.3, - "dewpoint_f": 36.1, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, + "cloud": 0, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 20.4, - "gust_kph": 32.9, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 0 }, { "time_epoch": 1721980800, "time": "2024-07-26 01:00", - "temp_c": 30.7, - "temp_f": 87.3, + "temp_c": 0, + "temp_f": 0, "is_day": 0, "condition": { "text": "Clear ", "icon": "//cdn.weatherapi.com/weather/64x64/night/113.png", "code": 1000 }, - "wind_mph": 13.2, - "wind_kph": 21.2, - "wind_degree": 311, - "wind_dir": "NW", - "pressure_mb": 1010.0, - "pressure_in": 29.84, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 17, - "cloud": 5, - "feelslike_c": 28.6, - "feelslike_f": 83.5, - "windchill_c": 30.7, - "windchill_f": 87.3, - "heatindex_c": 28.6, - "heatindex_f": 83.5, - "dewpoint_c": 2.9, - "dewpoint_f": 37.2, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, + "cloud": 0, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 18.9, - "gust_kph": 30.4, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 0 }, { "time_epoch": 1721984400, "time": "2024-07-26 02:00", - "temp_c": 29.5, - "temp_f": 85.1, + "temp_c": 0, + "temp_f": 0, "is_day": 0, "condition": { "text": "Clear ", "icon": "//cdn.weatherapi.com/weather/64x64/night/113.png", "code": 1000 }, - "wind_mph": 13.2, - "wind_kph": 21.2, - "wind_degree": 311, - "wind_dir": "NW", - "pressure_mb": 1010.0, - "pressure_in": 29.83, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 19, - "cloud": 4, - "feelslike_c": 27.4, - "feelslike_f": 81.4, - "windchill_c": 29.5, - "windchill_f": 85.1, - "heatindex_c": 27.4, - "heatindex_f": 81.4, - "dewpoint_c": 3.1, - "dewpoint_f": 37.5, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, + "cloud": 0, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 19.0, - "gust_kph": 30.6, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 0 }, { "time_epoch": 1721988000, "time": "2024-07-26 03:00", - "temp_c": 28.6, - "temp_f": 83.5, + "temp_c": 0, + "temp_f": 0, "is_day": 0, "condition": { "text": "Clear ", "icon": "//cdn.weatherapi.com/weather/64x64/night/113.png", "code": 1000 }, - "wind_mph": 11.2, - "wind_kph": 18.0, - "wind_degree": 318, - "wind_dir": "NW", - "pressure_mb": 1010.0, - "pressure_in": 29.82, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 20, - "cloud": 4, - "feelslike_c": 26.6, - "feelslike_f": 79.9, - "windchill_c": 28.6, - "windchill_f": 83.5, - "heatindex_c": 26.6, - "heatindex_f": 79.9, - "dewpoint_c": 3.1, - "dewpoint_f": 37.6, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, + "cloud": 0, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 16.4, - "gust_kph": 26.4, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 0 }, { "time_epoch": 1721991600, "time": "2024-07-26 04:00", - "temp_c": 27.9, - "temp_f": 82.2, + "temp_c": 0, + "temp_f": 0, "is_day": 0, "condition": { "text": "Clear ", "icon": "//cdn.weatherapi.com/weather/64x64/night/113.png", "code": 1000 }, - "wind_mph": 8.7, - "wind_kph": 14.0, - "wind_degree": 319, - "wind_dir": "NW", - "pressure_mb": 1010.0, - "pressure_in": 29.83, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 20, - "cloud": 3, - "feelslike_c": 26.0, - "feelslike_f": 78.8, - "windchill_c": 27.9, - "windchill_f": 82.2, - "heatindex_c": 26.0, - "heatindex_f": 78.8, - "dewpoint_c": 2.9, - "dewpoint_f": 37.2, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, + "cloud": 0, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 12.7, - "gust_kph": 20.5, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 0 }, { "time_epoch": 1721995200, "time": "2024-07-26 05:00", - "temp_c": 27.3, - "temp_f": 81.1, + "temp_c": 0, + "temp_f": 0, "is_day": 0, "condition": { "text": "Clear ", "icon": "//cdn.weatherapi.com/weather/64x64/night/113.png", "code": 1000 }, - "wind_mph": 7.6, - "wind_kph": 12.2, - "wind_degree": 314, - "wind_dir": "NW", - "pressure_mb": 1010.0, - "pressure_in": 29.84, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 20, - "cloud": 4, - "feelslike_c": 25.5, - "feelslike_f": 77.9, - "windchill_c": 27.3, - "windchill_f": 81.1, - "heatindex_c": 25.5, - "heatindex_f": 77.9, - "dewpoint_c": 2.6, - "dewpoint_f": 36.7, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, + "cloud": 0, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 11.6, - "gust_kph": 18.7, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 0 }, { "time_epoch": 1721998800, "time": "2024-07-26 06:00", - "temp_c": 27.3, - "temp_f": 81.1, + "temp_c": 0, + "temp_f": 0, "is_day": 0, "condition": { "text": "Clear ", "icon": "//cdn.weatherapi.com/weather/64x64/night/113.png", "code": 1000 }, - "wind_mph": 5.8, - "wind_kph": 9.4, - "wind_degree": 314, - "wind_dir": "NW", - "pressure_mb": 1011.0, - "pressure_in": 29.85, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 21, - "cloud": 6, - "feelslike_c": 25.5, - "feelslike_f": 77.8, - "windchill_c": 27.3, - "windchill_f": 81.1, - "heatindex_c": 25.5, - "heatindex_f": 77.8, - "dewpoint_c": 2.4, - "dewpoint_f": 36.4, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, + "cloud": 0, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 9.1, - "gust_kph": 14.7, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 0 }, { "time_epoch": 1722002400, "time": "2024-07-26 07:00", - "temp_c": 28.1, - "temp_f": 82.7, + "temp_c": 0, + "temp_f": 0, "is_day": 1, "condition": { "text": "Sunny", "icon": "//cdn.weatherapi.com/weather/64x64/day/113.png", "code": 1000 }, - "wind_mph": 2.9, - "wind_kph": 4.7, - "wind_degree": 310, - "wind_dir": "NW", - "pressure_mb": 1011.0, - "pressure_in": 29.86, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 20, - "cloud": 8, - "feelslike_c": 26.2, - "feelslike_f": 79.1, - "windchill_c": 28.1, - "windchill_f": 82.7, - "heatindex_c": 26.2, - "heatindex_f": 79.1, - "dewpoint_c": 2.3, - "dewpoint_f": 36.2, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, + "cloud": 0, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 4.1, - "gust_kph": 6.6, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 7.0 }, { "time_epoch": 1722006000, "time": "2024-07-26 08:00", - "temp_c": 29.5, - "temp_f": 85.2, + "temp_c": 0, + "temp_f": 0, "is_day": 1, "condition": { "text": "Sunny", "icon": "//cdn.weatherapi.com/weather/64x64/day/113.png", "code": 1000 }, - "wind_mph": 2.0, - "wind_kph": 3.2, - "wind_degree": 273, - "wind_dir": "W", - "pressure_mb": 1012.0, - "pressure_in": 29.87, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 18, - "cloud": 8, - "feelslike_c": 27.4, - "feelslike_f": 81.4, - "windchill_c": 29.5, - "windchill_f": 85.2, - "heatindex_c": 27.4, - "heatindex_f": 81.4, - "dewpoint_c": 2.4, - "dewpoint_f": 36.3, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, + "cloud": 0, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 2.3, - "gust_kph": 3.7, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 7.0 }, { "time_epoch": 1722009600, "time": "2024-07-26 09:00", - "temp_c": 31.3, - "temp_f": 88.4, + "temp_c": 0, + "temp_f": 0, "is_day": 1, "condition": { "text": "Sunny", "icon": "//cdn.weatherapi.com/weather/64x64/day/113.png", "code": 1000 }, - "wind_mph": 2.7, - "wind_kph": 4.3, - "wind_degree": 267, - "wind_dir": "W", - "pressure_mb": 1011.0, - "pressure_in": 29.86, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 16, - "cloud": 7, - "feelslike_c": 29.2, - "feelslike_f": 84.6, - "windchill_c": 31.3, - "windchill_f": 88.4, - "heatindex_c": 29.2, - "heatindex_f": 84.6, - "dewpoint_c": 2.2, - "dewpoint_f": 36.0, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, + "cloud": 0, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 3.1, - "gust_kph": 5.0, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 8.0 }, { "time_epoch": 1722013200, "time": "2024-07-26 10:00", - "temp_c": 33.3, - "temp_f": 91.9, + "temp_c": 0, + "temp_f": 0, "is_day": 1, "condition": { "text": "Sunny", "icon": "//cdn.weatherapi.com/weather/64x64/day/113.png", "code": 1000 }, - "wind_mph": 4.3, - "wind_kph": 6.8, - "wind_degree": 287, - "wind_dir": "WNW", - "pressure_mb": 1011.0, - "pressure_in": 29.84, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 14, - "cloud": 7, - "feelslike_c": 31.4, - "feelslike_f": 88.5, - "windchill_c": 33.3, - "windchill_f": 91.9, - "heatindex_c": 31.4, - "heatindex_f": 88.5, - "dewpoint_c": 2.0, - "dewpoint_f": 35.5, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, + "cloud": 0, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 4.9, - "gust_kph": 7.9, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 8.0 }, { "time_epoch": 1722016800, "time": "2024-07-26 11:00", - "temp_c": 35.4, - "temp_f": 95.7, + "temp_c": 0, + "temp_f": 0, "is_day": 1, "condition": { "text": "Sunny", "icon": "//cdn.weatherapi.com/weather/64x64/day/113.png", "code": 1000 }, - "wind_mph": 5.8, - "wind_kph": 9.4, - "wind_degree": 304, - "wind_dir": "NW", - "pressure_mb": 1010.0, - "pressure_in": 29.83, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 12, - "cloud": 6, - "feelslike_c": 33.8, - "feelslike_f": 92.9, - "windchill_c": 35.4, - "windchill_f": 95.7, - "heatindex_c": 33.8, - "heatindex_f": 92.9, - "dewpoint_c": 1.3, - "dewpoint_f": 34.4, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, + "cloud": 0, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 6.7, - "gust_kph": 10.8, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 9.0 }, { "time_epoch": 1722020400, "time": "2024-07-26 12:00", - "temp_c": 37.4, - "temp_f": 99.4, + "temp_c": 0, + "temp_f": 0, "is_day": 1, "condition": { "text": "Sunny", "icon": "//cdn.weatherapi.com/weather/64x64/day/113.png", "code": 1000 }, - "wind_mph": 6.0, - "wind_kph": 9.7, - "wind_degree": 309, - "wind_dir": "NW", - "pressure_mb": 1009.0, - "pressure_in": 29.81, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 10, - "cloud": 6, - "feelslike_c": 36.5, - "feelslike_f": 97.7, - "windchill_c": 37.4, - "windchill_f": 99.4, - "heatindex_c": 36.5, - "heatindex_f": 97.7, - "dewpoint_c": 0.4, - "dewpoint_f": 32.7, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, + "cloud": 0, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 7.0, - "gust_kph": 11.2, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 9.0 }, { "time_epoch": 1722024000, "time": "2024-07-26 13:00", - "temp_c": 39.3, - "temp_f": 102.8, + "temp_c": 0, + "temp_f": 0, "is_day": 1, "condition": { "text": "Sunny", "icon": "//cdn.weatherapi.com/weather/64x64/day/113.png", "code": 1000 }, - "wind_mph": 4.5, - "wind_kph": 7.2, - "wind_degree": 303, - "wind_dir": "WNW", - "pressure_mb": 1008.0, - "pressure_in": 29.78, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 9, - "cloud": 5, - "feelslike_c": 39.1, - "feelslike_f": 102.5, - "windchill_c": 39.3, - "windchill_f": 102.8, - "heatindex_c": 39.1, - "heatindex_f": 102.5, - "dewpoint_c": 0.1, - "dewpoint_f": 32.1, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, + "cloud": 0, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 5.1, - "gust_kph": 8.3, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 9.0 }, { "time_epoch": 1722027600, "time": "2024-07-26 14:00", - "temp_c": 40.8, - "temp_f": 105.5, + "temp_c": 0, + "temp_f": 0, "is_day": 1, "condition": { "text": "Sunny", "icon": "//cdn.weatherapi.com/weather/64x64/day/113.png", "code": 1000 }, - "wind_mph": 2.9, - "wind_kph": 4.7, - "wind_degree": 284, - "wind_dir": "WNW", - "pressure_mb": 1007.0, - "pressure_in": 29.75, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 8, - "cloud": 4, - "feelslike_c": 41.3, - "feelslike_f": 106.4, - "windchill_c": 40.8, - "windchill_f": 105.5, - "heatindex_c": 41.3, - "heatindex_f": 106.4, - "dewpoint_c": 1.0, - "dewpoint_f": 33.9, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, + "cloud": 0, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 3.4, - "gust_kph": 5.4, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 10.0 }, { "time_epoch": 1722031200, "time": "2024-07-26 15:00", - "temp_c": 41.8, - "temp_f": 107.2, + "temp_c": 0, + "temp_f": 0, "is_day": 1, "condition": { "text": "Sunny", "icon": "//cdn.weatherapi.com/weather/64x64/day/113.png", "code": 1000 }, - "wind_mph": 1.6, - "wind_kph": 2.5, - "wind_degree": 229, - "wind_dir": "SW", - "pressure_mb": 1006.0, - "pressure_in": 29.71, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 9, - "cloud": 1, - "feelslike_c": 42.7, - "feelslike_f": 108.9, - "windchill_c": 41.8, - "windchill_f": 107.2, - "heatindex_c": 42.7, - "heatindex_f": 108.9, - "dewpoint_c": 2.5, - "dewpoint_f": 36.6, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, + "cloud": 0, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 1.8, - "gust_kph": 2.9, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 10.0 }, { "time_epoch": 1722034800, "time": "2024-07-26 16:00", - "temp_c": 42.2, - "temp_f": 108.0, + "temp_c": 0, + "temp_f": 0, "is_day": 1, "condition": { "text": "Sunny", "icon": "//cdn.weatherapi.com/weather/64x64/day/113.png", "code": 1000 }, - "wind_mph": 2.5, - "wind_kph": 4.0, - "wind_degree": 119, - "wind_dir": "ESE", - "pressure_mb": 1005.0, - "pressure_in": 29.68, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 9, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, "cloud": 0, - "feelslike_c": 43.4, - "feelslike_f": 110.1, - "windchill_c": 42.2, - "windchill_f": 108.0, - "heatindex_c": 43.4, - "heatindex_f": 110.1, - "dewpoint_c": 3.4, - "dewpoint_f": 38.1, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 2.8, - "gust_kph": 4.6, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 10.0 }, { "time_epoch": 1722038400, "time": "2024-07-26 17:00", - "temp_c": 40.4, - "temp_f": 104.7, + "temp_c": 0, + "temp_f": 0, "is_day": 1, "condition": { "text": "Sunny", "icon": "//cdn.weatherapi.com/weather/64x64/day/113.png", "code": 1000 }, - "wind_mph": 7.4, - "wind_kph": 11.9, - "wind_degree": 215, - "wind_dir": "SW", - "pressure_mb": 1004.0, - "pressure_in": 29.65, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 8, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, "cloud": 0, - "feelslike_c": 40.6, - "feelslike_f": 105.2, - "windchill_c": 40.4, - "windchill_f": 104.7, - "heatindex_c": 40.6, - "heatindex_f": 105.2, - "dewpoint_c": 1.6, - "dewpoint_f": 35.0, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 8.5, - "gust_kph": 13.7, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 10.0 }, { "time_epoch": 1722042000, "time": "2024-07-26 18:00", - "temp_c": 38.0, - "temp_f": 100.4, + "temp_c": 0, + "temp_f": 0, "is_day": 1, "condition": { "text": "Sunny", "icon": "//cdn.weatherapi.com/weather/64x64/day/113.png", "code": 1000 }, - "wind_mph": 22.1, - "wind_kph": 35.6, - "wind_degree": 306, - "wind_dir": "NW", - "pressure_mb": 1005.0, - "pressure_in": 29.67, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 10, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, "cloud": 0, - "feelslike_c": 37.3, - "feelslike_f": 99.1, - "windchill_c": 38.0, - "windchill_f": 100.4, - "heatindex_c": 37.3, - "heatindex_f": 99.1, - "dewpoint_c": 1.0, - "dewpoint_f": 33.8, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 25.5, - "gust_kph": 41.0, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 9.0 }, { "time_epoch": 1722045600, "time": "2024-07-26 19:00", - "temp_c": 35.1, - "temp_f": 95.2, + "temp_c": 0, + "temp_f": 0, "is_day": 1, "condition": { "text": "Sunny", "icon": "//cdn.weatherapi.com/weather/64x64/day/113.png", "code": 1000 }, - "wind_mph": 18.8, - "wind_kph": 30.2, - "wind_degree": 312, - "wind_dir": "NW", - "pressure_mb": 1006.0, - "pressure_in": 29.69, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 11, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, "cloud": 0, - "feelslike_c": 33.7, - "feelslike_f": 92.6, - "windchill_c": 35.1, - "windchill_f": 95.3, - "heatindex_c": 33.7, - "heatindex_f": 92.6, - "dewpoint_c": 1.0, - "dewpoint_f": 33.9, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 21.6, - "gust_kph": 34.8, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 9.0 }, { "time_epoch": 1722049200, "time": "2024-07-26 20:00", - "temp_c": 32.6, - "temp_f": 90.7, + "temp_c": 0, + "temp_f": 0, "is_day": 1, "condition": { "text": "Sunny", "icon": "//cdn.weatherapi.com/weather/64x64/day/113.png", "code": 1000 }, - "wind_mph": 17.2, - "wind_kph": 27.7, - "wind_degree": 326, - "wind_dir": "NNW", - "pressure_mb": 1007.0, - "pressure_in": 29.73, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 13, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, "cloud": 0, - "feelslike_c": 30.8, - "feelslike_f": 87.4, - "windchill_c": 32.6, - "windchill_f": 90.7, - "heatindex_c": 30.8, - "heatindex_f": 87.4, - "dewpoint_c": 0.3, - "dewpoint_f": 32.6, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 20.4, - "gust_kph": 32.8, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 8.0 }, { "time_epoch": 1722052800, "time": "2024-07-26 21:00", - "temp_c": 30.2, - "temp_f": 86.3, + "temp_c": 0, + "temp_f": 0, "is_day": 0, "condition": { "text": "Clear ", "icon": "//cdn.weatherapi.com/weather/64x64/night/113.png", "code": 1000 }, - "wind_mph": 15.7, - "wind_kph": 25.2, - "wind_degree": 326, - "wind_dir": "NNW", - "pressure_mb": 1008.0, - "pressure_in": 29.76, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 16, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, "cloud": 0, - "feelslike_c": 28.3, - "feelslike_f": 82.9, - "windchill_c": 30.2, - "windchill_f": 86.3, - "heatindex_c": 28.3, - "heatindex_f": 82.9, - "dewpoint_c": 1.6, - "dewpoint_f": 35.0, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 20.1, - "gust_kph": 32.4, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 0 }, { "time_epoch": 1722056400, "time": "2024-07-26 22:00", - "temp_c": 28.2, - "temp_f": 82.8, + "temp_c": 0, + "temp_f": 0, "is_day": 0, "condition": { "text": "Clear ", "icon": "//cdn.weatherapi.com/weather/64x64/night/113.png", "code": 1000 }, - "wind_mph": 14.8, - "wind_kph": 23.8, - "wind_degree": 329, - "wind_dir": "NNW", - "pressure_mb": 1009.0, - "pressure_in": 29.79, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 20, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, "cloud": 0, - "feelslike_c": 26.7, - "feelslike_f": 80.0, - "windchill_c": 28.2, - "windchill_f": 82.8, - "heatindex_c": 26.7, - "heatindex_f": 80.0, - "dewpoint_c": 2.6, - "dewpoint_f": 36.7, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 20.1, - "gust_kph": 32.3, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 0 }, { "time_epoch": 1722060000, "time": "2024-07-26 23:00", - "temp_c": 26.8, - "temp_f": 80.2, + "temp_c": 0, + "temp_f": 0, "is_day": 0, "condition": { "text": "Clear ", "icon": "//cdn.weatherapi.com/weather/64x64/night/113.png", "code": 1000 }, - "wind_mph": 13.0, - "wind_kph": 20.9, - "wind_degree": 323, - "wind_dir": "NW", - "pressure_mb": 1009.0, - "pressure_in": 29.8, - "precip_mm": 0.0, - "precip_in": 0.0, - "snow_cm": 0.0, - "humidity": 24, + "wind_mph": 0, + "wind_kph": 0, + "wind_degree": 0, + "wind_dir": "N", + "pressure_mb": 0, + "pressure_in": 0, + "precip_mm": 0, + "precip_in": 0, + "snow_cm": 0, + "humidity": 0, "cloud": 0, - "feelslike_c": 25.6, - "feelslike_f": 78.1, - "windchill_c": 26.8, - "windchill_f": 80.2, - "heatindex_c": 25.6, - "heatindex_f": 78.1, - "dewpoint_c": 4.2, - "dewpoint_f": 39.5, + "feelslike_c": 0, + "feelslike_f": 0, + "windchill_c": 0, + "windchill_f": 0, + "heatindex_c": 0, + "heatindex_f": 0, + "dewpoint_c": 0, + "dewpoint_f": 0, "will_it_rain": 0, "chance_of_rain": 0, "will_it_snow": 0, "chance_of_snow": 0, - "vis_km": 10.0, - "vis_miles": 6.0, - "gust_mph": 18.2, - "gust_kph": 29.3, + "vis_km": 0, + "vis_miles": 0, + "gust_mph": 0, + "gust_kph": 0, "uv": 0 } ] diff --git a/modules/menus/calendar/weather/index.ts b/modules/menus/calendar/weather/index.ts index c6a44f2..b6e0e9a 100644 --- a/modules/menus/calendar/weather/index.ts +++ b/modules/menus/calendar/weather/index.ts @@ -26,10 +26,19 @@ const WeatherWidget = () => { ) .then((res) => { try { - if (typeof res === "string") { - theWeather.value = JSON.parse(res); + if (typeof res !== "string") { + return theWeather.value = DEFAULT_WEATHER; } + + const parsedWeather = JSON.parse(res); + + if (Object.keys(parsedWeather).includes("error")) { + return theWeather.value = DEFAULT_WEATHER; + } + + return theWeather.value = parsedWeather; } catch (error) { + theWeather.value = DEFAULT_WEATHER; console.error(`Failed to parse weather data: ${error}`); } })