diff --git a/config.template b/config.template index 48749f6..0e71c2f 100644 --- a/config.template +++ b/config.template @@ -60,6 +60,8 @@ NOAAforecastDuration = 4 NOAAalertCount = 2 # use Open-Meteo API for weather data not NOAA usefull for non US locations UseMeteoWxAPI = False +# Default to metric units rather than imperial +useMetric = False # solar module [solar] diff --git a/mesh_bot.py b/mesh_bot.py index e61e569..3d13174 100755 --- a/mesh_bot.py +++ b/mesh_bot.py @@ -89,18 +89,19 @@ def auto_response(message, snr, rssi, hop, message_from_id, channel_number, devi location = get_node_location(message_from_id, deviceID) weatherAlert = getActiveWeatherAlertsDetail(str(location[0]),str(location[1])) bot_response = weatherAlert - elif "wxc" in message.lower(): + elif "wxc" in message.lower() or "wx" in message.lower(): location = get_node_location(message_from_id, deviceID) - 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) - if use_meteo_wxApi: + if use_meteo_wxApi and not "wxc" in message.lower() and not use_metric: + logger.debug(f"System: Returning Open-Meteo API for weather imperial") weather = get_wx_meteo(str(location[0]),str(location[1])) + elif use_meteo_wxApi: + logger.debug(f"System: Returning Open-Meteo API for weather metric") + weather = get_wx_meteo(str(location[0]),str(location[1]),1) + elif not use_meteo_wxApi and "wxc" in message.lower() or use_metric: + logger.debug(f"System: Returning NOAA API for weather metric") + weather = get_weather(str(location[0]),str(location[1]),1) else: + logger.debug(f"System: Returning NOAA API for weather imperial") weather = get_weather(str(location[0]),str(location[1])) bot_response = weather elif "joke" in message.lower(): diff --git a/modules/settings.py b/modules/settings.py index 14cbe2b..30e93c7 100644 --- a/modules/settings.py +++ b/modules/settings.py @@ -65,6 +65,7 @@ try: 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 + use_metric = config['location'].getboolean('useMetric', False) # default Imperial units 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