Repository navigation
SummaryWhen the MQTT broker disappears briefly (e.g. broker restart for backup) and the ESP reconnects, Consequence: every subscription registered via the standard Berry API Tasmota's own C-side subscriptions (command topics, group topics, LWT) are re-subscribed correctly across the same reconnect event. Only Berry-side subscriptions are affected. Setup
Minimal reproducer (Berry)import mqtt
# Counter for the mqtt_connected() driver hook
class HookWatcher
var count
def init() self.count = 0 end
def mqtt_connected()
self.count += 1
tasmota.log("WATCHER: mqtt_connected fired #" + str(self.count), 2)
end
end
var w = HookWatcher()
tasmota.add_driver(w)
global.watcher = w
# Subscription via the standard mqtt module
def msg_handler(topic, idx, payload_s, payload_b)
tasmota.log("MSG: " + topic + " = " + str(payload_s), 2)
end
mqtt.subscribe("test/reconnect", msg_handler)
tasmota.log("Setup complete -- subscribed via mqtt.subscribe()", 2)Steps to reproduce
Expected
Observed
Evidence from a running systemCaptured this morning on both ESPs while restarting the broker container, 10-second-poll of counters (ESP A shown -- ESP B identical): Identical pattern on ESP B (different SoC, same firmware). Other Tasmota devices on the same broker -- which only use C-side command/group subscriptions, no Berry -- resumed normally after the broker came back, so the broker side is fine. This pattern also matches what we see daily at 05:00 local time when our Fhem container is restarted by a backup cron: forecast and external-sensor subscriptions silently die until a user-side periodic watchdog re-registers them. Possibly relevant code pathIn
Design intent looks clear: Questions
Current workaround: a custom Berry liveness watchdog that periodically checks message-reception age per topic and calls Thanks for any pointers! |
Replies: 4 comments 5 replies
|
Not sure where you are getting that Anyway, using Mosquitto and As your code with |
|
You have encountered the issue when AI is doing everything. Not understanding what is done and why. Sorry this is a dead end. No one can help to debug AI slop code. |
|
Don't use AI to generate code unless you were already able to do it yourself. In that situation, well-supervised AI can sometimes save time, but you'd have to be able to have fun with spotting the errors it made, and hand-hold it for baby steps, instead of just pulling the slot machine handle again. And don't expect others to debug AI slop code for you. |
|
AI-GENERATED POST (full disclosure) This post was written by Claude (Anthropic), at the request of a Tasmota user === Summary In a custom Tasmota build with USE_BERRY enabled and USE_RULES undefined, In our case this manifested as Berry MQTT subscriptions silently dying after === Reproducer Custom build with: Berry code (excerpt from the stock tasmota.add_rule("Mqtt#Connected", / -> self.mqtt_connect()) Steps:
Quick verification on the running firmware: curl "http:///cm?cmnd=Rule1" If the response is === Why this happens (with file paths from Tasmota current dev as of 2026-05-17) The Berry API What needs USE_RULES is the dispatch path. There are two classes of events: CLASS A: actively broadcast events CLASS B: rules_flag-based events The Class B events I have identified so far (from System#Init, System#Boot, Time#Init, Time#Set, Possibly more. The comment in === Where the existing Tasmota documentation points in the wrong direction
=== Fix Add === Suggested upstream changes (optional, for maintainers if they care)
=== What we did locally We re-enabled USE_RULES in our custom build (commit on our private fork). 20:23:46.834 MQT: connected Berry now re-subscribes on every reconnect. Our defense-in-depth Berry === |
AI-GENERATED POST (full disclosure)
This post was written by Claude (Anthropic), at the request of a Tasmota user
running a custom build. The user reviewed and approved the content before
posting. Posting it under their own name because the trap turned out to be a
clean structural issue with a clear test case, and it might help others who
hit the same custom-build pattern. If the AI origin disqualifies the post for
the maintainers, please consider it withdrawn and feel free to delete.
===
Summary
In a custom Tasmota build with USE_BERRY enabled and USE_RULES undefined,
calls to
tasmota.add_rule(pattern, callback)for certain event patternssilently never fire. The Berry script keeps runni…