From 00b2e9bb80e7fcd310fa0b0a719726665d2fcbe2 Mon Sep 17 00:00:00 2001 From: Tomasz Kramkowski Date: Fri, 27 Jun 2025 19:57:00 +0100 Subject: Pass packet metadata as arguments DUP, QoS, RETAIN and the packet identifier --- README.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 8bf7818..24c635f 100644 --- a/README.md +++ b/README.md @@ -55,14 +55,19 @@ The routes follow the following format: On startup, `mqttr` will read the config file and subscribe to all the topics. When a message is received, `mqttr` will match the message topic against the routes and execute every program which is part of a matching route. Each program -will have the message topic appended as an additional argument and will receive -the message on stdin. +will have the message topic as well as the DUP, QoS, RETAIN and Packet +Identifier (when applicable) appended as an additional arguments (in that order) +and will receive the message on stdin. An example program is this script: ```bash #!/usr/bin/env bash topic=$1 +dup=$2 +qos=$3 +retain=$4 +((qos == 1 || qos == 2)) && pkid=$5 action=$(jq --raw-output .action) [[ $action == "toggle" ]] || exit 0 mosquitto_pub --topic "zigbee2mqtt/light/set" --message '{"state":"TOGGLE"}' @@ -75,7 +80,6 @@ it being ran every time a new MQTT message is published to this topic. * Configurable timeouts (eventually configurable per process) * Configurable QoS for each subscription (default is 0 (at most once)) -* Pass message metadata via the environment (QoS, retain, dup) * Configurable logging * Ability to configure programs with non-UTF-8 in paths * Maybe config reloading on SIGHUP -- cgit v1.2.3-70-g09d2