How to use Sonoff Tasmota in Home Assistant?

Awesome stuff! I want to use your binary_sensor for LWT inside my packages but whenever I add a binary_sensor to a package, config fails. Sensors work fine. Anyone got any tricks?

Hi, if you are still having issues, I have a guide here on how to set up Sonoff Tasmota either through auto detection or MQTT.

Hey.
I have been struggling to manually(without using Auto-discovery) configure my Sonoff Basic, but after carefully studying GitHub wiki(wiki), i finally made it. I’m using Sonoff-Tasmota 6.4.1 and Home Assistant 0.85.1, so my configuration looks like:

/config/configuration.yaml:
switch: !include switch.yaml

/config/switch.yaml:

  • platform: mqtt
    name: “MY SONOFF”
    command_topic: “tasmota/sonoff_basic/cmnd/POWER1”
    state_topic: “tasmota/sonoff_basic/cmnd/POWER1”
    qos: 1
    payload_on: “ON”
    payload_off: “OFF”
    payload_available: “Online”
    payload_not_available: “Offline”
    retain: false

The code alignment is very important in yaml, so make sure you do the exact way as on my screenshoot

Note, that during Sonoff Basic MQTT configuration you should use the following:
Topic: sonoff_basic
Full Topic: tasmota/%topic%/%prefix%/

Hope it will help someone as me :smile:

1 Like

Your setup should like this:
- platform: mqtt
name: “Your Desired Name”
state_topic: “stat/sonoff_basic/POWER1”
command_topic: “cmnd/sonoff_basic/POWER1”
payload_on: “ON”
payload_off: “OFF”
optimistic: true
qos: 1
payload_available: “Online”
payload_not_available: “Offline”
retain: false

No, @mistrovly, i am afraid you are wrong.
The config you propose would probably have worked on the older versions. I have spend hours trying to make similar config work, but with no luck. The configuration I have posted above works flawlessly thou. If I am not mistaken there were some changes on Tasmota side source about two weeks ago. :slightly_smiling_face:

thanks. What version of tasmota are you using; because i’m still using 6.3.0

I am using 6.4.1, which i believe is the latest at the moment of me writing

Thank you for the info.

1 Like

It doesn’t make sense that you’re using the command topic name as the state_topic:.

All that does is capture the outbound command sent to the Sonoff device. It won’t catch the update that the Tasmota software publishes if there’s local control done, like someone pushes the button.

FYI, my configuration looks like this:

switch:
   - name: "sonoff1"
     platform: mqtt
     command_topic: 19916/cmnd/sonoff1/power
     state_topic:   19916/stat/sonoff1/POWER
     availability_topic: 19916/tele/sonoff1/LWT
     qos: 1
     retain: false
     payload_on:  "ON"
     payload_off: "OFF"
     payload_available:  "Online"
     payload_not_available: "Offline"

Note the topic names are case sensitive, and power vs. POWER in the command vs. state topics. My topic names have a non-standard prefix, and that particular device has a name of sonoff1 rather than the default… but the important bit is that they’re look at the stat topic to which state updates are published.

3 Likes

Thanks for this…