-
Notifications
You must be signed in to change notification settings - Fork 13
Home
A basic understanding of WeeWX and MQTT is required.
A MQTT broker publishing the desired data to one or more topics.
First up is to ensure that you can subscribe to the MQTT topics independent of WeeWX and obtain a basic understanding of the data being published.
-
Determine the information is required to subscribe to the MQTT topic(s). Some of the questions to answer are:
- What is the broker/server name?
- What is the port to connect to?
- Is a username/password required?
- What topics is the data being published to?
- etc.
-
Test that you can subscribe to the MQTT topic(s). A couple of options are:
-
The advantage of using mosquitto_sub, it is a widely used utility and therefore a lot of information can be found on the web.
-
The advantage of using MQTTSubscribe Simulator is that it can be used to also test the MQTTSubscribe section of the WeeWX configuration.
This does require MQTTSubscribe to be installed and configured.
-
-
Determine the MQTT message 'type'.
Currently three message 'types' are supported.
-
'individual' - Each field is its own topic and the MQTT message is the value. For example,
The value
1
is published to a topic oftopic/id
and the value26.7
is published to a topic oftopic/temp1
. -
'json' - The MQTT message is json. The json field/values in the message map to field/values in WeeWx. An example message is,
{ "id": 1, "temp1": “26.7“ }
-
'keyword' - The MQTT message is delimited data of keywords and values. The json field/values in the message map to field/values in WeeWx. An example message is,
id=1,temp1=26.7
-
Next up is to determine the necessary information to configure MQTTSubscribe
-
Determine if MQTTSubscribe should be run as a driver or service.
If you have an existing WeeWX installation running and you want to add/augment with it data from MQTT, run MQTTSubscribe as a service. If this will be a new WeeWX installation where the data is being received via MQTT, run MQTTSubscribe as a driver.
-
Determine incoming 'unit system'.
WeeWX has 3 unit systems. MQTTSubscribe must be configured to use one. The default is
US
- US - U.S. Customary
- METRICWX - Metric, with rain related measurements in mm and speeds in m/s
- METRIC - Metric, with rain related measurements in cm and speeds in km/hr
-
Determine what data transformation/conversion needs to be done on the incoming data.
MQTTTSubscribe supports many types of transformations/conversions of the incoming data.
- Ignore incoming data.
- Renaming the incoming name of the field/observation.
- By default incoming data is converted to type float. MQTTSubscribe supports conversion to int and str types.
- If all of the incoming data does not belong to the same WeeWX unit system, each field can specify its units.
- WeeWX expects some data (for example, rain) to be an increment from previous 'readings. If the MQTT data is a running total, MQTTSubscribe can 'convert' into an increment before passing it to WeeWx.
- And any other required transformations/conversions...
Installing MQTTSubscribe put placeholder sections for both MQTTSubscribeDriver and MQTTSubscribeService. Until additional configuration updates are made, neither of these will run when WeeWX is restarted. This allows one to install MQTTSubscribe and not 'break' an existing WeeWX installation. This allows the running MQTTSubscribe in simulation mode to debug prior to running it under WeeWX.
To install version 3.x with WeeWX 5.x see, Installing and updating version 3.x with WeeWX 5.x.
To install version 3.x with WeeWX 4.x see, Installing and updating version 3.x with WeeWX 4.x.
To install version 2.x and prior see, Installing and Updating Version 2.X and Earlier.
It is highly recommended that these steps are used to configure MQTTSubscribe. Following these steps configures MQTTSubscribe and tests the configuration without impacting an existing WeeWX installation.
If running as a driver follow [these instructions]($WEECTL station reconfigure --driver=user.MQTTSubscribe --no-prompt)
to set the driver to MQTTSubscribe
.
If running as a service, follow these to enable it.
Then update WeeWX's configuration via these instructions.
See, debugging.
Getting Help
Feel free to open an issue, start a discussion in github, or post on WeeWX google group. When doing so, see Help! Posting to weewx user for information on capturing the log.
Getting Started
Prerequisites
Required MQTT information
Required WeeWX information
Installing MQTTSubscribe
Configuring MQTTSubscribe
Running MQTTSubscribe with WeeWX
Debugging
Common Options
Main section
The [[topics]]
section
The [[[message]]]
section
The [[[topic-name]]]
section
The [[[[field-name]]]]
section
Additional Options
Main section
The [[tls]]
section
The [[topics]]
section
The [[[topic-name]]]
section
The [[[[field-name]]]]
section
Example individual Configuration
Example Configuration with multiple types