### Start mqttwarn Application Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/usage/index.rst These commands initiate the mqttwarn application. The first command starts mqttwarn using its default configuration file path. The second command allows specifying an alternative path for the configuration file using the 'MQTTWARNINI' environment variable, providing flexibility for different deployment scenarios. ```Shell mqttwarn ``` ```Shell MQTTWARNINI=/path/to/mqttwarn.ini mqttwarn ``` -------------------------------- ### Acquire mqttwarn Configuration and Start Service Source: https://github.com/mqtt-tools/mqttwarn/blob/main/examples/mediaplayer/readme.md These commands first download the `mqttwarn-mplayer.ini` configuration file from the mqttwarn GitHub repository, then start the `mqttwarn` service using the downloaded configuration. This setup enables `mqttwarn` to process MQTT messages and trigger actions based on the configuration. ```shell wget https://github.com/mqtt-tools/mqttwarn/raw/main/examples/mediaplayer/mqttwarn-mplayer.ini mqttwarn --config-file=mqttwarn-mplayer.ini ``` -------------------------------- ### Launch external mqttwarn-contrib cloudflare_zone plugin Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/usage/standalone.md This example demonstrates how to install and then launch an external plugin from the `mqttwarn-contrib` package, specifically `cloudflare_zone`. It first shows the `pip install` command for dependency management, then the `mqttwarn` command with `--plugin` pointing to the external module, and `--config` for authentication details, showcasing extensibility. ```shell pip install mqttwarn-contrib mqttwarn --plugin=mqttwarn_contrib.services.cloudflare_zone --config='{"auth-email": "foo", "auth-key": "bar"}' --options='{"addrs": ["0815", "www.example.org", ""], "message": "192.168.0.1"}' ``` -------------------------------- ### Install mqttwarn service plugin dependencies via pkg on FreeBSD Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/usage/freebsd.md These commands demonstrate how to install additional service plugin dependencies for mqttwarn on FreeBSD using the `pkg` utility. Examples include `py-pyserial` for serial communication and `py-slixmpp` for XMPP, which are acquired from the FreeBSD ports tree. ```bash pkg install comms/py-pyserial ``` ```bash pkg install net-im/py-slixmpp ``` -------------------------------- ### Manually Setup Python Virtual Environment for mqttwarn Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/workbench/sandbox.rst Instructions for manually creating and activating a Python virtual environment on both Linux and Windows. This is an alternative to using 'make test' for setting up the development sandbox, followed by installing mqttwarn in editable mode. ```Shell # On Linux python3 -m venv .venv source .venv/bin/activate ``` ```Shell # On Windows python -m venv .venv .venv\Scripts\activate ``` ```Shell pip install --editable=.[test] --upgrade ``` -------------------------------- ### Install mqttwarn core application on FreeBSD Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/usage/freebsd.md This command installs the main `py-mqttwarn` package from the FreeBSD ports tree using the `pkg` utility, providing the core mqttwarn application. ```bash pkg install sysutils/py-mqttwarn ``` -------------------------------- ### Install mqttwarn with specific service plugin support via pip Source: https://github.com/mqtt-tools/mqttwarn/blob/main/README.rst These commands demonstrate how to install mqttwarn along with support for specific notification service plugins. You can include single or multiple plugins by listing them within the square brackets. ```Bash pip install --upgrade 'mqttwarn[xmpp]' ``` ```Bash pip install --upgrade 'mqttwarn[apprise,asterisk,nsca,desktopnotify,tootpaste,xmpp]' ``` -------------------------------- ### Acquire Configuration and Start MQTTwarn Source: https://github.com/mqtt-tools/mqttwarn/blob/main/examples/zabbix-iot/readme.md These commands download the necessary configuration files for mqttwarn from a GitHub repository and then start the mqttwarn application using the downloaded INI configuration. This prepares mqttwarn to process MQTT messages according to the defined rules. ```shell wget https://github.com/mqtt-tools/mqttwarn/raw/main/examples/zabbix-iot/mqttwarn-zabbix-iot.ini wget https://github.com/mqtt-tools/mqttwarn/raw/main/examples/zabbix-iot/mqttwarn-zabbix-iot.py mqttwarn --config-file=mqttwarn-zabbix-iot.ini ``` -------------------------------- ### Clone mqttwarn Repository and Navigate to Examples Source: https://github.com/mqtt-tools/mqttwarn/blob/main/examples/frigate/README.rst Instructions to acquire the `mqttwarn` source code from GitHub and change the current directory to the Frigate example folder. This is a prerequisite step for setting up and running the Frigate-ntfy integration. ```bash git clone https://github.com/mqtt-tools/mqttwarn cd mqttwarn/examples/frigate ``` -------------------------------- ### Setup Mosquitto MQTT Broker with Docker Source: https://github.com/mqtt-tools/mqttwarn/blob/main/examples/owntracks-ntfy/readme.md This command starts a Mosquitto MQTT broker in a Docker container. It maps port 1883 to the host and uses a pre-configured non-authenticated setup, making it suitable for local development and testing. ```shell docker run --name=mosquitto -it --rm --publish=1883:1883 eclipse-mosquitto:2.0 mosquitto -c /mosquitto-no-auth.conf ``` -------------------------------- ### Install mqttwarn using pip Source: https://github.com/mqtt-tools/mqttwarn/blob/main/README.rst This command installs or upgrades the core mqttwarn package using pip, the Python package installer. It ensures you have the latest stable version of the application. ```Bash pip install --upgrade mqttwarn ``` -------------------------------- ### Download mqttwarn Configuration and Start Application Source: https://github.com/mqtt-tools/mqttwarn/blob/main/examples/owntracks-ntfy/readme.md These commands download the required `mqttwarn` configuration file and a Python script containing user-defined functions from a GitHub repository. After downloading, `mqttwarn` is started using the specified configuration file. ```shell wget https://github.com/mqtt-tools/mqttwarn/raw/main/examples/owntracks-ntfy/mqttwarn-owntracks.ini wget https://github.com/mqtt-tools/mqttwarn/raw/main/examples/owntracks-ntfy/mqttwarn-owntracks.py mqttwarn --config-file=mqttwarn-owntracks.ini ``` -------------------------------- ### Generate mqttwarn Configuration Blueprint Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/usage/index.rst This command creates a default configuration file blueprint for mqttwarn. The generated file, typically named 'mqttwarn.ini', serves as a starting point for customizing the application's behavior and settings. ```Shell mqttwarn make-config ``` -------------------------------- ### Install mqttwarn service plugin dependencies via pip Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/usage/freebsd.md This command shows how to install mqttwarn service plugin dependencies directly from the Python Package Index (PyPI) using `pip`. This method serves as an alternative if specific packages are not available in the FreeBSD ports tree. ```bash pip install pyserial slixmpp ``` -------------------------------- ### Install and Upgrade mqttwarn with pip Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/usage/pip.md This section provides commands for installing and upgrading the `mqttwarn` package using pip. It includes options to perform a basic installation, add support for a single service plugin, or integrate multiple service plugins simultaneously. It is recommended to execute these commands within a Python virtual environment. ```bash pip install --upgrade mqttwarn ``` ```bash pip install --upgrade 'mqttwarn[xmpp]' ``` ```bash pip install --upgrade 'mqttwarn[apprise,asterisk,nsca,desktopnotify,tootpaste,xmpp]' ``` -------------------------------- ### Clone and Test mqttwarn Repository Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/workbench/sandbox.rst Instructions to clone the mqttwarn repository from GitHub and run the initial software tests to verify the setup. ```Shell git clone https://github.com/mqtt-tools/mqttwarn cd mqttwarn make test ``` -------------------------------- ### Example Log Output from mqttwarn Dynamic Target Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/configure/topic.md This snippet shows the resulting log entry generated by `mqttwarn` after processing the MQTT message from the previous example. It illustrates how the `loglevel` and `message` placeholders were successfully interpolated into the log output, demonstrating the dynamic target functionality. ```text 2016-02-14 18:09:34,822 CRITICAL [log] Something crit happened! Nur Döner macht schöner! ``` -------------------------------- ### Install mqttwarn Development Extras with pip Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/workbench/sandbox.rst Commands to activate the Python virtual environment and install specific or multiple mqttwarn development extras using pip in editable mode. This allows for development on the installed packages. ```Shell source .venv/bin/activate pip install --editable=.[xmpp] ``` ```Shell pip install --editable=.[asterisk,nsca,desktopnotify,tootpaste,xmpp] ``` -------------------------------- ### Full Example: Running MQTTwarn with Linked Broker Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/usage/oci.md This command provides a comprehensive example of running the `mqttwarn` OCI image. It runs interactively, mounts the current directory for configuration, and links to an MQTT broker container named 'mosquitto'. ```shell docker run -it --rm --volume=$PWD:/etc/mqttwarn --link=mosquitto $IMAGE ``` -------------------------------- ### Install MySQL-python Library on Debian Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md Commands to install the necessary `MySQL-python` library and its dependencies on Debian-based Linux systems, required for the mqttwarn MySQL plugin to function. ```bash sudo apt-get install -y python-dev libmysqlclient-dev sudo pip install MySQL-python ``` -------------------------------- ### Example JSON Output from Jinja2 Template Source: https://github.com/mqtt-tools/mqttwarn/wiki/Examples This is an example of the JSON string produced by the Jinja2 template, demonstrating the structure and content of the transformed MQTT payload, including host, timestamp, temperature, and a short message. ```json "host": "arduino/temp", "woohooo": 17, "tst": "2014-04-13T09:25:46.247150Z", "temperature": "22", "short_message": "Heat 22"} ``` -------------------------------- ### Acquire Configuration and Start mqttwarn Source: https://github.com/mqtt-tools/mqttwarn/blob/main/examples/zabbix-iot/README.md These commands download the necessary configuration files for mqttwarn from a GitHub repository and then start the mqttwarn application using the downloaded INI configuration. This prepares mqttwarn to process MQTT messages and forward them to Zabbix. ```shell wget https://github.com/mqtt-tools/mqttwarn/raw/main/examples/zabbix-iot/mqttwarn-zabbix-iot.ini wget https://github.com/mqtt-tools/mqttwarn/raw/main/examples/zabbix-iot/mqttwarn-zabbix-iot.py mqttwarn --config-file=mqttwarn-zabbix-iot.ini ``` -------------------------------- ### Install mqttwarn Tootpaste Service for Mastodon Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md This shell command installs the 'tootpaste' service for mqttwarn, along with its necessary dependencies (Mastodon.py), enabling the ability to post messages to the Mastodon social network. ```shell pip install 'mqttwarn[tootpaste]' ``` -------------------------------- ### mqttwarn Configuration Initialization Commands Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/workbench/backlog.rst This section proposes a unified `mqttwarn init` command for creating initial configuration files and user-defined function (UDF) scripts. It supports creating a minimal setup or using predefined presets like 'hiveeyes' or 'homie' to quickly set up common configurations. ```Shell # Create folder .mqttwarn with minimal configuration (config.ini, udf.py) mqttwarn init ``` ```Shell # Create folder .mqttwarn with configuration from named preset "hiveeyes" (hiveeyes.ini, hiveeyes.py, hiveeyes-alert.j2) mqttwarn init --preset=hiveeyes ``` ```Shell # Create folder .mqttwarn with configuration from named preset "homie" (homie.ini, homie.py) mqttwarn init --preset=homie ``` -------------------------------- ### mqttwarn Plugin Command-Line Entrypoints Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/workbench/backlog.rst These examples demonstrate how various Python scripts are wired as command-line entrypoints for the `mqttwarn` tool, enabling specific functionalities like AMQP subscription, Zabbix publishing, and Zabbix sensor data submission. They show the `--plugin` and `--command` arguments used to integrate external scripts. ```Shell mqttwarn --plugin=amqp --command=subscribe ``` ```Shell mqttwarn --plugin=zabbix --command=publish ``` ```Shell mqttwarn --plugin=zabbix --command=sensor ``` -------------------------------- ### mqttwarn DNS Update Usage Examples Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md These examples show how to publish MQTT messages to trigger DNS updates via mqttwarn and how to verify the updates using `dig`. It demonstrates updating a TXT record for temperature data and an A record for an IP address. ```shell $ mosquitto_pub -t test/temp -m 42' $ dig @127.0.0.2 +noall +answer temperature.foo.aa txt temperature.foo.aa. 300 IN TXT "Current temperature: 42C" $ mosquitto_pub -t test/a -m 172.16.153.44 $ dig @127.0.0.2 +short www.foo.aa 172.16.153.44 ``` -------------------------------- ### Install mqttwarn using pip Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/readme.rst This snippet demonstrates how to install the mqttwarn package using pip, including options for upgrading and adding support for specific or multiple service plugins. It ensures the necessary Python dependencies are met for the core functionality or extended notification capabilities. ```Shell pip install --upgrade mqttwarn ``` ```Shell pip install --upgrade 'mqttwarn[xmpp]' ``` ```Shell pip install --upgrade 'mqttwarn[apprise,asterisk,nsca,desktopnotify,tootpaste,xmpp]' ``` -------------------------------- ### Python mqttwarn Plugin Configuration Suggestion Function Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/workbench/backlog.rst Defines a proposed `suggest_config()` function for mqttwarn plugins. This function is intended to return a string containing a suggested configuration snippet, aiding in the automatic or guided setup of plugins. ```Python def suggest_config(): snippet = """ ... """ return snippet ``` -------------------------------- ### mqttwarn Configuration for Asterisk VOIP Integration Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md Configuration example for `mqttwarn` to integrate with Asterisk via its Manager Interface (AMI). This setup allows `mqttwarn` to initiate VOIP conferences and send messages as variables to an extension, enabling voice notifications. ```ini [config:asterisk] host = 'localhost' port = 5038 username = 'mqttwarn' password = '' extension = 2222 context = 'default' targets = { 'user' : ['SIP/avaya/', '0123456789'] } ``` -------------------------------- ### Execute Example Frigate Event Publisher Script Source: https://github.com/mqtt-tools/mqttwarn/blob/main/examples/frigate/README.rst Runs a shell script designed to publish example Frigate events. This script simulates real-world event generation, allowing users to test the end-to-end notification pipeline. ```bash ./publish.sh ``` -------------------------------- ### Start MQTT Broker and ntfy Service with Docker Compose Source: https://github.com/mqtt-tools/mqttwarn/blob/main/examples/frigate/README.rst Command to start the Mosquitto MQTT broker and the ntfy notification service using Docker Compose. This sets up the essential infrastructure components required for the Frigate-mqttwarn-ntfy pipeline. ```bash docker compose up ``` -------------------------------- ### Launch mqttwarn ssh plugin with configuration and options Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/usage/standalone.md This command demonstrates how to launch the `ssh` service plugin of `mqttwarn`, which requires both a configuration and options. The `--config` parameter provides SSH connection details (host, port, user, password), while `--options` specifies the command to execute on the remote host and its payload, showcasing plugins needing extensive setup. ```shell mqttwarn --plugin=ssh --config='{"host": "ssh.example.org", "port": 22, "user": "foo", "password": "bar"}' --options='{"addrs": ["command with substitution %s"], "payload": "{\"args\": \"192.168.0.1\"}"}' ``` -------------------------------- ### Install VSCodium for Development Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/workbench/sandbox.rst Command to install VSCodium, the free and open-source version of VSCode without Microsoft telemetry, using Homebrew on macOS. This is recommended for mqttwarn development. ```Shell brew install --cask vscodium ``` -------------------------------- ### Launch mqttwarn pushover plugin Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/usage/standalone.md This example shows how to invoke the `pushover` service plugin of `mqttwarn` to send a notification. It utilizes the `--options` parameter to specify the notification title, message, recipient user keys/tokens, and priority, illustrating how to use plugins that do not require a separate configuration file. ```shell mqttwarn --plugin=pushover --options='{"title": "About", "message": "Hello world", "addrs": ["userkey", "token"], "priority": 6}' ``` -------------------------------- ### Redispub Plugin Configuration Example Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md This INI configuration block sets up the Redispub plugin to publish messages to a Redis channel. It specifies the Redis server's host and port, along with defining target channels for message distribution. ```ini [config:redispub] host = 'localhost' port = 6379 targets = { 'r1' : [ 'channel-1' ] } ``` -------------------------------- ### Start Mosquitto MQTT Broker with Docker Source: https://github.com/mqtt-tools/mqttwarn/blob/main/examples/mediaplayer/readme.md Command to run a Mosquitto MQTT broker instance using Docker. It maps port 1883 for external access and uses a pre-configured no-authentication configuration file, suitable for local development or testing environments. ```shell docker run --name=mosquitto -it --rm --publish=1883:1883 eclipse-mosquitto:2.0 mosquitto -c /mosquitto-no-auth.conf ``` -------------------------------- ### APNS MQTT Payload Examples Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md Examples of JSON payloads published via MQTT to trigger APNS notifications, demonstrating basic alert messages and custom data inclusion for app-specific handling. ```json {"alert": "Vehicle moved" } ``` ```json {"alert": "Vehicle moved", "custom" : { "tid": "C2" }} ``` -------------------------------- ### mqttwarn Topic Section Configuration for MySQL Plugin Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md Example `ini` configuration for a mqttwarn topic section, linking MQTT topics (`my/#`) to the configured MySQL target (`mysql:m2`), enabling message processing by the MySQL plugin. ```ini [names] topic = my/# targets = mysql:m2 ``` -------------------------------- ### Example Rendered MQTTwarn Output from Jinja2 Template Source: https://github.com/mqtt-tools/mqttwarn/wiki/Templates This snippet shows an example of the final message output generated by MQTTwarn after processing an MQTT payload through the `demo.j2` Jinja2 template. It illustrates how the template variables are populated and formatted into a human-readable message, demonstrating the end result of the templating process. ```text ------------------------------------------------------------ Name.................: JANE JOLIE Number...............: 47 Timestamp............: 19:15 Original payload.....: {"name":"Jane Jolie","number":47, "id":91} ``` -------------------------------- ### Launch mqttwarn log plugin using jo for JSON generation Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/usage/standalone.md This example shows how to use the `jo` program to construct JSON arguments for the `mqttwarn` command. It simplifies the creation of complex JSON strings for the `--options` parameter, avoiding manual escaping and making command-line usage more robust for `mqttwarn` plugin invocation. ```shell mqttwarn --plugin=log --options="$(jo message="Hello world" addrs=$(jo -a crit))" ``` -------------------------------- ### Apprise Parameter Propagation Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md Examples demonstrating how to propagate parameters to Apprise notification plugins, either by including them as URL query parameters in the Apprise URI or by embedding them within a JSON-formatted MQTT message. ```APIDOC Apprise URL Parameter Propagation: json://localhost/?:sound=oceanwave - Parameters are passed as URL query parameters. Apprise JSON MQTT Message Parameter Propagation: {":sound": "oceanwave", "tags": "foo,bar", "click": "https://httpbin.org/headers"} - Parameters are included directly in the JSON payload of the MQTT message. - Note the leading colon for Apprise-specific parameters (e.g., ":sound"). ``` -------------------------------- ### mqttwarn ntfy Service Configuration Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md Configures `mqttwarn` to send notifications via the ntfy service. This includes examples for using the hosted ntfy.sh service or a self-hosted instance, and how to specify additional options using a dictionary. ```ini [config:ntfy] targets = { 'test': 'https://ntfy.sh/testdrive', } ``` ```ini [config:ntfy] targets = { 'test': 'http://username:password@localhost:5555/testdrive', } ``` ```ini [config:ntfy] targets = { 'test': { 'url': 'https://ntfy.sh/testdrive', }, } ``` -------------------------------- ### Run Pytest for Frigate Integration Tests Source: https://github.com/mqtt-tools/mqttwarn/blob/main/examples/frigate/README.rst Commands to execute specific `pytest` tests related to the Frigate integration. This allows for verifying the functionality of the `mqttwarn` setup with Frigate event samples. ```bash pytest --no-cov -k frigate pytest --no-cov test_frigate.py ``` -------------------------------- ### mqttwarn MySQL Plugin Configuration Section Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md Example `ini` configuration for the mqttwarn MySQL plugin, defining database connection parameters (host, port, user, pass, dbname) and target table mappings, including a fallback column. ```ini [config:mysql] host = 'localhost' port = 3306 user = 'jane' pass = 'secret' dbname = 'test' targets = { # tablename #fallbackcolumn ('NOP' to disable) 'm2' : [ 'names', 'full' ] } ``` -------------------------------- ### Pushsafer Plugin Configuration Example Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md This INI configuration block defines settings for the Pushsafer plugin, allowing users to specify private keys, device IDs, notification aesthetics (icon, sound, vibration), URL links, time-to-live, priority, retry mechanisms, and answer options for different notification targets. ```ini [config:pushsafer] ; https://www.pushsafer.com/en/pushapi ; https://www.pushsafer.com/en/pushapi_ext targets = { 'basic': { 'private_key': '3SAz1a2iTYsh19eXIMiO' }, 'nagios': { 'private_key': '3SAz1a2iTYsh19eXIMiO', 'device': '52|65|78', 'icon': 64, 'sound': 2, 'vibration': 1, 'url': 'http://example.org', 'url_title': 'Example Org', 'time_to_live': 60, 'priority': 2, 'retry': 60, 'expire': 600, 'answer': 1, 'answeroptions': 'yes|no|maybe', 'answerforce': 1, 'confirm': 10, }, 'tracking': { 'private_key': '3SAz1a2iTYsh19eXIMiO', 'device': 'gs23', 'icon': 18, }, 'extraphone': { 'private_key': 'aliaskey2', 'time_to_live': 60, 'priority': 2, 'retry': 60, 'expire': 600, 'answer': 0 }, 'warnme': { 'private_key': 'aliaskey3', 'time_to_live': 60, 'priority': 1, 'answer': 1, 'answerforce': 1, 'confirm': 10 }, } ``` -------------------------------- ### Run mqttwarn with Frigate Configuration Source: https://github.com/mqtt-tools/mqttwarn/blob/main/examples/frigate/README.rst Executes the `mqttwarn` application, specifying the `frigate.ini` file as its configuration. This command starts the MQTT message router, enabling it to process Frigate events and forward them to ntfy. ```bash MQTTWARNINI=frigate.ini mqttwarn ``` -------------------------------- ### Configure AMQP Gateway Service for mqttwarn Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md This `ini` configuration block configures the `amqp` service in `mqttwarn`, effectively creating an MQTT to AMQP gateway. It specifies the AMQP broker `uri` and defines `targets` with an exchange name and routing key. The exchange must exist before use. This service requires the `Puka` library (`pip install puka`). ```ini [config:amqp] uri = 'amqp://user:password@localhost:5672/' targets = { 'test01' : [ 'name_of_exchange', 'routing_key' ], } ``` -------------------------------- ### Run Mosquitto MQTT Broker with Docker Source: https://github.com/mqtt-tools/mqttwarn/blob/main/examples/zabbix-iot/readme.md This command starts a Mosquitto MQTT broker instance using Docker. It publishes port 1883 for client connections and uses a no-authentication configuration file, making it suitable for local development and testing. ```shell docker run --name=mosquitto -it --rm --publish=1883:1883 eclipse-mosquitto:2.0 mosquitto -c /mosquitto-no-auth.conf ``` -------------------------------- ### mqttwarn Configuration for Multi-Target Apprise Notifications Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md Configuration example for `mqttwarn` using the `apprise_multi` module to dispatch messages to multiple Apprise plugins with different recipients within a single configuration block. It demonstrates sending to HTTP, Discord, and Email targets, each with its own `baseuri` and specific parameters. ```ini [defaults] launch = apprise-multi [config:apprise-multi] ; Dispatch message to multiple Apprise plugins. module = 'apprise_multi' targets = { 'demo-http' : [ { 'baseuri': 'json://localhost:1234/mqtthook' }, { 'baseuri': 'json://daq.example.org:5555/foobar' } ], 'demo-discord' : [ { 'baseuri': 'discord://4174216298/JHMHI8qBe7bk2ZwO5U711o3dV_js' } ], 'demo-mailto' : [ { 'baseuri': 'mailtos://smtp_username:smtp_password@mail.example.org', 'recipients': ['foo@example.org', 'bar@example.org'], 'sender': 'monitoring@example.org', 'sender_name': 'Example Monitoring', } ], } [apprise-multi-test] topic = apprise/multi/# targets = apprise-multi:demo-http, apprise-multi:demo-discord, apprise-multi:demo-mailto format = Alarm from {device}: {payload} title = Alarm from {device} ``` -------------------------------- ### mqttwarn Status Information Publishing Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/configure/mqttwarn.ini.md This API documentation describes how `mqttwarn` can publish its status information to the MQTT broker, similar to Mosquitto's `$SYS` topic. It details the configuration options `status_publish` and `status_topic`, and provides an example of subscribing to and viewing the published status messages. ```APIDOC Configuration Options: status_publish: Boolean (True/False) - Enables or disables the publishing of mqttwarn status information. - Default: False status_topic: String - The MQTT topic prefix for status messages. - Default: 'mqttwarn/$SYS' Published Status Topics (Examples): mqttwarn/$SYS/version: String - The version of mqttwarn. mqttwarn/$SYS/platform: String - The operating system platform mqttwarn is running on. mqttwarn/$SYS/python/version: String - The Python version used by mqttwarn. Usage Example (mosquitto_sub): mosquitto_sub -t 'mqttwarn/$SYS/#' -v - Subscribes to all mqttwarn system topics and displays messages verbosely. - Example Output: mqttwarn/$SYS/version 0.26.2 mqttwarn/$SYS/platform darwin mqttwarn/$SYS/python/version 3.9.7 Notes: - Messages are published with the `retained` flag. ``` -------------------------------- ### Start Mosquitto MQTT Broker with Docker Source: https://github.com/mqtt-tools/mqttwarn/blob/main/examples/zabbix-iot/README.md This command initiates a Mosquitto MQTT broker instance using Docker. It publishes port 1883 for external access and uses a configuration file that disables authentication, suitable for local development or testing. ```shell docker run --name=mosquitto -it --rm --publish=1883:1883 eclipse-mosquitto:2.0 mosquitto -c /mosquitto-no-auth.conf ``` -------------------------------- ### Run mqttwarn with custom configuration and log files Source: https://github.com/mqtt-tools/mqttwarn/blob/main/README.rst These commands illustrate how to specify a custom configuration file and a custom log file for mqttwarn using environment variables before launching the application. This allows for flexible deployment and debugging. ```Bash # Define configuration file export MQTTWARNINI=/etc/mqttwarn/acme.ini # Define log file export MQTTWARNLOG=/var/log/mqttwarn.log # Run mqttwarn mqttwarn ``` -------------------------------- ### Publishing JSON Payload to MQTT Broker Source: https://github.com/mqtt-tools/mqttwarn/wiki/Transformation Demonstrates how to publish a JSON payload to an MQTT topic using the `mosquitto_pub` command-line tool. This payload serves as an example input for `mqttwarn`'s transformation capabilities, showing the structure of data that `mqttwarn` can process. ```shell mosquitto_pub -t 'osx/json' -m '{"fruit":"banana", "price": 63, "tst" : "1391779336"}' ``` -------------------------------- ### Launch mqttwarn ntfy plugin with remote attachment Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/usage/standalone.md This example demonstrates sending an `ntfy` notification with a remote attachment using `mqttwarn`. The `--options` parameter defines the notification details, while the `--data` parameter specifies the URL of the attachment and an optional filename, showcasing how to include external files in notifications. ```shell mqttwarn --plugin=ntfy --options='{"addrs": {"url": "http://localhost:5555/testdrive"}, "title": "Example notification", "message": "Hello world"}' --data='{"attach": "https://unsplash.com/photos/spdQ1dVuIHw/download?w=320", "filename": "goat.jpg"}' ``` -------------------------------- ### Configure Global Ntfy Attachments in mqttwarn Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md This example shows how to configure ntfy attachment options globally for all configured target addresses within the `[config:ntfy]` section. This applies the `attach` URL and `filename` settings to all notifications sent from this configuration, simplifying setup for multiple targets. ```ini [config:ntfy] targets = {'test': 'https://ntfy.sh/testdrive'} attach = https://unsplash.com/photos/spdQ1dVuIHw/download?w=320 filename = goat.jpg ``` -------------------------------- ### Generate mqttwarn Configuration and UDF Starter Files Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/configure/index.rst These shell commands are used to create initial configuration files for mqttwarn. `mqttwarn make-config` generates `mqttwarn.ini`, and `mqttwarn make-udf` creates `udf.py`, providing blueprints for user customization. ```shell mqttwarn make-config > mqttwarn.ini mqttwarn make-udf > udf.py ``` -------------------------------- ### Configure HTTP Service Integration for MQTTwarn Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md Defines how to configure the MQTTwarn `http` service to send GET or POST requests to an HTTP endpoint. It details the five parameters required for each target, including method, URL, query parameters, authentication, and JSON payload forcing. Parameters can include MQTT message content using `{payload}` or other transformations. ```APIDOC http Service Configuration: Description: Allows invoking GET and POST requests to an HTTP service. Target Parameters (per target): 1. HTTP Method: 'get' or 'post' 2. URL: The target URL, supports transformations. 3. Parameters (dict or None): Key-value pairs for query parameters (GET) or body (POST). Values support transformations (e.g., '{name}', '{_dtiso}'). Special handling for '@' prefix: '@name' takes 'name' directly from transformation data without formatting. 4. Authentication (list of tuples or None): List of (username, password) tuples for basic authentication. 5. Force JSON (boolean or None): If True, forces transformation of parameters (3) to a JSON object and sets 'Content-Type: application/json' header for POST requests. Example INI Configuration: [config:http] timeout = 60 targets = { 'get1' : [ "get", "http://example.org?", { 'q': '{name}', 'isod' : '{_dtiso}', 'xx': 'yy' }, ('username', 'password') ], 'post1' : [ "post", "http://example.net", { 'q': '{name}', 'isod' : '{_dtiso}', 'xx': 'yy' }, None, True ] } ``` -------------------------------- ### Build and View mqttwarn Documentation Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/workbench/sandbox.rst Command to build the mqttwarn project's documentation, which is written in reStructuredText and Markdown, and view it, likely with an auto-reloading server. ```Shell make docs-autobuild ``` -------------------------------- ### Example JSON Output from Jinja2 Temperature Template Source: https://github.com/mqtt-tools/mqttwarn/blob/main/examples/arduino-temperature/readme.md This JSON snippet illustrates the structured output generated by the Jinja2 template after processing an MQTT temperature payload. It includes the original temperature, host information, a timestamp, and additional custom fields, demonstrating the successful enrichment of the raw data into a format suitable for logging or analysis systems. ```JSON {"host": "arduino/temp", "woohooo": 17, "tst": "2014-04-13T09:25:46.247150Z", "temperature": "22", "short_message": "Heat 22"} ``` -------------------------------- ### Launch mqttwarn file plugin Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/usage/standalone.md This command demonstrates launching the `file` service plugin of `mqttwarn` to write a message to a specified file. It uses the `--options` parameter to provide the message content and the target file path, showcasing how to use plugins that do not require a separate configuration file. ```shell mqttwarn --plugin=file --options='{"message": "Hello world\n", "addrs": ["/tmp/mqttwarn.err"]}' ``` -------------------------------- ### Configure MQTTwarn for Docker-linked MQTT Broker Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/usage/oci.md These snippets show how to link an `mqttwarn` container to an MQTT broker container (e.g., Mosquitto) running on the same Docker host. The Docker commands start the broker with a specific name, and the INI snippet configures `mqttwarn` to connect to it using that name, facilitated by the `--link` option. ```shell docker run --name=mosquitto -it --rm eclipse-mosquitto:1.6 docker run --name=mosquitto -it --rm eclipse-mosquitto:2.0 mosquitto -c /mosquitto-no-auth.conf ``` ```ini hostname = 'mosquitto' ``` ```shell --link=mosquitto ``` -------------------------------- ### Example MQTT Topic with Embedded Data Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/configure/transformation.md This example shows an OwnTracks MQTT topic and its associated JSON payload. The topic itself (`owntracks/jane/phone`) contains valuable information (username and device ID) that can be extracted and used in transformations, which is the purpose of the `alldata` option. ```text owntracks/jane/phone {"_type": "location", "lat": "52.4770352", "desc": "Home", "event": "leave"} ``` -------------------------------- ### Run mqttwarn interactively Source: https://github.com/mqtt-tools/mqttwarn/blob/main/README.rst This snippet shows how to launch mqttwarn directly from the command line. It runs the application in an interactive mode, typically using its default configuration and logging settings. ```Bash # Run mqttwarn mqttwarn ``` -------------------------------- ### Chromecast TTS Command Line Examples Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md These shell commands demonstrate how to trigger Chromecast Text-to-Speech via MQTTwarn. Examples include using the '--options' flag with 'mqttwarn' and publishing messages to the 'chromecast/say' topic with simple text or JSON payloads. ```shell mqttwarn --plugin=chromecast --options='{"message": "Hello world", "addrs": ["Living Room"]}' echo 'Hello world' | mosquitto_pub -t 'chromecast/say' -l echo '{"message": "Hello world", "addrs": ["Living Room"]}' | mosquitto_pub -t 'chromecast/say' -l ``` -------------------------------- ### Run mqttwarn as an interactive service Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/readme.rst This code snippet shows how to launch mqttwarn directly from the command line as an interactive service. It also illustrates how to specify custom configuration and log file paths using environment variables before executing the mqttwarn command. ```Shell # Run mqttwarn mqttwarn ``` ```Shell # Define configuration file export MQTTWARNINI=/etc/mqttwarn/acme.ini # Define log file export MQTTWARNLOG=/var/log/mqttwarn.log # Run mqttwarn mqttwarn ``` -------------------------------- ### Launch Multiple mqttwarn Services (INI) Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/configure/service.md Demonstrates how to activate configured services by adding their names to the 'launch' option within the global 'defaults' section of the 'mqttwarn.ini' configuration file. Multiple services can be specified as a comma-separated list. ```ini [defaults] launch = xxx, foo ``` -------------------------------- ### Launch mqttwarn log plugin with direct JSON options Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/usage/standalone.md This command demonstrates how to launch the `log` service plugin of `mqttwarn` directly from the command line. It passes a JSON string via the `--options` parameter to specify the message content and target addresses, allowing for quick testing or custom notification programs without a full MQTT workflow. ```shell mqttwarn --plugin=log --options='{"message": "Hello world", "addrs": ["crit"]}' ``` -------------------------------- ### InfluxDB Data Storage Example with Topic Transformation Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md This example shows an INI configuration for an MQTT topic that transforms the payload into an InfluxDB field and adds custom tags. The accompanying text block demonstrates how the data will be stored in InfluxDB, including the automatically generated 'topic' tag. ```ini [environment/temperature/basement] targets = influxdb:temperature format = room=basement,entity=sensor2 temperature={payload} ``` ```text (tag) (tag) (field) (tag) time entity room temperature topic ---- ------ ---- ----------- ----- {timestamp} sensor2 basement 47.5 environment_temperature_basement ``` -------------------------------- ### Pushover Message Payload Examples Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md These JSON examples illustrate various valid payload structures for sending messages to Pushover. They cover simple text messages, messages with base64 encoded images, messages with images downloaded from a URL, and messages with images from authenticated URLs (digest authentication). ```json { "message": "Message only, with no image" } ``` ```json { "message": "Message with base64 encoded image", "imagebase64": "" } ``` ```json { "message": "Message with image downloaded from URL", "imageurl": "" } ``` ```json { "message": "Message with image downloaded from URL: digest authentication", "imageurl": "", "auth": "digest", "user": "myspecialuser", "password": "myspecialpassword" } ``` -------------------------------- ### Example PostgreSQL Table Output for mqttwarn Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md These examples illustrate the data stored in a PostgreSQL table by mqttwarn, demonstrating how JSON payloads are mapped to columns and how the fallback column handles unmapped data or non-JSON payloads. The first table shows mapping of 'id' and 'name'. The second shows the 'message' fallback column populated when 'number' is not mapped. The third shows the fallback column for a non-JSON message. ```postgres +------+------------+ | id | name | +------+------------+ | 90 | Jane Jolie | +------+------------+ ``` ```postgres +------+------------+-----------------------------------------------------+ | id | name | message | +------+------------+-----------------------------------------------------+ | 90 | Jane Jolie | NULL | | 90 | Jane Jolie | { "name" : "Jane Jolie", "id" : 90, "number" : 17 } | +------+------------+-----------------------------------------------------+ ``` ```postgres +------+------+-------------+--------+ | id | name | message | number | +------+------+-------------+--------+ | NULL | NULL | I love MQTT | NULL | +------+------+-------------+--------+ ``` -------------------------------- ### mqttwarn Message Transformation Example Source: https://github.com/mqtt-tools/mqttwarn/wiki/Replacement This example illustrates the input and output of MQTT messages when the `lookup_data` function is applied via `mqttwarn`'s configuration. An incoming message with JSON payload `{"fruit":"pineapple", "price": 131, "tst" : "1391779336"}` is transformed by `lookup_data` to produce 'Ananas' as the outgoing message on `out/food` and `out/fruit/pineapple`. ```text in/a1 {"fruit":"pineapple", "price": 131, "tst" : "1391779336"} out/food Ananas out/fruit/pineapple Ananas ``` -------------------------------- ### Launch mqttwarn ntfy plugin with local attachment Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/usage/standalone.md This command illustrates how to send an `ntfy` notification with an attachment from the local filesystem using `mqttwarn`. The `--options` parameter includes the notification details and the local file path, demonstrating the capability to attach local files to notifications. ```shell mqttwarn --plugin=ntfy --options='{"addrs": {"url": "http://localhost:5555/testdrive", "file": "goat.jpg"}, "title": "Example notification", "message": "Hello world"}' ``` -------------------------------- ### mqttwarn Configuration for AutoRemote Integration Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md Configuration example for `mqttwarn` to forward messages from specified MQTT topics to AutoRemote clients. It defines a target with API key, password, and other parameters for sending notifications to AutoRemote. ```ini [config:autoremote] targets = { 'conv2' : [ 'ApiKey', 'Password', 'Target', 'Group', 'TTL' ] } [autoremote/user] targets = autoremote:conv2 ``` -------------------------------- ### Publish Frigate Sample Events and Snapshots via MQTT Source: https://github.com/mqtt-tools/mqttwarn/blob/main/examples/frigate/README.rst Demonstrates how to publish sample Frigate event JSON data and a camera snapshot image to an MQTT broker using `mosquitto_pub` and `jq`. This simulates Frigate's behavior for testing the notification pipeline. ```bash cat assets/frigate-event-new-good.json | jq -c | mosquitto_pub -t 'frigate/events' -l mosquitto_pub -f goat.png -t 'frigate/cam-testdrive/goat/snapshot' ``` -------------------------------- ### Example of Parsed Hiveeyes Topic Data Source: https://github.com/mqtt-tools/mqttwarn/wiki/Incorporating-topic-names This JSON object illustrates the structure of the dictionary generated by the `hiveeyes_topic_to_topology` function, showing how MQTT topic segments are mapped to named fields for further processing. ```json { "realm": "hiveeyes", "network": "0ef-917-40b-a4-5b5", "gateway": "8sf83id9", "node": "1", "field": "temp1" } ``` -------------------------------- ### Example mqttwarn Formatted Output (InfluxDB Line Protocol) Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/configure/transformation.md Illustrates the final output generated by `mqttwarn` after applying the `ds18b20_values` transformation and the specified `format` string. This output is in the InfluxDB line protocol format, ready for ingestion. ```text weather,topic=tasmota/temp/ds/1 temperature=19.7 1517525319000 ``` -------------------------------- ### Example Tasmota DS18B20 Sensor JSON Input Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/configure/transformation.md Illustrates the raw JSON status response from a Tasmota-flashed device with a DS18B20 temperature sensor. This shows the typical nested structure where the 'Temperature' value is within a 'DS18B20' object. ```json { "Time": "2018.02.01 21:29:40", "DS18B20": { "Temperature": 19.7 }, "TempUnit": "C" } ``` -------------------------------- ### Configure mqttwarn Zabbix Plugin Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md This INI configuration block sets up the `mqttwarn` Zabbix plugin. It defines the target Zabbix host, the discovery key for low-level discovery, and the Zabbix trapper addresses for sending data. It also shows how to route MQTT topics to the Zabbix plugin. ```ini [config:zabbix] host = "mqttwarn01" # an existing host configured in Zabbix discovery_key = "mqtt.discovery" targets = { # Trapper address port 't1' : [ '172.16.153.110', 10051 ], } [zabbix/clients/+] alldata = ZabbixData() targets = zabbix:t1 [zabbix/item/#] alldata = ZabbixData() targets = zabbix:t1 ``` -------------------------------- ### Basic mqttwarn.ini Configuration for File and Log Output Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/configure/mqttwarn.ini.md This INI configuration sets up `mqttwarn` to connect to an MQTT broker, activate `file` and `log` services, and define targets for messages received on the `test/+` topic. Messages are directed to `/tmp/mqtt.log` and the `info` log. ```ini [defaults] ; MQTT broker address. hostname = 'localhost' port = 1883 ; Names of the service providers to activate. launch = file, log [config:file] append_newline = True targets = { 'mylog': ['/tmp/mqtt.log'] } [config:log] targets = { 'info': [ 'info' ] } [test/+] targets = file:mylog, log:info ``` -------------------------------- ### Manually Publish Frigate Snapshot Image and Open Locally Source: https://github.com/mqtt-tools/mqttwarn/blob/main/examples/frigate/README.rst Demonstrates downloading a sample image, publishing it as a Frigate snapshot to MQTT, and then opening the locally saved image for verification. This simulates the process of Frigate publishing camera snapshots. ```bash wget -O goat.png https://user-images.githubusercontent.com/453543/231550862-5a64ac7c-bdfa-4509-86b8-b1a770899647.png mosquitto_pub -f goat.png -t 'frigate/cam-testdrive/goat/snapshot' open /tmp/mqttwarn-frigate-cam-testdrive-goat.png ``` -------------------------------- ### Example MQTT Message Payload for MySQL Plugin Source: https://github.com/mqtt-tools/mqttwarn/blob/main/docs/notifier-catalog.md A sample JSON payload representing an MQTT message that the mqttwarn MySQL plugin processes. Fields like `name` and `id` are used to populate SQL table columns with the same names. ```json { "name" : "Jane Jolie", "id" : 90, "number" : 17 } ```