From 02b712e36d3784f3c4aa1b454d0f594bfdcd635c Mon Sep 17 00:00:00 2001 From: Michael Ingraham <34340210+meingraham@users.noreply.github.com> Date: Thu, 11 Jul 2019 14:55:43 -0400 Subject: [PATCH] Subscribe/Unsubscribe --- Commands.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Commands.md b/Commands.md index b45bc7c8..1c045f06 100644 --- a/Commands.md +++ b/Commands.md @@ -203,10 +203,12 @@ StateText1|`` = set `OFF` state text (10 chars max)` = set `ON` state text (10 chars max) StateText3|`` = set `TOGGLE` state text (10 chars max) StateText4|`` = set `HOLD` state text (10 chars max) -SwitchRetain|`0` = disable use of MQTT retain flag *(default)*
`1` = enable MQTT retain flag on switch press +SwitchRetain|`0` = disable use of MQTT retain flag *(default)*
`1` = enable MQTT retain flag on switch press +Subscribe|List all topics currently subscribed
`, [, ]`
The `` parameter is optional. It is specified to parse a key/value pair from a JSON payload in the MQTT message. In order to parse a value from a multi-level JSON pair, you can use one dot (`.`) syntax to split the key into sections.

Subscribes to an MQTT topic and assigns an [`Event`](#event) name to it. You must compile your own binary with `#define SUPPORT_MQTT_EVENT` in your `user_config_override.h` file.

**Examples:**
  • `Subscribe BkLight, stat/%topic%/POWER`
          `Rule1 ON Event#BkLight=ON DO ENDON`
  • `Subscribe DnTemp, stat/%topic%/SENSOR, DS18B20.Temperature`
          where the MQTT message payload is `{"Time":"2017-02-16T10:13:52", "DS18B20":{"Temperature":20.6}}`
          `Rule1 ON Event#DnTemp>=21 DO ENDON`
  • SwitchTopic|`` = set MQTT switch topic (32 chars max)
    `0` = disable use of MQTT switch topic
    `1` = set MQTT switch topic to device `%topic%`
    `2` = reset MQTT switch topic to firmware default (`MQTT_SWITCH_TOPIC`) _(default = `0`)_
    [Read more](Buttons-and-switches) about this TelePeriod|`0` = disable telemetry messages
    `1` = reset telemetry period to firmware default (`TELE_PERIOD`)
    `10..3600` = set telemetry period in seconds *(default = `300`)* -Topic|`1` = reset MQTT topic to firmware default (`MQTT_TOPIC`) and restart
    `` = set MQTT topic (32 chars max) **and** `ButtonTopic` and restart +Topic|`1` = reset MQTT topic to firmware default (`MQTT_TOPIC`) and restart
    `` = set MQTT topic (32 chars max) **and** `ButtonTopic` and restart +Unsubscribe|Unsubscribe from all topics currently subscribed using the [`Subscribe`](#subscribe) command
    `` = unsubscribe from a specific MQTT topic

    You must compile your own binary with `#define SUPPORT_MQTT_EVENT` in your `user_config_override.h` file. See also | [`SetOption2`](#setoption2) - Add units to status messages
    [`SetOption4`](#setoption4) - Return MQTT response as RESULT or %COMMAND% topic
    [`SetOption10`](#setoption10) - Main topic change behaviour ### [Rules](Rules)