Remove auto discovered MQTT

I have added a MQTT broker on a device on the LAN through, autodiscover on my Hass.io.

The only thing stated in the auto discover set up is the IP of the device.
However, I need to add mor information/parametres of the broker in the configuration.yaml file.

It seems the auto discovered instance overrides the one I state in the configuration.yaml

2018-10-17 19:19:04 WARNING (MainThread) [homeassistant.components.mqtt] Data in your config entry is going to override your configuration.yaml: {'broker': '10.0.0.27', 'discovery': False, 'port': 1883}

Been trying to figure this one out for days:

Is there a way to flush/remove the auto discovered device, so I can set it up manually?

Thanks.

check your known_devices.yaml file to see if it’s listed there.
You may also need to publish an empty message with retain flag to remove the old device if its previous state was published with the retrain flag. (mqtt.fx is great for this)

Thanks!

There is no known_devices.yaml in my config folder. Is it supposed to be in the same folder as

configuration.yaml

?

yes, if it’s not there you can have a look at the files in the .storage folder, namely core.entity_registry
Make sure you back it up first
Then don’t forget to publish an empty message with retain flag to remove the old device

1 Like

Thanks a bunch

There is no mentione of mqtt in the core.entity_registry file, however, in the .storage folder there is a file called core.config_entries .`It contains the following code:

{
    "data": {
        "entries": [
            {
                "connection_class": "local_push",
                "data": {
                    "broker": "192.168.1.102",
                    "discovery": true,
                    "port": 1883
                },
                "domain": "mqtt",
                "entry_id": "5eaa2a2eac7246978eef0d7dcd5e6908",
                "source": "user",
                "title": "192.168.1.102",
                "version": 1
            }
        ]
    },
    "key": "core.config_entries",
    "version": 1
}

Can I edit this file to include the keepalive value? Also the version of the Mosquitto broker is 1.4.14.

Should this be stated in the last line? Eg, does this look valid?:

{
    "data": {
        "entries": [
            {
                "connection_class": "local_push",
                "data": {
                    "broker": "192.168.1.102",
                    "discovery": true,
                    "keepalive": 30,
                    "port": 1883
                },
                "domain": "mqtt",
                "entry_id": "5eaa2a2eac7246978eef0d7dcd5e6908",
                "source": "user",
                "title": "192.168.1.102",
                "version": 1
            }
        ]
    },
    "key": "core.config_entries",
    "version": 1.4.14
}

I have no idea. If you have a device that’s still in HA because its status was sent with the retain flag you need to publish an empty message on the same topic with the retain flag to remove it from your broker’s records

Is there any work-in-progress for easier removing auto discovered devices from HA? It’s a pain to remove these devices.

Did you turn off discovery on the device? That should remove it.

1 Like

Not yet, but it is a good idea. I try this asap.

I had the same issue.

I was trying to set up garHAge, which allows me to monitor the status of two “covers”. It also allows me to trigger a relay to open / close them. (Garage doors).
I initially configured it with the embedded mqtt broker. It was working with the exception of the trigger. So I could read information from the IOT device, but couldn’t publish anything to it. So I thought it may be a mqtt issue, so I removed the embedded mqtt and set up mosquito.

It got worse, then. It would only read the status sporadically, and I still couldn’t trigger the door.

So I uninstalled mosquito through the add-on interface, restarted, and went back to the embedded mqtt. But now, it seems confused. I was getting read errors in the homeassistant.log, and I was also seeing

Data in your config entry is going to override your configuration.yaml: {'broker': '192.168.1.115', 'discovery': False, 'password': '<redacted>', 'port': 1883, 'username': 'mqttuser'}

I then did some tests on my garHAge interface, and discovered that the relay was an ACTIVE_LOW_RELAY (not a ACTIVE_HIGH_RELAY). So I made an adjustment to the code and flashed the device.

Back to hass.io

Finally, I found an obscure (to me anyway), file located in .storage with the name core.config_entries. In that file was a section referencing mqtt. First, I backed up the file, then removed this section.

Next, I removed the mqtt: section from my configuration.yaml file and restarted HA. I wanted to have a clean slate.

Next, I added mqtt: back into the configuration.yaml file and restarted again.
From there, I went to configuration->integrations and configured the mqtt component.

I booted up my garHAge device and now everything is working.
Sorry to be so verbose, but I wanted to include as much as I could so others googling could hopefully find a solution.

You should not touch that file and you will find the entries will have returned as well.

@DavidFW1960 I recently had a problem with hassio using wrong mqtt broker (possibly caused by me initially trying to use the internal broker instead of mosquitto). Removing an mqtt related entry from the core.config_entries file solved the problem for me. Do you know if there is another preferred way to fix such an issue? I did indeed see that another entry was added when I used mqtt again, but this time it was referring to the mosquitto broker and worked fine.

It can be tricky… I used MQTT Explorer recently do delete retained stuff in the broker but also turning off discovery on the device, removing the integration and removing the broker then restarting - that should normally fix it. If it doesn’t stopping Home Assistant and very carefully editing that file should be ok as long as you don’t break the JSON format…