Howto add Sonoff-Tasmota to Hass.io?

My SONOFF version firmware: Sonoff-Tasmota 5.11.1e
My HASS.io version firmware: 0.61.1

Howto add my sonoff to Hass.io?

Config SONOFF

configuration.yaml

mqtt:
  - broker: 192.168.1.220
    port: 1883
    username: admin
    password: 12345
    
  - broker: 192.168.1.119
    port: 1883
    username: admin
    password: 12345    

switch:

platform: mqtt
name: "Sonoff 01"
state_topic: "home/sonoff01/switch1"
command_topic: "home/sonoff01/switch1/set"
availability_topic: "home/sonoff01/switch1/available"
payload_on: "ON"
payload_off: "OFF"
optimistic: false
qos: 0
retain: true

Error UI

hassio-error

Your indenting is wrong.
Indent everything under switch: like you have with your MQTT brokers.

Can I ask why you have two MQTT brokers ?

two sonoff = two broker
it’s ok?

It’s correct?

- mqtt:
  broker: 192.168.1.220
  port: 1883
  username: admin
  password: 12345
- platform:mqtt
name: "Sonoff 01"
state_topic: "home/sonoff01/switch1"
command_topic: "home/sonoff01/switch1/set"
availability_topic: "home/sonoff01/switch1/available"
payload_on: "ON"
payload_off: "OFF"
optimistic: false
qos: 0
retain: true

Almost. Try this :

mqtt:
  broker: 192.168.1.220
  port: 1883
  username: admin
  password: 12345

switch:
 - platform:mqtt
   name: "Sonoff 01"
   state_topic: "home/sonoff01/switch1"
   command_topic: "home/sonoff01/switch1/set"
   availability_topic: "home/sonoff01/switch1/available"
   payload_on: "ON"
   payload_off: "OFF"
   optimistic: false
   qos: 0
   retain: true

Error!..

Your indentation is still wrong.

Copy from my last post.

Currently you have

switch:

- platform: mqtt
  everything else under here

Should be

switch:
 - platform:
   everything else under here

You currently have the hyphen under the ‘s’ in switch.
It should be under the ‘w’ in switch

I Try…

sonoff-config2

Waiting… reboot HASS.io…

NO!
Error…

sonoff-config3

Please… helpme! Thx!

You have a separate switch.yaml ? Then it will be different again.

You’ll need to remove the switch: at the top and remove the space before the hyphen in front of platform.
Then line everything up under the ‘p’ in platform :slight_smile:

So in your switch.yaml you will have

- platform:mqtt
  name: "Sonoff 01"
  state_topic: "home/sonoff01/switch1"
  command_topic: "home/sonoff01/switch1/set"
  availability_topic: "home/sonoff01/switch1/available"
  payload_on: "ON"
  payload_off: "OFF"
  optimistic: false
  qos: 0
  retain: true

:joy::joy::joy: i try!
Reboot… wait!

Thx Thx!!!

i try! reboot now!

I thank you for all the information.
I’m new to hass.io
I hope it can work now …

unfortunately there are other errors:

To avoid errors I have separated the configuration:

Now reboot! :crossed_fingers:

Going from your first post, you’ve told the Sonoff the broker is on 192.168.1.219 and then in the HA config you’re using completely different IPs.

The broker IP should be your pi’s IP as that’s where it is.

Also, the default topics are…

state_topic: "stat/sonoff/POWER"
command_topic: "cmnd/sonoff/POWER"

What guide did you follow as it can’t have been one for a tasmota/ha combination?

…also, check your homeassistant.log to find specifically what the errors are.

the same discussion is at this address: https://goo.gl/DjVVWB
thx!

I think the problem that you have a problem is with the mqtt topic, you had defined the topic in you sonoff as sonoff2 (see the image that you post), and in your configuration file you have all the topics has sonoff01. The topics in the configuration file must be always like:
state_topic: “stat/sonoff/POWER”
command_topic: “cmnd/sonoff/POWER”
availability_topic: “tele/sonoff/LWT”
The only thing that you can change in the strings between “” is the word sonoff, that is between / /. And you change for the name that you put on the topic option, on the sonoff configuration page. For your case and assuming that you still have the configuration as in the image that you post you must put: sonoff2. The rest you CAN’T change.
If you have several sonoff you change the topic for each one, and must be different. And use the same topic name in the switch configuration.

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