Added enabled config option for the plugin.

This commit is contained in:
Walter Boring 2026-01-22 17:48:44 -05:00
parent 93095879b9
commit fa012069c1
4 changed files with 66 additions and 3 deletions

View File

@ -1,6 +1,6 @@
from oslo_config import cfg
from aprsd_weewx_plugin.conf import weewx
from aprsd_weewx_plugin.conf import main
CONF = cfg.CONF
weewx.register_opts(CONF)
main.register_opts(CONF)

View File

@ -0,0 +1,58 @@
from oslo_config import cfg
weewx_group = cfg.OptGroup(
name="aprsd_weewx_plugin",
title="APRSD Weewx Plugin settings",
)
weewx_opts = [
cfg.FloatOpt(
"latitude",
default=None,
help="Latitude of the station you want to report as",
),
cfg.FloatOpt(
"longitude",
default=None,
help="Longitude of the station you want to report as",
),
cfg.IntOpt(
"report_interval",
default=60,
help="How long (in seconds) in between weather reports",
),
]
weewx_mqtt_opts = [
cfg.StrOpt(
"mqtt_user",
help="MQTT username",
),
cfg.StrOpt(
"mqtt_password",
secret=True,
help="MQTT password",
),
cfg.StrOpt(
"mqtt_host",
help="MQTT Hostname to connect to",
),
cfg.PortOpt(
"mqtt_port",
help="MQTT Port",
),
]
ALL_OPTS = weewx_opts + weewx_mqtt_opts
def register_opts(cfg):
cfg.register_group(weewx_group)
cfg.register_opts(ALL_OPTS, group=weewx_group)
def list_opts():
register_opts(cfg.CONF)
return {
weewx_group.name: ALL_OPTS,
}

View File

@ -6,6 +6,11 @@ weewx_group = cfg.OptGroup(
)
weewx_opts = [
cfg.BoolOpt(
"enabled",
default=False,
help="Enable the plugin?",
),
cfg.FloatOpt(
"latitude",
default=None,

View File

@ -44,7 +44,7 @@ class WeewxMQTTPlugin(plugin.APRSDRegexCommandPluginBase):
def setup(self):
"""Ensure that the plugin has been configured."""
self.enabled = True
self.enabled = CONF.aprsd_weewx_plugin.enabled
if not CONF.aprsd_weewx_plugin.mqtt_host:
LOG.error("aprsd_weewx_plugin.mqtt_host is not set in config!")
self.enabled = False