mirror of
https://github.com/hemna/aprsd-weewx-plugin.git
synced 2026-05-28 02:47:08 -04:00
Added enabled config option for the plugin.
This commit is contained in:
parent
93095879b9
commit
fa012069c1
@ -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)
|
||||
|
||||
58
aprsd_weewx_plugin/conf/main.py
Normal file
58
aprsd_weewx_plugin/conf/main.py
Normal 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,
|
||||
}
|
||||
@ -6,6 +6,11 @@ weewx_group = cfg.OptGroup(
|
||||
)
|
||||
|
||||
weewx_opts = [
|
||||
cfg.BoolOpt(
|
||||
"enabled",
|
||||
default=False,
|
||||
help="Enable the plugin?",
|
||||
),
|
||||
cfg.FloatOpt(
|
||||
"latitude",
|
||||
default=None,
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user