Skip to content

Parser mode

Rich Bell edited this page Mar 10, 2024 · 3 revisions

Parse MQTT 'message' data

Note, this function was intoduced in MQTTSubscribe version 3.0.

This reads data from a file and attempts to parse it into WeeWX format.

This functionality is useful for people that do not have acces to the live MQTT feed, such as MQTTSubscribe developers.

Environment setup

Set the mode that MQTTSubscribe will be running in

If running as a driver,

RUN_MODE=driver

If running as a service,

RUN_MODE=service

For pip and git installs - activate the environment

source ~/weewx-venv/bin/activate

Set the file locations

For pip installs

WEEWX_ROOT=~/weewx-data
export USER_ROOT=$WEEWX_ROOT/bin/user
CONFIG_FILE=$WEEWX_ROOT/weewx.conf
WEECTL=weectl

For package installs

WEEWX_ROOT=/etc/weewx/
export BIN_ROOT=/usr/share/weewx/
export USER_ROOT=$WEEWX_ROOT/bin/user
CONFIG_FILE=$WEEWX_ROOT/weewx.conf
WEECTL=weectl

For git 'installs'

WEEWX_REPO=~/weewx
WEEWX_ROOT=~/weewx-data
export BIN_ROOT=$WEEWX_REPO/src
export USER_ROOT=$WEEWX_ROOT/bin/user
CONFIG_FILE=$WEEWX_ROOT/weewx.conf
WEECTL=$WEEWX_REPO/bin/weectl

Invocation

python3 $USER_ROOT/MQTTSubscribe.py parse $RUN_MODE --help

Options

--conf CONF

The WeeWX configuration file. Typically weewx.conf.

--console

Log to console in addition to syslog.

--logging-file LOGGING_FILE

Log to specified file.

--logging-level

Specify the level of logging. Valid values are, DEBUG, INFO, TRACE.

--message-file

The file containing the MQTT message.

--top-level

Use the complete input configuration as the MQTTSubscribeDriver/MQTTSubscribeService configuration section.

-- topic

The topic to 'publish' the '--message-file' message.

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

Date/Time Processing Options

Experimental Options

Configurator Mode

    Environment setup
    Invocation
    Options

Simulator Mode

    Environment setup
    Invocation
    driver simulation options
    service simulation options

Parser Mode

    Environment setup
    Invocation
    Options

Example individual Configuration

Example json Configuration

    Simple json message
    'Nested' json message
    json message with array

Example keyword Configuration

Example Configuration with multiple types

Example unit and unit group customization

FAQ

Debugging
Understanding The log

    Initialization
    MQTT Initialization
    MQTTSubscribeDriver secondary thread processing
    MQTTSubscribeDriver primary thread processing
    MQTTSubscribeService secondary thread processing
    MQTTSubscribeService primary thread processing

Supporting Additional message types
Development Environment
Deprecated Documentation

     Configuring pre 1.6.0
     Options Removed In 2.0.0
     Using test_mqtt.py To Check MQTT
     Running As A driver In Standalone Mode
     Running As A service In Standalone Mode

Clone this wiki locally