MQTT Discovery

OK… So I have the new MQTT add-on and I have set up a user in HA for MQTT, reset the addon options to defaults and configured the integration on IP 127.0.0.1, port 1883, and the username and password for the newly created user. I also checked the box to enable MQTT discovery. Finally, as per instructions, I deleted the entire mqtt section on configuration.yaml including the mqtt: key/line.

The username and password are identical to the old user/pass I had configured already in Tasmota on my Sonoffs.

This all worked perfectly. I did delete the old integration and restarted HA before adding the new MQTT integration and configuring as per above.

Next, I deleted the MQTT switches I had configured, however when I restarted, they were not auto-configured or discovered so I added them back and all is well again.

So how can I configure them via discovery?

Currently in config yaml I have this:

switch:
  - platform: mqtt
    name: "Coffee Maker"
    command_topic: "cmnd/sonoff1/power"
    state_topic: "stat/sonoff1/POWER"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: false
  - platform: mqtt
    name: "Toothbrush"
    command_topic: "cmnd/sonoff2/power"
    state_topic: "stat/sonoff2/POWER"
    qos: 1
    payload_on: "ON"
    payload_off: "OFF"
    retain: false

also in Tasmota, my MQTT configuration looks like this:

What changes to config yaml and/or my MQTT configuration do I need to make to use discovery?

The docs are not clear and the MQTT Discovery docs seem to be ‘old’ or just don’t map at all (or I don’t know how to map/adapt) to the new broker etc.

Anyone have any idea or could anyone using discovery share their config yaml and Tasmota settings?

For Tasmota flashed devices you have to issue the following command in the console to enable discovery:

SetOption19 On

More here: https://github.com/arendst/Sonoff-Tasmota/wiki/Home-Assistant#discovery

Note: I haven’t actually tried this yet. It’s on my list of things to do. Let me know how it goes.

4 Likes

is that all Tom?

So I can delete the switches in config and set that option on?

Theoretically, yes.

You also have to have discovery enabled in HA. https://www.home-assistant.io/components/discovery/

I do have discovery working perfectly with my esphomeyal ESP2866 sensors.

Yep I have always used discovery.

Just restarted with no switches in yaml and as soon as I enabled the option the switches popped up. Then I just had to customize them… Did that in GUI as I think it’s ignoring customize for some reason

1 Like

Bloody Hell!!!

Talk about the ‘law of unexpected consequences’

Using MQTT discovery changed the name of my switches… so I had to edit the following:

ui-lovelace.yaml
groups.yaml
customize.yaml
google-assistant.yaml
automations.yaml

Would have been great if I could have just changed the name of the discovered switches. sigh.

I’m kinda expecting I broke something else as well… time will tell. I did resync google assistant no problem though…

1 Like

Could you provide an examole of the before and after entity / name changes?

I might be able to pre-empt this by changing the sonoff settings.

for the screen shoted one above, it was switch.coffee_maker and became switch.sonoff12914

I might be ok then.

My sonnof’s have friendly names that match the device names in HA.

So hopefully, “Lounge Dehumidifier” will become switch.lounge_dehumidifier.

1 Like

could be… I never changed the names in the sonoff in case I wanted to switch them around if I had a failure… maybe that bit me in the ass… just seems everywhere I turn theres somewhere else I need to change the f*@king name.

1 Like

Totally understand. I have four sonoffs in the walls that aren’t going to move so I didn’t mind naming them but I have two others mounted in boxes in the middle of short extension cords. These two I started out with just “sonoff1” and 'sonoff2" in case I moved them. They have since found permanent homes so I did rename them.

1 Like

I have a couple of questions and hoping you guys could help me understand,
I have RPI3B+ with HassOS 1.10, I used the AIO installer to setup it up. Currently on Home Assistant 0.81.6,

I have numerous items coming in from Smartthings MQTT Bridge. I have MQTT configured in my configuration.yaml and then have all the smartthings entities configured in sensor.yaml and binary_sensor.yaml files. To switch to the integration, I would just delete all that and go the thru the “MQTT” Integration?
Do I uninstalled the Mosquitto add-on?
Delete mqtt: completely from the configuration yaml?

Thanks

You need the MQTT addon - it’s still the broker. Also are you using a username and password? I created a Home Assistant user with the same user/password. Then you’d delete the yaml files and delete all mqtt: from config yaml. I am assuming your MQTT devices support discovery? I had to set an option to enable that in Tasmota.

Just keep a copy of everything you do in case you need to wind back the changes.

Yes, currently I am using a username/password in the MQTT configuration with a client_id. I have no idea if my devices support discovery. I have 3 Konnected.IO boards for an existing wired alarm system in my house. A couple of Hue Dimmer remotes to control some zwave switches in a couple of areas in the house. I am assuming that the discovery option would have to be Smartthings related since they are all coming thru that way.

You can still keep your device configs if you don’t want to use discovery. Just delete the main mqtt: entry and any of it’s options.

1 Like

I removed MQTT from my configuration.yaml and removed all devices from binary_sensor.yaml and tried the integration and checked discover. Got a Success! response. Clicked on the MQTT inside the configuration settings page and it says, “No devices configured”

image

yes same here… but it should show any discovered devices in the dev tools… With Tasmota you need to set the discovery option in the console.

I’m having trouble too.

My esp2866 esphomeyaml devices are discovered no problem but I’m not having any luck with Tasmota devices (Sonoff POW R2, Tasmota v 6.2.1).

I commented out my switch and sensor config for this device and set option 19 to on in Tasmota. Restarted HA and nothing was discovered.

All of my MQTT devices were coming from SmartThings MQTT Bridge. I don’t know of any options to set it to discovery.