Relays from Esp8266 with Tasmota "toggle" on mosquito mqtt connection

Hy everyone, I have just installed Tasmota 13.1.0 on a relay board with the brain being esp8266 and i have configured it to work with wifi and mqtt in Home Assistant so i would be able to control the board inside and outside my home network using Nabu cloud for the moment.

I have experienced an issue that when i restart the board, the relays turn on/off for a moment wich at first i though i might be caused by the way Tasmota handles the gpio pins, but it turns out it happens when the board connects to the mqtt server and received some retained values wich toggles the relays.

After following multiple forums and topics about this subject, i still didn’t managed to solve the issue.
Thins i have changed;

so13 on
wificonfig 5 (wait)
ipaddress1 192.168.1.206

SwitchRetain off
ButtonRetain on followed by 
ButtonRetain off (i didn't get the retained lines with powers for all relays)

PowerOnState 3 (last state)
PowerRetain ON

added
retain-false
in Settings - add-ons - Mosquito - configuration - edit in yaml mode
i don’t know how to access the configuration.yaml for mosquito
where i have seen i had to set something like this

!! EDIT !!
I have just changed the mqtt topic name for my tasmota, it seems that the issues is no longer occurring


It still does that retained thing but the values are OFF now as they should and the relays no longer toggle.

Now what did it change ? I suspect that some cached settings were stored in mqtt wich made the relays turn on instead ? how can that be cleared then, only change i made was the topic name, the rest of mqtt settings are the same

Capture3

Send an empty message to the topic or use Mqtt Explorer (free program) to inspect the retained messages on the broker and delete them.

Many years ago I also used tasmota (as well as espeasy and espurna) for my esp fleet together with mqtt. :put_litter_in_its_place:

Long story short: I never got any of this *wares stable enough so that they were fit for any serious use (thermostat control, pump, etc.). Just when I discovered esphome and got familiar with it my devices became rock solid and made mqtt completly obsolete thank’s to the native api. :rocket:

Best day in my HA journey was definitly when I turned off the mqtt broker - suddenly so much more free time is available as no more debugging (retained messages and other obscure stuff) is necessary. Today I have more then 100 esphome nodes in my park and they just run and run and run :racehorse:

Just to expand on the advice, from the command line, the usual way to remove Retained messages is to send another WITHOUT the retained flag, but MQTT Explorer has a lovely button to delete topics (retained and otherwise) in one…
image

Just used it this morning when updating my brewing MQTT sensor which has been updated with the new Entity Naming Standards.

Hi,
Take a look at the pin table which includes boot state - might explain the hard reset relay switching:

The GPIO closest to your hardware is usually one that toggles on boot!

If this helps, :heart: this post!

Tasmota and MQTT are rock solid here, but then again, a friend ended up chatting with Andy Stanford-Clark (co-inventor of MQTT) about my automation hardware so YMMV!

I also use ESPhome and find the native-API straight into HASS good, but not everything runs ESPhome. MQTT can be a useful choice (e.g. integration with other systems with command-line MQTT clients, and good Python support).

The best bit is we have lots of choices, and they’re open source. :slight_smile:

1 Like

@groza actually ruled already out that boot/strapping pins are responsible in his first post :point_down:

I guess that’s possible, tasmota has a big community so it would be quite weird if they all would have flawky setups running.

In tasmota I were bothered the most back in the days that the configurations were scattered are all over the place - some were found in the web server menu’s - others require quite obscure commands in the terminal and some things need to be edited before compiling manually. :bowing_man: Another bad mileage was that sometimes tasmota updates just broke or reset configurations and it too often was a hit and miss to get two devices to behave reproducible. In comparison esphome has exact one place to configure everything and updates are always working as the settings a “burned in” :fire:

MQTT is indeed often the lowest common denominator and could be a life safer if the access to a device is limited - still it introduces (unnecessary) multiple points of failure for simple HA ↔ DEVICE communication imho. :arrows_counterclockwise: Beside the communication over mqtt brokers is often even unencrypted by default :unlock:

MQTT was actually made for a complete different environment and optimized for low bandwidth networks which is the opposite we have in our homes today! Still - for some reason - mqtt manages that binary sensor payloads are about 10 times in size compared to the native api of esphome. :weight_lifting_man:

As seen in this thread the author probably waisted already quite some time on this issue which might have be a non-issue by sacrificing MQTT :man_shrugging:

I guess when people have a lot’s of spare times and like tinkering going with tasmota can be quite a fun journey. If users prefer a quick “just works” solutions which is easy manageable and updatable I would suggest to opt-in for esphome together with the native api :white_check_mark:

As a rule of thumb: If it runs Tasmota it also runs esphome :wink:

:100:

Must admit to giving up on reading the screenshots and assuming ESP hardware floating GPIO were the root cause of relay chatter based on my own experience.

A Pimoroni Grow board running on a RPi Zero Python script grows decent tomatoes and peppers via MQTT Discovery, all without being ESP-based, so as ever it depends…

ESPhome is particularly good where there’s more local logic (justifying the recompiling overhead). Thankfully, Tasmota fixed the paging issues which might have caused lost settings (about v8?) so works well for standard devices.

Sat comms telemetry is fun to operate (less so during solar storms in the North - I closed tickets as WONTFIX as we didn’t have a space craft!), but thankfully as you suggest, 2Gbps WLAN is so much more comfortable.

It is fair that settling up secure MQTT is painful with certificates on a WAN, and new ESPhome LAN installs just work with encryption (as long as you update with a cable to reformat).

I’ve never had a sniffer on the traffic, but am surprised at MQTT being inefficient compared to ESPhome. This greybeard dev hates serialising JSON / YAML, and found punching paper tape was so much more satisfying! :grin:🧙‍♂:sauropod: