MQTT and sonoff tasmota

Hi all. I am having trouble configuring my MQTT.
My method to date for adding my sonoff switches was to use the HACS ESP Home add on. It still works but is a bit messy so I thought I’d change to MQTT. I thgink its very close but I cannot see the devices after setting it all up.
My setup is a single RPI3B with a copy of hassio flashed to the card. Its been running for a couple of years and is on the latest versions of hassio and HACS.
I started by removing any reference to MQTT in my configuration.yaml. I removed my MQTT integration. I removed the Mosquito MQTT addon.
I restarted homeassistant.
I added and started the mosquito addon with defaults and re-started home assistant.
I have an administrative user named kens_mqtt_user
I looked in integratioins and found tyhat MQTT had been automatically added and had discovery enabled.
I have a sonoff basic flashed with the latest tasmota via tasmotizer. It has wifi and mqtt configured including kens_mqtt_user as the username.
When I look at the console for my sonoff device I can see that it connected to mqtt
When I look at the mosquito log I can see the device.

1598233953: New connection from 192.168.1.156 on port 1883.
[INFO] found kens_mqtt_user on Home Assistant
1598233955: New client connected from 192.168.1.156 as DVES (p2, c1, k30, u’kens_mqtt_user’)

But in my configuration, I do not see the switch?
How do I make it appear in my home assistant devices?.

btw, I’ve tried lots of combinations of entries in my configuration.yaml from nothing to the current entry:

‘’’
mqtt:
broker: 192.168.1.<my_address>
username: kens_mqtt_user
password:
‘’’’

(obviously with real values in the <> bracked parts.)

Hopefully someone can tell me the important part that I’ve missed out.

I’m a complete n00b, but did you use ‘setoption19 1’ in your tasmota console?

1 Like

No I didn’t. What is that and how do I set it?

It is the HASS auto discovery. Login to your tasmota device and in the console type ‘SetOption19 1’ or ‘so19 1’.

Thanks, I tried that and it accepted it and displayed the status again.
But nothing in homeassistant.
Am I still supposed to add binary sensor details into my switch.yaml? I thought the auto discovery did that part for me???

I also have TasmoAdmin installed and it sees my sonoff switch OK and allows me to toggle it.
The only part that I’m missing is being able to see it in my Devices. So I cannot add it to the front end.

If I understand correctly the TasmoAdmin will see them because it is using the IP address(s) Just as you would when you login to tasmota on your switch. It is not connecting in that instance via MQTT. So you don’t see any of them under your entities? Also you were sure to set the correct password for your kens_mqtt_user?

Thanks for persevering. Don’t assume that I know what I’m doing, its all very mysterious to me. :slight_smile:But yes, I HAVE checked the password.

In home assistant when I look at the MQTT log file, it shows the switch connecting to MQTT.
1598237487: New connection from 192.168.1.111 on port 1883.
1598237487: New client connected from 192.168.1.111 as auto-C0DF1436-44D3-A648-8FE1-B0FE74EAC6DB (p2, c1, k60, u’kens_mqtt_user’).

In the sonoff config, I have set GPIO14 Sensor to be Switch1(9)
The other gpio settings are set to None(0)

In the TasmoAdmin there are lots of config options that I can see but don’t know what they mean. One is SetOption4 - MQTT Response State. It is not set? Should it be?

I THINK that maybe I should have an entry in my configuratrion.yaml?
Something like this:

switch:
  platform: mqtt
  name: “My_Switch_6”
  command_topic: “cmnd/sonoff2/power”
  state_topic: “stat/sonoff2/POWER”
  qos: 1
  payload_on: “ON”
  payload_off: “OFF”
  retain: true

And I can see in the sonoff config that there is an “Other” settings that includes MQTT.
It has a Device Name and Friendly Name and it has Emulatioin set to “None”
Is that right?

If you are using discovery you shouldn’t have any mqtt switch of config at all for mqtt

Can you tell me whether or not I should have any binary sensor details in my configuration.yaml?
I DO have that for my sonoff RF-0Bridge that I set up via MQTT a long time back.
I am probably wrong in my assumption that tasmoltizer and tasmoadmin would automatically perform discovery and just add the device to my homeassistant devices.???

My bet is that everyone assumes I know what I’m doing and that I will have done some step or another. What I was really hoping for was a single set of ALL steps to follow to make it work. But I have followed bits from LOTS of different threads a most likely missed one that everyone assumed was too obvious to even mention.

tasmoadmin has nothing to do with anything in Home Assistant

can you show your configuration for the Mosquitto Broker Addon?

Hi David. I only mention tasmoadmin as I believe it accesses via MQTT.

My mosquito has default settings.

logins: []
anonymous: false
customize:
  active: false
  folder: mosquitto
certfile: fullchain.pem
keyfile: privkey.pem
require_certificate: false

The Port settings are also as default.
tcp - 1883, 1884, 8883, 8884 all enabled

I didn’t change anything in the MQTT Integration other than enabling discovery.

What .bin did you flash to your sonoff ? Tasmota.bin or tasmota-lite.bin ?

so the login username and password… is that a Home Assistant user/pass?
Also version? Some versions of Tasmota don’t support MQTT discovery.
Tasmoadmin does not use MQTT to access the Sonoff… IP all the way there.

I do have active true and I set up the ACL file etc…
Perhaps try that…
image
accesscontrollist:

user mqttuser
topic readwrite #
user homeassistant
topic readwrite # 

My HA user is mqttuser. I did need to add the homeassistant user as well
acl.conf

acl_file /share/mosquitto/accesscontrollist

After doing that try removing the integration and restarting before adding back.
Then in the console for the device SetOption 19 On

OH You will have to restart the broker as well…