Tutorial code blocks, mqtt, is not "good practice" #28
sfromis
started this conversation in
Tutorials and Code Blocks
Replies: 2 comments 1 reply
-
Ah yes, the danger of looking at code snippets on the discussion forum.
I'll see if I can get it to work without it.
…On Sun, 9 Jul 2023, 9:26 pm sfromis, ***@***.***> wrote:
This line from the code block is not a good idea:
tasmota.add_rule("MQTT#Connected=1", subscribes)
This is not really useful, as mqtt.subscribe can since quite some time be
done before Tasmota has connected to MQTT, as Tasmota will automatically
manage the calls to the broker at the right time.
Even before this enhancement, the example would be problematic, as it
could lead to multiple subscriptions in case of Tasmota reconnecting
without restarting, like in case of unstable Wifi. The difficulties of
doing a robust subscription management was the impetus for this being
integrated in Tasmota Berry, instead of users expected to do the relevant
subscribe/unsubscribe at good points in time.
Minor detail, the example is doing import string without this being
used...
—
Reply to this email directly, view it on GitHub
<#28>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ABTSUVLOBYY6ITLNBTBQ3TLXPKIOPANCNFSM6AAAAAA2DOCCR4>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Beta Was this translation helpful? Give feedback.
0 replies
-
@sfromis This information is very important for users. What are the negative effects of a redundant "import" ? John |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This line from the code block is not a good idea:
tasmota.add_rule("MQTT#Connected=1", subscribes)
This is not really useful, as
mqtt.subscribe
can since quite some time be done before Tasmota has connected to MQTT, as Tasmota will automatically manage the calls to the broker at the right time.Even before this enhancement, the example would be problematic, as it could lead to multiple subscriptions in case of Tasmota reconnecting without restarting, like in case of unstable Wifi. The difficulties of doing a robust subscription management was the impetus for this being integrated in Tasmota Berry, instead of users expected to do the relevant subscribe/unsubscribe at good points in time.
Minor detail, the example is doing
import string
without this being used...Beta Was this translation helpful? Give feedback.
All reactions