Troubles with MQTT and Sonoff Switches

Hi everyone.
This is what happen (sorry my english, I’m from Chile): I can’t connect my Sonoff TH16 as a switch through MQTT, I don’t know what is wrong, is the first time I use MQTT and I don’t know if my configuration is secure.

First: I have this

{
“plain”: true,
“plain_websockets”: false,
“ssl”: true,
“ssl_websockets”: false,
“anonymous”: false,
“logins”: [
{
“username”: “User-Name-Same-I-Use-On-Tasmota”
“password”: “User-Password-Same-I-Use-On-Tasmota”
}
],
“customize”: {
“active”: false,
“folder”: “mosquitto”
},
“certfile”: “fullchain.pem”,
“keyfile”: “privkey.pem”
}

Log of MQTT add-on

1532064812: mosquitto version 1.4.15 (build date 2018-03-04 15:35:59+0000) starting
1532064812: Config loaded from /etc/mosquitto.conf.
1532064812: Opening ipv4 listen socket on port 1883.
1532064812: Opening ipv6 listen socket on port 1883.
1532064812: Opening ipv4 listen socket on port 8883.
1532064812: Opening ipv6 listen socket on port 8883.
1532064812: Warning: Mosquitto should not be run as root/administrator.
1532066613: Saving in-memory database to /data/mosquitto.db.
1532068414: Saving in-memory database to /data/mosquitto.db.
1532068452: New connection from 192.168.0.29 on port 1883.
1532068452: New client connected from 192.168.0.29 as DVES_42976F (c1, k15, u'Pabletee12').

In my configuration.yaml I have this:

mqtt:
broker: https://mydomain.duckdns.org
port: 1883
client_id: DVES_I_Dont_If_this_can_be_showed
keepalive: 60
username: User Name same I use in the add-on of MQTT
password: Password same I use in the add-on of MQTT
protocol: 3.1.1

switch:

  • platform: mqtt
    name: “Sonoff”
    state_topic: “cmnd/sonoff/switch1”
    command_topic: “cmnd/sonoff/switch1/set”
    availability_topic: “cmnd/sonoff/switch1/available”
    payload_on: “ON”
    payload_off: “OFF”
    optimistic: false
    qos: 0
    retain: true

My Sonoff config

My Info

The Message in Home screen
Sonoff3

I don’t know what to do, I know this wonderful community helps everyone, please, help :confounded:.

I don’t use Hass.io, but I believe you need to install the MQTT add on, if you haven’t already, from the Hass.io install section. When I tried Hass.io I made the mistake of trying to use my old AIO MQTT config in Hass.io and had a similar issue.

What happens if you set ssl to false ?

“ssl”: false,

Here is my config for my sonoff basic

platform: mqtt
  name: "Sonoff1"
  command_topic: "cmnd/sonoff1/power"
  state_topic: "stat/sonoff1/POWER" # since 5.14 FW option 26 0 will turn off ie POWER where 26 1 turns it on ie POWER1
  #qos: 1
  payload_on: "ON"
  payload_off: "OFF"
  optimistic: false
  retain: true