Skip to content

Simulator mode

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

Simulating running WeeWX

Note, this function was intoduced in MQTTSubscribe version 3.0.

This runs MQTTSubscribe in an environment that is very close to running MQTTSubscribe with WeeWX. This serves the following purposes.

  1. The MQTTSubscribe configuration can be tested prior to updating the configuration (weewx.conf) being used by WeeWX.
  2. The MQTTSubscribe configuration can be debugged without having to update the configuration (weewx.conf) being used by WeeWX.

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 simulate $RUN_MODE --help

driver simulation options

--archive-delay ARCHIVE_DELAY

The simulated archive delay in seconds.

--archive-interval ARCHIVE_INTERVAL

The simulated archive interval in seconds.

--binding {archive,loop}

The type of binding.

--conf CONF

The WeeWX configuration file. Typicall 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.

--records RECORD_COUNT

The number of archive records to create.

service simulation options

--binding {archive,loop}

The type of binding.

--conf CONF

The WeeWX configuration file. Typically weewx.conf.

--console

Log to console in addition to syslog.

--frequency FREQUENCY

The frequency that the simulated loop packets/archive records arrive.

--logging-file LOGGING_FILE

Log to specified file.

--logging-level

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

--records RECORD_COUNT

The number of archive records to create.

--units {US,METRIC,METRICWX}

The default units if not in MQTT payload.

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