From 76af0e5e3cee03793b64405baedbe40841080b41 Mon Sep 17 00:00:00 2001
From: sfromis <47082390+sfromis@users.noreply.github.com>
Date: Sun, 10 Sep 2023 18:16:31 +0200
Subject: [PATCH] Update Berry.md
mqtt.subscribe without active MQTT connection
---
docs/Berry.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/docs/Berry.md b/docs/Berry.md
index b0ec4b6226..e37908341d 100644
--- a/docs/Berry.md
+++ b/docs/Berry.md
@@ -581,6 +581,7 @@ Tasmota Function|Parameters and details
:---|:---
mqtt.publish|`(topic:string, payload:string[, retain:bool, start:int, len:int]) -> nil`
Equivalent of `publish` command, publishes a MQTT message on `topic` with `payload`. Optional `retain` parameter.
`payload` can be a string or a bytes() binary array
`start` and `len` allow to specify a sub-part of the string or bytes buffer, useful when sending only a portion of a larger buffer.
mqtt.subscribe|`mqtt.subscribe(topic:string [, function:closure]) -> nil`
Subscribes to a `topic` (exact match or pattern). Contrary to Tasmota's `Subscribe` command, the topic is sent as-is and not appended with `/#`. You need to add wildcards yourself. Driver method `mqtt_data` is called for each matching payload.
If a function/closure is added, the function is called whenever and only if an incoming messages matches the pattern for this function. The function should return `true` if message was processed, `false` if not which will let the message flow to Tasmota eventually as a command.
+You can call mqtt.subscribe even without MQTT connection, and Tasmota will manage subscriptions upon connection, also when reconnecting after an outage. This allows code in `autoexec.be` do make a subscription, which will then have effect after connection has been established.
mqtt.unsubscribe|`(topic:string) -> nil`
Unubscribe to a `topic` (exact match).
mqtt.connected|`mqtt.connected() -> bool`
Returns `true` if Tasmota is connected to the MQTT broker