From 986df391b2eb5af78f26b95fa1c989760dfa2a56 Mon Sep 17 00:00:00 2001 From: Hemna Date: Mon, 31 Jul 2023 21:53:02 -0400 Subject: [PATCH] re-enable USWeatherPlugin to use mapClick The old MApClick.php api seems to work...re-enabling --- aprsd/plugin_utils.py | 6 +++--- aprsd/plugins/weather.py | 9 ++++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/aprsd/plugin_utils.py b/aprsd/plugin_utils.py index 5b8234f..33fe455 100644 --- a/aprsd/plugin_utils.py +++ b/aprsd/plugin_utils.py @@ -33,9 +33,9 @@ def get_weather_gov_for_gps(lat, lon): ) try: url2 = ( - # "https://forecast.weather.gov/MapClick.php?lat=%s" - # "&lon=%s&FcstType=json" % (lat, lon) - f"https://api.weather.gov/points/{lat},{lon}" + "https://forecast.weather.gov/MapClick.php?lat=%s" + "&lon=%s&FcstType=json" % (lat, lon) + #f"https://api.weather.gov/points/{lat},{lon}" ) LOG.debug(f"Fetching weather '{url2}'") response = requests.get(url2, headers=headers) diff --git a/aprsd/plugins/weather.py b/aprsd/plugins/weather.py index 821dcce..8f07f39 100644 --- a/aprsd/plugins/weather.py +++ b/aprsd/plugins/weather.py @@ -37,11 +37,18 @@ class USWeatherPlugin(plugin.APRSDRegexCommandPluginBase, plugin.APRSFIKEYMixin) def process(self, packet): LOG.info("Weather Plugin") fromcall = packet.from_call + message = packet.get("message_text", None) # message = packet.get("message_text", None) # ack = packet.get("msgNo", "0") + a = re.search(r"^.*\s+(.*)", message) + if a is not None: + searchcall = a.group(1) + searchcall = searchcall.upper() + else: + searchcall = fromcall api_key = CONF.aprs_fi.apiKey try: - aprs_data = plugin_utils.get_aprs_fi(api_key, fromcall) + aprs_data = plugin_utils.get_aprs_fi(api_key, searchcall) except Exception as ex: LOG.error(f"Failed to fetch aprs.fi data {ex}") return "Failed to fetch aprs.fi location"