New User help with MQTT

I have just setup my rpi3 with Home Assistant having being running OpenHab for the last few years. Most of my devices are sonoff devices flashed with Tasmota

I have installed HA, setup an additional user called mqtt and changed my devices to use the new IP address and username and password… installed the Mosquitto broker and left the configuration as is (as im using a HA user).

the Mosquitto broker logs show the user connecting but no devices show up in intergrations. Ive read forum posts (most seem out of date) and watched a few youtube videos but im no further forward. any help would massively appreciated.

Broker Config:

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

Broker Log:

[12:25:05] INFO: Setup mosquitto configuration
[12:25:05] WARNING: SSL not enabled - No valid certs found!
[12:25:05] INFO: No local user available
[12:25:06] INFO: Initialize Add-on services
[12:25:06] INFO: Initialize Home Assistant discovery
[12:25:06] INFO: Start Mosquitto daemon
1585139106: mosquitto version 1.6.3 starting
1585139106: Config loaded from /etc/mosquitto.conf. 1585139106: Loading plugin: /usr/share/mosquitto/
1585139106: |-- *** auth-plug: startup
1585139106: ├── Username/password checking enabled.
1585139106: ├── TLS-PSK checking enabled.
1585139106: └── Extended authentication not enabled. 1585139106: Opening ipv4 listen socket on port 1883.
1585139106: Opening ipv6 listen socket on port 1883. 1585139106: Opening websockets listen socket on port 1884.
1585139106: Warning: Mosquitto should not be run as root/administrator. 1585139108: New connection from on port 1883.
1585139109: Socket error on client <unknown>, disconnecting.
1585139109: New connection from on port 1883. [INFO] found homeassistant on local database
1585139109: New client connected from as auto-A0C6F36D-B0F9-1891-2B37-364655D0D737 (p2, c1, k60, u'homeassistant').
1585139111: New connection from on port 1883. [INFO] found mqtt on Home Assistant
1585139113: New client connected from as SonoffBasic01 (p2, c1, k10, u'mqtt').
1585139113: New connection from on port 1883.
1585139113: New client connected from as rgbswitch02 (p2, c1, k10, u'mqtt').

developer tools >> mqtt >> Listen to a topic

Set the “listen to” to “#”

This will allow you to see all messages and confirm client response and server send are same topic and working

Thank you so much, I didnt even realise there was settings in dev tools!

as soon as I did this I got

Message 1 received on sonoff/SonoffBasic01/LWT at 1:46 PM:
QoS: 0 - Retain: true

Message 0 received on rgbswitch/rgbswitch02/LWT at 1:46 PM:
QoS: 0 - Retain: true

however I still got no devices within intergrations

Are those your devices?
Not sure Integration you use but be sure Integration s topic match those above. In my experience if no message received device may not show but I can’t remember exactly

yeah they are two different devices (ive turned the others off while I get these working), ive not changed the config of the devices since using openhab other than the username and password for mqtt

im just using the Mosquitto broker intergation, its difficult to say much more than this as its all brand new to me

Thanks again

I think you only added the MQTT integration?
This will only establish the communication between HA and mqtt server.

You must now add the devices using switch, sensor or other integrations separately like below. If you done that maybe post what you have for the (2) switchesswitch:

  - 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

actually best you look at the docs. below if for binary_sensor like motion or on/off sensor

ahhhh this makes much more sense!

thats exactly what I was looking for, where do I add this?

configuration.yaml . These items cannot be added by UI at this time

Thanks, you’ve been a massive help :slight_smile:

OK I now have devices working from the main overview page, I can switch devices on and off and the states are also working (if i switch the device on/off from elsewhere)

all my switches are now showing as entities but not as devices so I am unable to use them in the automation section, I cant find anyway to add them to devices either.

You can use entities in automations.