From ba1447d5f4c2555227a9b1a3b0118cbd2fb379a3 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 7 Aug 2024 18:04:22 -0700 Subject: [PATCH 01/14] inital --- config.template | 8 ++- mesh_bot.py | 30 ++++++---- modules/settings.py | 5 +- modules/system.py | 4 ++ modules/wx_meteo.py | 139 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 170 insertions(+), 16 deletions(-) create mode 100644 modules/wx_meteo.py diff --git a/config.template b/config.template index 6168d84..48749f6 100644 --- a/config.template +++ b/config.template @@ -54,10 +54,12 @@ bbs_admin_list = enabled = True lat = 48.50 lon = -123.0 -# weather forecast days, the first two rows are today and tonight -DAYS_OF_WEATHER = 4 +# NOAA weather forecast days, the first two rows are today and tonight +NOAAforecastDuration = 4 # number of weather alerts to display -ALERT_COUNT = 2 +NOAAalertCount = 2 +# use Open-Meteo API for weather data not NOAA usefull for non US locations +UseMeteoWxAPI = False # solar module [solar] diff --git a/mesh_bot.py b/mesh_bot.py index 1945010..02b21db 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -82,21 +82,26 @@ def auto_response(message, snr, rssi, hop, message_from_id, channel_number, devi location = get_node_location(message_from_id, deviceID) moon = get_moon(str(location[0]),str(location[1])) bot_response = moon - elif "wxalert" in message.lower(): - location = get_node_location(message_from_id, deviceID) - weatherAlert = getActiveWeatherAlertsDetail(str(location[0]),str(location[1])) - bot_response = weatherAlert - elif "wxa" in message.lower(): - location = get_node_location(message_from_id, deviceID) - weatherAlert = getWeatherAlerts(str(location[0]),str(location[1])) - bot_response = weatherAlert + elif "wxalert" in message.lower() or "wxa" in message.lower(): + if use_meteo_wxApi: + bot_response = "wxalert is not supported in Open-Meteo API" + else: + location = get_node_location(message_from_id, deviceID) + weatherAlert = getActiveWeatherAlertsDetail(str(location[0]),str(location[1])) + bot_response = weatherAlert elif "wxc" in message.lower(): location = get_node_location(message_from_id, deviceID) - weather = get_weather(str(location[0]),str(location[1]),1) + if use_meteo_wxApi: + weather = get_wx_meteo(str(location[0]),str(location[1]),1) + else: + weather = get_weather(str(location[0]),str(location[1]),1) bot_response = weather elif "wx" in message.lower(): location = get_node_location(message_from_id, deviceID) - weather = get_weather(str(location[0]),str(location[1])) + if use_meteo_wxApi: + weather = get_wx_meteo(str(location[0]),str(location[1])) + else: + weather = get_weather(str(location[0]),str(location[1])) bot_response = weather elif "joke" in message.lower(): bot_response = tell_joke() @@ -335,7 +340,10 @@ async def start_rx(): if solar_conditions_enabled: logger.debug(f"System: Celestial Telemetry Enabled") if location_enabled: - logger.debug(f"System: Location Telemetry Enabled") + if use_meteo_wxApi: + logger.debug(f"System: Location Telemetry Enabled using Open-Meteo API") + else: + logger.debug(f"System: Location Telemetry Enabled using NOAA API") if dad_jokes_enabled: logger.debug(f"System: Dad Jokes Enabled!") if store_forward_enabled: diff --git a/modules/settings.py b/modules/settings.py index 7c3b24a..14cbe2b 100644 --- a/modules/settings.py +++ b/modules/settings.py @@ -64,6 +64,7 @@ try: location_enabled = config['location'].getboolean('enabled', False) latitudeValue = config['location'].getfloat('lat', 48.50) longitudeValue = config['location'].getfloat('lon', -123.0) + use_meteo_wxApi = config['location'].getboolean('UseMeteoWxAPI', False) # default False use NOAA zuluTime = config['general'].getboolean('zuluTime', False) welcome_message = config['general'].get(f'welcome_message', WELCOME_MSG) welcome_message = (f"{welcome_message}").replace('\\n', '\n') # allow for newlines in the welcome message @@ -75,8 +76,8 @@ try: log_messages_to_file = config['general'].getboolean('LogMessagesToFile', True) # default True config['general'].get('motd', MOTD) urlTimeoutSeconds = config['general'].getint('URL_TIMEOUT', 10) # default 10 seconds - forecastDuration = config['general'].getint('DAYS_OF_WEATHER', 4) # default days of weather - numWxAlerts = config['general'].getint('ALERT_COUNT', 2) # default 2 alerts + forecastDuration = config['general'].getint('NOAAforecastDuration', 4) # NOAA forcast days + numWxAlerts = config['general'].getint('NOAAalertCount', 2) # default 2 alerts bbs_ban_list = config['bbs'].get('bbs_ban_list', '').split(',') bbs_admin_list = config['bbs'].get('bbs_admin_list', '').split(',') repeater_enabled = config['repeater'].getboolean('enabled', False) diff --git a/modules/system.py b/modules/system.py index b2406c2..f5b2071 100644 --- a/modules/system.py +++ b/modules/system.py @@ -36,6 +36,10 @@ if location_enabled: from modules.locationdata import * # from the spudgunman/meshing-around repo trap_list = trap_list + trap_list_location # items tide, whereami, wxc, wx help_message = help_message + ", whereami, wx, wxc, wxa" + + # Open-Meteo Configuration for worldwide weather + if use_meteo_wxApi: + from modules.wx_meteo import * # from the spudgunman/meshing-around repo # BBS Configuration if bbs_enabled: diff --git a/modules/wx_meteo.py b/modules/wx_meteo.py new file mode 100644 index 0000000..73ebad5 --- /dev/null +++ b/modules/wx_meteo.py @@ -0,0 +1,139 @@ +import openmeteo_requests +from retry_requests import retry +#import requests_cache +from modules.log import * + +def get_wx_meteo(lat=0, lon=0, unit=0): + # set forcast days 1 or 3 + forecastDays = 3 + + # Setup the Open-Meteo API client with cache and retry on error + #cache_session = requests_cache.CachedSession('.cache', expire_after = 3600) + #retry_session = retry(cache_session, retries = 5, backoff_factor = 0.2) + retry_session = retry(retries = 3, backoff_factor = 0.2) + openmeteo = openmeteo_requests.Client(session = retry_session) + + # Make sure all required weather variables are listed here + # The order of variables in hourly or daily is important to assign them correctly below + url = "https://api.open-meteo.com/v1/forecast" + params = { + "latitude": {lat}, + "longitude": {lon}, + "daily": ["weather_code", "temperature_2m_max", "temperature_2m_min", "precipitation_hours", "precipitation_probability_max", "wind_speed_10m_max", "wind_gusts_10m_max", "wind_direction_10m_dominant"], + "timezone": "auto", + "forecast_days": {forecastDays} + } + + # Unit 0 is imperial, 1 is metric + if unit == 0: + params["temperature_unit"] = "fahrenheit" + params["wind_speed_unit"] = "mph" + params["precipitation_unit"] = "inch" + params["distance_unit"] = "mile" + params["pressure_unit"] = "inHg" + + responses = openmeteo.weather_api(url, params=params) + + # Process first location. Add a for-loop for multiple locations or weather models + response = responses[0] + logger.debug(f"Got wx data from Open-Meteo in {response.Timezone()} {response.TimezoneAbbreviation()}") + + # Process daily data. The order of variables needs to be the same as requested. + daily = response.Daily() + daily_weather_code = daily.Variables(0).ValuesAsNumpy() + daily_temperature_2m_max = daily.Variables(1).ValuesAsNumpy() + daily_temperature_2m_min = daily.Variables(2).ValuesAsNumpy() + daily_precipitation_hours = daily.Variables(3).ValuesAsNumpy() + daily_precipitation_probability_max = daily.Variables(4).ValuesAsNumpy() + daily_wind_speed_10m_max = daily.Variables(5).ValuesAsNumpy() + daily_wind_gusts_10m_max = daily.Variables(6).ValuesAsNumpy() + daily_wind_direction_10m_dominant = daily.Variables(7).ValuesAsNumpy() + + # convert wind value to cardinal directions + for value in daily_wind_direction_10m_dominant: + if value < 22.5: + wind_direction = "N" + elif value < 67.5: + wind_direction = "NE" + elif value < 112.5: + wind_direction = "E" + elif value < 157.5: + wind_direction = "SE" + elif value < 202.5: + wind_direction = "S" + elif value < 247.5: + wind_direction = "SW" + elif value < 292.5: + wind_direction = "W" + elif value < 337.5: + wind_direction = "NW" + else: + wind_direction = "N" + + # create a weather report + weather_report = "" + for i in range(forecastDays): + if str(i + 1) == "1": + weather_report += "Today, " + elif str(i + 1) == "2": + weather_report += "Tomorrow, " + else: + weather_report += "Beyond tomorrow, " + + # report weather from WMO Weather interpretation codes (WW) + code_string = "" + if daily_weather_code[i] == 0: + code_string = "Clear sky" + elif daily_weather_code[i] == 1 or 2 or 3: + code_string = "Partly cloudy" + elif daily_weather_code[i] == 45 or 48: + code_string = "Fog" + elif daily_weather_code[i] == 51 or 53 or 55: + code_string = "Drizzle: Light, moderate, and dense intensity" + elif daily_weather_code[i] == 56 or 57: + code_string = "Freezing Drizzle: Light and dense intensity" + elif daily_weather_code[i] == 61 or 63 or 65: + code_string = "Rain: Slight, moderate and heavy intensity" + elif daily_weather_code[i] == 66 or 67: + code_string = "Freezing Rain: Light and dense intensity" + elif daily_weather_code[i] == 71 or 73 or 75: + code_string = "Snow: Light, moderate and heavy intensity" + elif daily_weather_code[i] == 77: + code_string = "Snow Grains" + elif daily_weather_code[i] == 80 or 81 or 82: + code_string = "Rain showers: Slight, moderate, and violent" + elif daily_weather_code[i] == 85 or 86: + code_string = "Snow showers slight and heavy" + elif daily_weather_code[i] == 95: + code_string = "Thunderstorm: Slight or moderate" + elif daily_weather_code[i] == 96 or 99: + code_string = "Thunderstorm with slight and heavy hail" + + weather_report += "Conditions " + code_string + ". " + + # report temperature + if unit == 0: + weather_report += "High Temp: " + str(round(daily_temperature_2m_max[i],2)) + "F, with a low of " + str(round(daily_temperature_2m_min[i],2)) + "F. " + else: + weather_report += "High Temp: " + str(round(daily_temperature_2m_max[i],2)) + "C, with a low of " + str(round(daily_temperature_2m_min[i],2)) + "C. " + + # check for precipitation + if daily_precipitation_hours[i] > 0: + if unit == 0: + weather_report += "Precipitation Probability: " + str(round(daily_precipitation_probability_max[i],2)) + "in. in " + str(round(daily_precipitation_hours[i],2)) + " hours. " + else: + weather_report += "Precipitation Probability: " + str(round(daily_precipitation_probability_max[i],2)) + "mm. in " + str(round(daily_precipitation_hours[i],2)) + " hours. " + else: + weather_report += "No Precip. " + + # check for wind + if daily_wind_speed_10m_max[i] > 0: + if unit == 0: + weather_report += "Max Wind Speed: " + str(round(daily_wind_speed_10m_max[i],2)) + "mph with gusts up to " + str(round(daily_wind_gusts_10m_max[i],2)) + "mph out of:" + wind_direction + "\n" + else: + weather_report += "Max Wind Speed: " + str(round(daily_wind_speed_10m_max[i],2)) + "kph with gusts up to " + str(round(daily_wind_gusts_10m_max[i],2)) + "kph out of:" + wind_direction + "\n" + else: + weather_report += "No Wind\n" + + return weather_report + From 922956e981ae54f4635eb2c35d4242719ccf91bd Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 7 Aug 2024 18:12:58 -0700 Subject: [PATCH 02/14] Update wx_meteo.py --- modules/wx_meteo.py | 63 ++++++++++++++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/modules/wx_meteo.py b/modules/wx_meteo.py index 73ebad5..868f594 100644 --- a/modules/wx_meteo.py +++ b/modules/wx_meteo.py @@ -88,28 +88,52 @@ def get_wx_meteo(lat=0, lon=0, unit=0): code_string = "Partly cloudy" elif daily_weather_code[i] == 45 or 48: code_string = "Fog" - elif daily_weather_code[i] == 51 or 53 or 55: - code_string = "Drizzle: Light, moderate, and dense intensity" - elif daily_weather_code[i] == 56 or 57: - code_string = "Freezing Drizzle: Light and dense intensity" - elif daily_weather_code[i] == 61 or 63 or 65: - code_string = "Rain: Slight, moderate and heavy intensity" - elif daily_weather_code[i] == 66 or 67: - code_string = "Freezing Rain: Light and dense intensity" - elif daily_weather_code[i] == 71 or 73 or 75: - code_string = "Snow: Light, moderate and heavy intensity" + elif daily_weather_code[i] == 51: + code_string = "Drizzle: Light" + elif daily_weather_code[i] == 53: + code_string = "Drizzle: Moderate" + elif daily_weather_code[i] == 55: + code_string = "Drizzle: Heavy" + elif daily_weather_code[i] == 56: + code_string = "Freezing Drizzle: Light" + elif daily_weather_code[i] == 57: + code_string = "Freezing Drizzle: Moderate" + elif daily_weather_code[i] == 61: + code_string = "Rain: Slight" + elif daily_weather_code[i] == 63: + code_string = "Rain: Moderate" + elif daily_weather_code[i] == 65: + code_string = "Rain: Heavy" + elif daily_weather_code[i] == 66: + code_string = "Freezing Rain: Light" + elif daily_weather_code[i] == 67: + code_string = "Freezing Rain: Dense" + elif daily_weather_code[i] == 71: + code_string = "Snow: Light" + elif daily_weather_code[i] == 73: + code_string = "Snow: Moderate" + elif daily_weather_code[i] == 75: + code_string = "Snow: Heavy" elif daily_weather_code[i] == 77: code_string = "Snow Grains" - elif daily_weather_code[i] == 80 or 81 or 82: - code_string = "Rain showers: Slight, moderate, and violent" - elif daily_weather_code[i] == 85 or 86: - code_string = "Snow showers slight and heavy" + elif daily_weather_code[i] == 80: + code_string = "Rain showers: Slight" + elif daily_weather_code[i] == 81: + code_string = "Rain showers: Moderate" + elif daily_weather_code[i] == 82: + code_string = "Rain showers: Heavy" + elif daily_weather_code[i] == 85: + code_string = "Snow showers: Light" + elif daily_weather_code[i] == 86: + code_string = "Snow showers: Moderate" elif daily_weather_code[i] == 95: - code_string = "Thunderstorm: Slight or moderate" - elif daily_weather_code[i] == 96 or 99: - code_string = "Thunderstorm with slight and heavy hail" + code_string = "Thunderstorm: Slight" + elif daily_weather_code[i] == 96: + code_string = "Thunderstorm: Moderate" + elif daily_weather_code[i] == 99: + code_string = "Thunderstorm: Heavy" - weather_report += "Conditions " + code_string + ". " + weather_report += "Cond: " + code_string + ". " # report temperature if unit == 0: @@ -135,5 +159,8 @@ def get_wx_meteo(lat=0, lon=0, unit=0): else: weather_report += "No Wind\n" + #trim last newline + weather_report = weather_report[:-1] + return weather_report From fbd38aa147c103845d2652721d12b19edd48cf13 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 7 Aug 2024 18:52:42 -0700 Subject: [PATCH 03/14] Update README.md addressing issue https://github.com/SpudGunMan/meshing-around/issues/23 --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 76b3f7b..0030025 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Any messages that are over 160 characters are chunked into 160 message bytes to - Other functions - `whereami` returns the address of location of sender if known - `tide` returns the local tides, NOAA data source - - `wx` and `wxc` returns local weather forecast, NOAA data source (wxc is metric value) + - `wx` and `wxc` returns local weather forecast, (wxc is metric value), NOAA or Open Meteo for weather forcasting. - `wxa` and `wxalert` return NOAA alerts. Short title or expanded details - `joke` tells a joke - `messages` Replay the last messages heard, like Store and Forward @@ -80,6 +80,14 @@ Setting the default channel is the channel that won't be spammed by the bot. It' respond_by_dm_only = True defaultChannel = 0 ``` +The weather forcasting defaults to NOAA but for outside the USA you can set UseMeteoWxAPI `True` to use a world weather API. The lat and lon are for defaults when a node has no location data to use. +``` +[location] +enabled = True +lat = 48.50 +lon = -123.0 +UseMeteoWxAPI = True +``` Modules can be disabled or enabled. ``` From 49c0f3b1c5d490c8c1b3c5aafb7a856966cbe359 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 7 Aug 2024 19:10:03 -0700 Subject: [PATCH 04/14] Update wx_meteo.py --- modules/wx_meteo.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/modules/wx_meteo.py b/modules/wx_meteo.py index 868f594..55d4cf1 100644 --- a/modules/wx_meteo.py +++ b/modules/wx_meteo.py @@ -78,7 +78,7 @@ def get_wx_meteo(lat=0, lon=0, unit=0): elif str(i + 1) == "2": weather_report += "Tomorrow, " else: - weather_report += "Beyond tomorrow, " + weather_report += "Futurecast: " # report weather from WMO Weather interpretation codes (WW) code_string = "" @@ -137,30 +137,31 @@ def get_wx_meteo(lat=0, lon=0, unit=0): # report temperature if unit == 0: - weather_report += "High Temp: " + str(round(daily_temperature_2m_max[i],2)) + "F, with a low of " + str(round(daily_temperature_2m_min[i],2)) + "F. " + weather_report += "High: " + str(round(daily_temperature_2m_max[i],2)) + "F, with a low of " + str(round(daily_temperature_2m_min[i],2)) + "F. " else: - weather_report += "High Temp: " + str(round(daily_temperature_2m_max[i],2)) + "C, with a low of " + str(round(daily_temperature_2m_min[i],2)) + "C. " + weather_report += "High: " + str(round(daily_temperature_2m_max[i],2)) + "C, with a low of " + str(round(daily_temperature_2m_min[i],2)) + "C. " # check for precipitation if daily_precipitation_hours[i] > 0: if unit == 0: - weather_report += "Precipitation Probability: " + str(round(daily_precipitation_probability_max[i],2)) + "in. in " + str(round(daily_precipitation_hours[i],2)) + " hours. " + weather_report += "Precipitation: " + str(round(daily_precipitation_probability_max[i],2)) + "in, in " + str(round(daily_precipitation_hours[i],2)) + " hours. " else: - weather_report += "Precipitation Probability: " + str(round(daily_precipitation_probability_max[i],2)) + "mm. in " + str(round(daily_precipitation_hours[i],2)) + " hours. " + weather_report += "Precipitation: " + str(round(daily_precipitation_probability_max[i],2)) + "mm, in " + str(round(daily_precipitation_hours[i],2)) + " hours. " else: weather_report += "No Precip. " # check for wind if daily_wind_speed_10m_max[i] > 0: if unit == 0: - weather_report += "Max Wind Speed: " + str(round(daily_wind_speed_10m_max[i],2)) + "mph with gusts up to " + str(round(daily_wind_gusts_10m_max[i],2)) + "mph out of:" + wind_direction + "\n" + weather_report += "Max Wind Speed: " + str(round(daily_wind_speed_10m_max[i],2)) + "mph with gusts up to " + str(round(daily_wind_gusts_10m_max[i],2)) + "mph from:" + wind_direction else: - weather_report += "Max Wind Speed: " + str(round(daily_wind_speed_10m_max[i],2)) + "kph with gusts up to " + str(round(daily_wind_gusts_10m_max[i],2)) + "kph out of:" + wind_direction + "\n" + weather_report += "Max Wind Speed: " + str(round(daily_wind_speed_10m_max[i],2)) + "kph with gusts up to " + str(round(daily_wind_gusts_10m_max[i],2)) + "kph from:" + wind_direction else: weather_report += "No Wind\n" - #trim last newline - weather_report = weather_report[:-1] + # add a new line for the next day + if i < forecastDays - 1: + weather_report += "\n" return weather_report From f6ff4e2d7d08edb2fca6cee77da5446b5c089ae8 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 7 Aug 2024 19:20:24 -0700 Subject: [PATCH 05/14] short-strings --- modules/wx_meteo.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/wx_meteo.py b/modules/wx_meteo.py index 55d4cf1..e2575ff 100644 --- a/modules/wx_meteo.py +++ b/modules/wx_meteo.py @@ -137,25 +137,25 @@ def get_wx_meteo(lat=0, lon=0, unit=0): # report temperature if unit == 0: - weather_report += "High: " + str(round(daily_temperature_2m_max[i],2)) + "F, with a low of " + str(round(daily_temperature_2m_min[i],2)) + "F. " + weather_report += "High: " + str(int(round(daily_temperature_2m_max[i]))) + "F, with a low of " + str(int(round(daily_temperature_2m_min[i]))) + "F. " else: - weather_report += "High: " + str(round(daily_temperature_2m_max[i],2)) + "C, with a low of " + str(round(daily_temperature_2m_min[i],2)) + "C. " + weather_report += "High: " + str(int(round(daily_temperature_2m_max[i]))) + "C, with a low of " + str(int(round(daily_temperature_2m_min[i]))) + "C. " # check for precipitation if daily_precipitation_hours[i] > 0: if unit == 0: - weather_report += "Precipitation: " + str(round(daily_precipitation_probability_max[i],2)) + "in, in " + str(round(daily_precipitation_hours[i],2)) + " hours. " + weather_report += "Precip: " + str(round(daily_precipitation_probability_max[i],2)) + "in, in " + str(round(daily_precipitation_hours[i],2)) + " hours. " else: - weather_report += "Precipitation: " + str(round(daily_precipitation_probability_max[i],2)) + "mm, in " + str(round(daily_precipitation_hours[i],2)) + " hours. " + weather_report += "Precip: " + str(round(daily_precipitation_probability_max[i],2)) + "mm, in " + str(round(daily_precipitation_hours[i],2)) + " hours. " else: weather_report += "No Precip. " # check for wind if daily_wind_speed_10m_max[i] > 0: if unit == 0: - weather_report += "Max Wind Speed: " + str(round(daily_wind_speed_10m_max[i],2)) + "mph with gusts up to " + str(round(daily_wind_gusts_10m_max[i],2)) + "mph from:" + wind_direction + weather_report += "Wind: " + str(int(round(daily_wind_speed_10m_max[i]))) + "mph, gusts up to " + str(int(round(daily_wind_gusts_10m_max[i]))) + "mph from:" + wind_direction + "." else: - weather_report += "Max Wind Speed: " + str(round(daily_wind_speed_10m_max[i],2)) + "kph with gusts up to " + str(round(daily_wind_gusts_10m_max[i],2)) + "kph from:" + wind_direction + weather_report += "Wind: " + str(int(round(daily_wind_speed_10m_max[i]))) + "kph, gusts up to " + str(int(round(daily_wind_gusts_10m_max[i]))) + "kph from:" + wind_direction + "." else: weather_report += "No Wind\n" From 5e0ab39301cc5431d4c9d993d3a63e9609e27120 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 7 Aug 2024 19:27:29 -0700 Subject: [PATCH 06/14] requirements update --- README.md | 1 + requirements.txt | 1 + 2 files changed, 2 insertions(+) diff --git a/README.md b/README.md index 0030025..c30a855 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,7 @@ pip install geopy pip install maidenhead pip install beautifulsoup4 pip install dadjokes +pip install openmeteo_requests ``` To enable emoji in the Debian console, install the fonts `sudo apt-get install fonts-noto-color-emoji` diff --git a/requirements.txt b/requirements.txt index 370a21d..cd19afd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -7,3 +7,4 @@ geopy maidenhead beautifulsoup4 dadjokes +openmeteo_requests From 7cabff0bc4af4dad3419a8f89293190ba927d638 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 7 Aug 2024 19:27:47 -0700 Subject: [PATCH 07/14] Update wx_meteo.py --- modules/wx_meteo.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/wx_meteo.py b/modules/wx_meteo.py index e2575ff..8e403b8 100644 --- a/modules/wx_meteo.py +++ b/modules/wx_meteo.py @@ -1,4 +1,4 @@ -import openmeteo_requests +import openmeteo_requests # pip install openmeteo-requests from retry_requests import retry #import requests_cache from modules.log import * From 88d1ecc7ec8204bfd6239c7c59cf9f8b5ff8779c Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 7 Aug 2024 19:40:20 -0700 Subject: [PATCH 08/14] Update system.py --- modules/system.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/system.py b/modules/system.py index f5b2071..ef66604 100644 --- a/modules/system.py +++ b/modules/system.py @@ -35,11 +35,13 @@ if solar_conditions_enabled: if location_enabled: from modules.locationdata import * # from the spudgunman/meshing-around repo trap_list = trap_list + trap_list_location # items tide, whereami, wxc, wx - help_message = help_message + ", whereami, wx, wxc, wxa" + help_message = help_message + ", whereami, wx, wxc" # Open-Meteo Configuration for worldwide weather if use_meteo_wxApi: from modules.wx_meteo import * # from the spudgunman/meshing-around repo + else: + help_message = help_message + ", wxa, tide" # BBS Configuration if bbs_enabled: From 14c304ca2d4d5d8f6a08dff1cb7d47a4bb20557a Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 7 Aug 2024 19:40:41 -0700 Subject: [PATCH 09/14] Update system.py --- modules/system.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/system.py b/modules/system.py index ef66604..d15cf5d 100644 --- a/modules/system.py +++ b/modules/system.py @@ -29,7 +29,7 @@ if sitrep_enabled: if solar_conditions_enabled: from modules.solarconditions import * # from the spudgunman/meshing-around repo trap_list = trap_list + trap_list_solarconditions # items hfcond, solar, sun, moon - help_message = help_message + ", sun, hfcond, solar, moon, tide" + help_message = help_message + ", sun, hfcond, solar, moon" # Location Configuration if location_enabled: From 1cb9a60bbad98981a04f70dfa6e529fb9a903abf Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 7 Aug 2024 19:42:48 -0700 Subject: [PATCH 10/14] Update system.py --- modules/system.py | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/system.py b/modules/system.py index d15cf5d..ac1ad1a 100644 --- a/modules/system.py +++ b/modules/system.py @@ -41,6 +41,7 @@ if location_enabled: if use_meteo_wxApi: from modules.wx_meteo import * # from the spudgunman/meshing-around repo else: + # NOAA only features help_message = help_message + ", wxa, tide" # BBS Configuration From b084b0f79e3199b990dbe9140d1d25d3bb83eba4 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 7 Aug 2024 19:59:34 -0700 Subject: [PATCH 11/14] Update mesh_bot.py --- mesh_bot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mesh_bot.py b/mesh_bot.py index 7a2cbe8..e61e569 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -84,7 +84,7 @@ def auto_response(message, snr, rssi, hop, message_from_id, channel_number, devi bot_response = moon elif "wxalert" in message.lower() or "wxa" in message.lower(): if use_meteo_wxApi: - bot_response = "wxalert is not supported in Open-Meteo API" + bot_response = "wxalert is not supported" else: location = get_node_location(message_from_id, deviceID) weatherAlert = getActiveWeatherAlertsDetail(str(location[0]),str(location[1])) From 932b98a634eb4c00575d617822a036e9b37dd82a Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 7 Aug 2024 20:04:01 -0700 Subject: [PATCH 12/14] debug --- modules/system.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/system.py b/modules/system.py index 0e4a319..3a02c05 100644 --- a/modules/system.py +++ b/modules/system.py @@ -199,8 +199,8 @@ def get_node_list(nodeInt=1): node_list2.sort(key=lambda x: x[1], reverse=True) except Exception as e: logger.error(f"System: Error sorting node list: {e}") - print (f"Node List1: {node_list1[:5]}\n") - print (f"Node List2: {node_list2[:5]}\n") + #print (f"Node List1: {node_list1[:5]}\n") + #print (f"Node List2: {node_list2[:5]}\n") # make a nice list for the user for x in node_list1[:SITREP_NODE_COUNT]: From ab00cb11bb62a4f56feba167de24fc22b9533a26 Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 7 Aug 2024 20:05:27 -0700 Subject: [PATCH 13/14] Update system.py --- modules/system.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/modules/system.py b/modules/system.py index 3a02c05..81aa086 100644 --- a/modules/system.py +++ b/modules/system.py @@ -199,18 +199,23 @@ def get_node_list(nodeInt=1): node_list2.sort(key=lambda x: x[1], reverse=True) except Exception as e: logger.error(f"System: Error sorting node list: {e}") + node_list = "Error creating node list" #print (f"Node List1: {node_list1[:5]}\n") #print (f"Node List2: {node_list2[:5]}\n") - # make a nice list for the user - for x in node_list1[:SITREP_NODE_COUNT]: - short_node_list.append(f"{x[0]} SNR:{x[2]}") - for x in node_list2[:SITREP_NODE_COUNT]: - short_node_list.append(f"{x[0]} SNR:{x[2]}") + try: + # make a nice list for the user + for x in node_list1[:SITREP_NODE_COUNT]: + short_node_list.append(f"{x[0]} SNR:{x[2]}") + for x in node_list2[:SITREP_NODE_COUNT]: + short_node_list.append(f"{x[0]} SNR:{x[2]}") - for x in short_node_list: - if x != "" or x != '\n': - node_list += x + "\n" + for x in short_node_list: + if x != "" or x != '\n': + node_list += x + "\n" + except Exception as e: + logger.error(f"System: Error creating node list: {e}") + node_list = "Error creating node list" return node_list From e533e1472ec0fd79157d9d6fe73f38350af10a5a Mon Sep 17 00:00:00 2001 From: SpudGunMan Date: Wed, 7 Aug 2024 20:06:19 -0700 Subject: [PATCH 14/14] fix --- modules/system.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/system.py b/modules/system.py index 81aa086..a1ca781 100644 --- a/modules/system.py +++ b/modules/system.py @@ -199,7 +199,7 @@ def get_node_list(nodeInt=1): node_list2.sort(key=lambda x: x[1], reverse=True) except Exception as e: logger.error(f"System: Error sorting node list: {e}") - node_list = "Error creating node list" + node_list = ERROR_FETCHING_DATA #print (f"Node List1: {node_list1[:5]}\n") #print (f"Node List2: {node_list2[:5]}\n") @@ -215,7 +215,7 @@ def get_node_list(nodeInt=1): node_list += x + "\n" except Exception as e: logger.error(f"System: Error creating node list: {e}") - node_list = "Error creating node list" + node_list = ERROR_FETCHING_DATA return node_list