hi i getting frustrated… i delete the MQTT intergration i remove the binary sensors etc it creates from one of my esp devices… and then it adds _2 _3 etc cuz its re adds devices… i delete the mqtt i delete then all the sensors switchs etc linked to the mqtt and esp device… but it comes back when i re add the mqtt intergration…
example is like
2 programs 1 is touch_screen and other is vehicle1_temp_switchs
well it will add a switch
touch_scree_vehicle1_temp_switchs
as a sensor… but yet none are attached to HA so i trying to purge it from detecting i even have Nodered off just to make sure for automations i have for mqtt not to detect
on top of it cuz ive used the same esp32 device on 2 different esp program,s i wrote. but eventually only use 1 program it links the 2 esphome files the switchs binary sensors etc to 1 sensor in the mqtt… i cant seem to purge things as it keeps detecting mqtt when i dont have any thing coming in i dont have the esp device add to HA its not even plugged in yet it keep adding… how do i purge it… i do the delete… of the mqtt and then it just pops up in the settings/devices i cant purge the old settings wont start fresh
Download MQTT Explorer for your Mac or PC. The topics are still in the MQTT broker with a retain flag set. Connect MQTT Explorer to your broker, then use the delete feature to delete the topics.
ok downloading it… why doesnt home assistant let you just delete it… why do i need another program to fix home assistants mqtt i was looking for a file or the purge enteries to try to delete mqtt… i had even uninstalled MQTT and rebooted and reinstalled and the settings came back…why are the things being retained? i did look in the mqtt settings bottom page it says toggle it to retain but i dont have it toggled to retain… is this a glitch or something?
Because it’s not a HA issue, it’s a MQTT issue. All brokers will work the same and have the same “bug”. Unfortunately that’s how the retain flag in MQTT works.
my internet slow so going to take 40 min to download 79 meg frig
oh so even though the retain toggle switch is off in home assistant at the bottom of the page even though its off mqtt retains the information… so how often do you need to use this program? everytime i change something in node red or esphome for mqtt…
i guess if its a bug… how long this been around as a bug any fix? i know i been struggling for months trying to delete… i just tonight got fed up and wanted it fixed and stupid uninstall didnt even fix it… which you think an uninstall would clear all data
It is not a bug.
It is working as intended and it is the MQTT standard that sets this.
HA retain flag will only affect topics HA posts.
Your other devices that post topics to the MQTT broker will decide what retain flag they want to have set for their topics.
The data is not stored in HA, but in the broker, so you would need to uninstall the broker and purge its data in the process.
what i have done deleted the mqtt interegration and then it pops up then i deleted the entities on the developers page…
but when i re added the mqtt it re added
i also tried delete the mqtt intergration . and then re deleted the entities… and then went to service page. and ran the purge recorder that didnt help
i also uninstalled the mqtt add on rebooted HA and then retinstalled and it came back…
so now i downloading the explorer
as for the retain flag in HA do you mean if HA was sending a topic message like the esp devices… and whats the purpose of this retain? and can i disable it then
and how do you purge the data after u uninstall mqtt broker? i figured uninstall would have it
i googled esphome mqtt… is that retain thing the discovery_retain: and set that to false
and set the retain: to false?
and what benefits are there for retaining the mqtt messages?
The ability to store a value on the broker (retained message) is a legitimate feature with useful applications.
To purge a retained message on the broker, you publish an empty string to its topic. It can be done in Home Assistant via Developer Tools → Actions and using the mqtt.publish action. However you have to know which MQTT topic contains the retained message (in your case, it’s probably one of the MQTT Discovery topics starting with homeassistantesphome).
MQTT Explorer can be used to purge a retained message. It shows you all of the topics published to the broker so that can make it easier to decide which is the topic to purge.
As others have said, this is a feature of MQTT. If a message has the retained flag set then a new client subscribes to the topic, it gets the message immediately without waiting for the next update. Retained messages ensure that critical information is always available to subscribers even if the publisher is offline.
Not surprised. The only way to terminate a retained message is to publish an empty message to the topic without the retained bit set. You can do this in MQTT Explorer.
It depends on which device is setting the retained bit. If the device is still connecting to the MQTT broker, then the message will come back.
The MQTT integration has nothing to do with what is retained by the broker. The MQTT integration makes Home Assistant an MQTT client. It allows it to connect to a broker, subscribe to topics, and publish to topics.
I strongly recommend you consider reading the following tutorial:
I read it over six years ago and it provided me with a good understanding of how MQTT works.
I suggest reading the chapters in order but if you want to jump ahead, here’s the one for Retained Messages.
@123
so in my esphome i not sure how to send a blank and for esphome one of the code is
on_turn_on:
then:
- if:
condition:
api.connected:
then:
- mqtt.publish:
topic: vehicles/vehicle1
payload: switch1
mqtt:
id: my_mqtt
broker: !secret home_mqtt_server ### Set Default MQTT Server IP to Home One
username: !secret mqtt_user
password: !secret mqtt_password
reboot_timeout: 0s
oh so the intergration in device/settings thats connecting to the mqtt broker inside hA so u gotta delete the code there
now i dont understand 100% about the retain @stevemann mentioned
about the criticail information … like what information would it be… cuz for me it comes back and the states are all unavaliable so its not retaining any useful data?
is the retain mqtt message say if a caller id as i have a caller id mqtt to HA
but is it if Joe Blow calls the ID mqtt retains Joe Blow and if the esphome device offline and HA reboots… the mqtt retains does it pop up Joe Blow as the state even when the esphome device is offline and HA rebooted… is that the purpose?
mqtt explorere still downliading… i feel like im back to dial up days
Philips Hue and Nest use MQTT retained flag to remember the last known state of the devices. The automobile industry uses MQTT in their car networks for publishing and retaining CEL codes, MQTT is used in smart energy grids, Medtronics and Phillips uses retwined messages for medical devices that come online every few minutes and update data. Amazon and Walmart use MQTT in their inventory systems.
Without knowing which device on your network is setting the retained bit, no one can guess why.
I just saw that you uploaded the MQTT explorer screen. You need to identify which topic has the retained bit set. I’ve never seen it because none of my many dozens of MQTT topic have the retained bit set. But there is supposed to be a small yellow “R” icon next to the topic name that indicates the retained bit is set. Expand the top level to show all of the topics. For example in your image, homeassistant has 47 topics.
ah ok i had to delete and reboot HA a couple times and re delete as it came back… but for now its gone… so least its not giving me a hastle
i didnt get a chance to look for a R but ill try it again at later time…
and ok so thats that the mqtt retain means basicly last state… always learning something new… i wonder how you can retrieve mqtt retain for my future knowlege… but least i not seeing the annyoing issues at the moment anyways (: