Sonoff Basic MQTT Not Available

Hello,

I’ve tried everything in the last couple of hours but my Sonoff Basic is always in the state “Not Available” inside Home Assistant. I tried both Mosquito and the embedded MQTT Broker.

Console on the Sonoff looks fine. It also connect correctly to the broker:
22:49:18 MQT: tele/badspiegel/STATE = {"Time":"2018-11-10T22:49:18","Uptime":"0T00:00:15","Vcc":3.149,"POWER":"OFF","Wifi": {"AP":1,"SSId":"mySSID","RSSI":62,"APMac":"XYZ"}}

configuration.yaml:
    mqtt:
        password: mypw

switch:
  - platform: mqtt
    name: "Spiegel Licht"
    state_topic: "stat/badspiegel/POWER"
    command_topic: "cmnd/badspiegel/POWER"
    availability_topic: "tele/badspiegel/LWT"
    qos: 0
    payload_on: "ON"
    payload_off: "OFF"
    payload_available: "Online"
    payload_not_available: "Offline"
    retain: true

I really don’t know what’s wrong there. Sonoff Firmware is 5.14

What version of mqtt u using

You mean on the Sonoff? Or on HA?

Where can I see this on the Sonoff? On HA at the moment I’m using the embedded Broker on version 0.81.6

V3+ of the broker won’t accept a user called homeassistant any more

There was a recent problem with a hassio addon, but I don’t think that has affected the embedded broker.

I think you need to connect another client to the broker to display the messages being sent by your sonoff to check they match your HA configuration. mosquitto_sub or MQTT.FX should do the job

For mosquitto_sub, the command is

$ mosquitto_sub -v -V mqttv311 -u homeassistant -P <broker password> -t "#"

Just tried from my Windows Laptop like this:
mosquitto_sub.exe -v -V mqttv311 -h 192.168.178.30 -u homeassistant -P mypw -t #

Output is (switching it on/off trough webinterface):

$SYS/broker/version HBMQTT version 0.9.4
tele/badspiegel/LWT online
tele/badspiegel/STATE {"Time":"2018-11-11T10:24:38","Uptime":"0T11:35:35","Vcc":3.149,"POWER":"OFF","Wifi":{"AP":1,"SSId":"myssid","RSSI":66,"APMac":"44:4E:6D:A2:58:E9"}}
stat/badspiegel/RESULT {"POWER":"ON"}
stat/badspiegel/POWER ON
stat/badspiegel/RESULT {"POWER":"OFF"}
stat/badspiegel/POWER OFF

Looks fine right? Switch is still not available inside HA.
SpiegelLicht

Could it be that HA is not picking up the LWT message.

Try setting qos to 1 in your config

Capitalization is important. This needs to be

  payload_available: "online"
1 Like

I checked that and his config is identical to mine, except I am using QoS 1 and I don’t use “homeassistant” as my mqtt username. I have the capital ‘O’ working but with tasmota 6.2. The guide uses capitals too.

Setting qos to 1 didn’t help.

BUT setting payload_available to “online” instead of “Online” did the trick! Thank you very much!

2 Likes

Can you confirm that it is actually working in that it is displayed as offline when you unplug the sonoff?

When I unplug the Sonoff is says “Not available”.

Everything seems to work fine now. But I kept the QOS setting to 1.

Is it somehow possible to mute the Sonoff so it doesn’t make that noise when switching it on/off ?

Every guide I read said the o is uppercase. Maybe remember if you update your tasmota you may need to change it back.

If you mean the click sound of the relay then I don’t think it is easy to change this unless you mod them to use quieter or solid state relays if this is even possible.

You can only configure HA from what the tasmota is actually sending. I don’t have a tasmota, so there may be some configuration that has been set up to send all lower case for the LWT message, but it seems easier to change HA.

No its relay clicking over

Wait you could put in different room lol