1
0
mirror of https://github.com/craigerl/aprsd.git synced 2026-01-23 05:55:44 -05:00

Remove openweathermap

OpenWeatherMap based plugins have been moved to the external
aprsd-openweathermap-plugins here:

https://github.com/hemna/aprsd-openweathermap-plugin

OWM plugins have been removed from aprsd proper because
they require a paid subscription now.  bye.
This commit is contained in:
Walter Boring 2026-01-21 15:27:05 -05:00
parent da3ef77ea3
commit e3fda752f6
3 changed files with 1 additions and 207 deletions

View File

@ -4,18 +4,10 @@ aprsfi_group = cfg.OptGroup(
name='aprs_fi',
title='APRS.FI website settings',
)
query_group = cfg.OptGroup(
name='query_plugin',
title='Options for the Query Plugin',
)
avwx_group = cfg.OptGroup(
name='avwx_plugin',
title='Options for the AVWXWeatherPlugin',
)
owm_wx_group = cfg.OptGroup(
name='owm_weather_plugin',
title='Options for the OWMWeatherPlugin',
)
aprsfi_opts = [
cfg.StrOpt(
@ -24,18 +16,6 @@ aprsfi_opts = [
),
]
owm_wx_opts = [
cfg.StrOpt(
'apiKey',
help="OWMWeatherPlugin api key to OpenWeatherMap's API."
'This plugin uses the openweathermap API to fetch'
'location and weather information.'
'To use this plugin you need to get an openweathermap'
'account and apikey.'
'https://home.openweathermap.org/api_keys',
),
]
avwx_opts = [
cfg.StrOpt(
'apiKey',
@ -57,9 +37,6 @@ avwx_opts = [
def register_opts(config):
config.register_group(aprsfi_group)
config.register_opts(aprsfi_opts, group=aprsfi_group)
config.register_group(query_group)
config.register_group(owm_wx_group)
config.register_opts(owm_wx_opts, group=owm_wx_group)
config.register_group(avwx_group)
config.register_opts(avwx_opts, group=avwx_group)
@ -67,6 +44,5 @@ def register_opts(config):
def list_opts():
return {
aprsfi_group.name: aprsfi_opts,
owm_wx_group.name: owm_wx_opts,
avwx_group.name: avwx_opts,
}

View File

@ -1,11 +1,10 @@
import logging
import re
import pytz
from oslo_config import cfg
from tzlocal import get_localzone
from aprsd import packets, plugin, plugin_utils
from aprsd import packets, plugin
from aprsd.utils import fuzzy, trace
CONF = cfg.CONF
@ -50,65 +49,3 @@ class TimePlugin(plugin.APRSDRegexCommandPluginBase):
# So we can mock this in unit tests
localzone = self._get_local_tz()
return self.build_date_str(localzone)
class TimeOWMPlugin(TimePlugin, plugin.APRSFIKEYMixin):
"""OpenWeatherMap based timezone fetching."""
command_regex = r'^([t]|[t]\s|time)'
command_name = 'time'
short_description = "Current time of GPS beacon's timezone. Uses OpenWeatherMap"
def setup(self):
self.ensure_aprs_fi_key()
@trace.trace
def process(self, packet: packets.MessagePacket):
fromcall = packet.from_call
message = packet.message_text
# ack = packet.get("msgNo", "0")
# optional second argument is a callsign to search
a = re.search(r'^.*\s+(.*)', message)
if a is not None:
searchcall = a.group(1)
searchcall = searchcall.upper()
else:
# if no second argument, search for calling station
searchcall = fromcall
api_key = CONF.aprs_fi.apiKey
try:
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 location'
LOG.debug(f'LocationPlugin: aprs_data = {aprs_data}')
if not len(aprs_data['entries']):
LOG.error("Didn't get any entries from aprs.fi")
return 'Failed to fetch aprs.fi location'
lat = aprs_data['entries'][0]['lat']
lon = aprs_data['entries'][0]['lng']
try:
self.config.exists(
['services', 'openweathermap', 'apiKey'],
)
except Exception as ex:
LOG.error(f'Failed to find config openweathermap:apiKey {ex}')
return 'No openweathermap apiKey found'
api_key = self.config['services']['openweathermap']['apiKey']
try:
results = plugin_utils.fetch_openweathermap(api_key, lat, lon)
except Exception as ex:
LOG.error(f"Couldn't fetch openweathermap api '{ex}'")
# default to UTC
localzone = pytz.timezone('UTC')
else:
tzone = results['timezone']
localzone = pytz.timezone(tzone)
return self.build_date_str(localzone)

View File

@ -170,125 +170,6 @@ class USMetarPlugin(plugin.APRSDRegexCommandPluginBase, plugin.APRSFIKEYMixin):
return reply
class OWMWeatherPlugin(plugin.APRSDRegexCommandPluginBase):
"""OpenWeatherMap Weather Command
This provides weather near the caller or callsign.
How to Call: Send a message to aprsd
"weather" - returns the weather near the calling callsign
"weather CALLSIGN" - returns the weather near CALLSIGN
This plugin uses the openweathermap API to fetch
location and weather information.
To use this plugin you need to get an openweathermap
account and apikey.
https://home.openweathermap.org/api_keys
"""
# command_regex = r"^([w][x]|[w][x]\s|weather)"
command_regex = r'^[wW]'
command_name = 'OpenWeatherMap'
short_description = 'OpenWeatherMap weather of GPS Beacon location'
def setup(self):
if not CONF.owm_weather_plugin.apiKey:
LOG.error('Config.owm_weather_plugin.apiKey is not set. Disabling')
self.enabled = False
else:
self.enabled = True
def help(self):
_help = [
'openweathermap: Send {} to get weather from your location'.format(
self.command_regex
),
'openweathermap: Send {} <callsign> to get weather from <callsign>'.format(
self.command_regex
),
]
return _help
@trace.trace
def process(self, packet):
fromcall = packet.get('from_call')
message = packet.get('message_text', None)
# ack = packet.get("msgNo", "0")
LOG.info(f"OWMWeather Plugin '{message}'")
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, searchcall)
except Exception as ex:
LOG.error(f'Failed to fetch aprs.fi data {ex}')
return 'Failed to fetch location'
# LOG.debug("LocationPlugin: aprs_data = {}".format(aprs_data))
if not len(aprs_data['entries']):
LOG.error('Found no entries from aprs.fi!')
return 'Failed to fetch location'
lat = aprs_data['entries'][0]['lat']
lon = aprs_data['entries'][0]['lng']
units = CONF.units
api_key = CONF.owm_weather_plugin.apiKey
try:
wx_data = plugin_utils.fetch_openweathermap(
api_key,
lat,
lon,
units=units,
exclude='minutely,hourly',
)
except Exception as ex:
LOG.error(f"Couldn't fetch openweathermap api '{ex}'")
# default to UTC
return 'Unable to get weather'
if units == 'metric':
degree = 'C'
else:
degree = 'F'
if 'wind_gust' in wx_data['current']:
wind = '{:.0f}@{}G{:.0f}'.format(
wx_data['current']['wind_speed'],
wx_data['current']['wind_deg'],
wx_data['current']['wind_gust'],
)
else:
wind = '{:.0f}@{}'.format(
wx_data['current']['wind_speed'],
wx_data['current']['wind_deg'],
)
# LOG.debug(wx_data["current"])
# LOG.debug(wx_data["daily"])
reply = '{} {:.1f}{}/{:.1f}{} Wind {} {}%'.format(
wx_data['current']['weather'][0]['description'],
wx_data['current']['temp'],
degree,
wx_data['current']['dew_point'],
degree,
wind,
wx_data['current']['humidity'],
)
return reply
class AVWXWeatherPlugin(plugin.APRSDRegexCommandPluginBase):
"""AVWXWeatherMap Weather Command