Folks,
I’ve got a problem defining my sonoff basic switch in home assistant.
In specific, I cannot find the right MQTT settings to get it working.
I got Hassbian 0.69.1 (not hass.io) running on a Rasberry Pi 3.
I want to use the embedded MQTT server in Home Assistant.
Sonoff switch has Tasmota firmware 5.12 running.
Host: IP address from my Raspberry Pi
Port: predefined, not changed
Client: predefined
Benutzer = User: the gui username of my homeassistant installation
Passwort = password: the gui password of my homeassistant installation
topic: changed to a unique name for my sonoff switch
full topic: predefined or default, not changed
Question 1:
is “homeassistant” the correct username?
When I login into the web gui, I only need to enter the password without username.
But the sonoff switch is shown as “not available” in the dashboard:
The working “SZ-Fernsehlampe” is connected with a AVM DECT200 switch.
The other switches are other sonoffs, I try to implement after one of them is working correctly.
If you want to use the embedded broker, you just need mqtt: in your configuration, as you had it originally. The configuration suggested by @myle requires you to set up an external broker.
At that point, the sonoff correctly connected to the broker. The only thing left was to determine the topics to be sent.
I think your missing the “payload”. I have a few Sonoff basics that I set up following this video by BRUH Automation. Here’s how my configuration looks for the sonoff.
I also notice you have “POWER” capitalized in both in both the command and state topics. I don’t fully understand mqtt enough to know if that matters or if just to help tell them apart? But the example I followed did have one in all caps and the other all lower.
Alright…
First I changed the topic back to default = sonoff.
In the configuration.yaml I already had the payload etc etc in - dont ask me, why I didnt typed and posted here the complete config, sorry, my mistake.
After some trial boot ups, I had success, but realized, that it is not a must, that the default topic is “sonoff”.
It is possible and needed to give here a “unique” name, also in case of more switches.
Otherwise, all of the sonoff switches will turn on with one “switch” in the homeassistant dashboard.
In my case it is now “sonoff_gh” and “sonoff_wz” (two separate sonoff switches).
With that, the dashboard shows my two sonoff switches and I can turn it on.
Only on!
Not out again
Also, when I commented in the availability_topic, hassbian is not starting after reboot.
Alright, satisfied right now.
The next step is to figure out, why I can only turn the switches on, not out.
The dashboard switch shows the animation for turning on, followed by the animation for turning off (switch button switches back to off). But the lamps, which are connected to the sonoffs, keep powered on.
You need to post your yaml snippets using the instructions in the blue box at the top of the post.
This means that the state message sent by the sonoff has not been decoded correctly by HA, so HA assumes it is still off. I notice in your configuration that you have changed the state_topic: to lower case. I believe that should be upper case, to match the configuration supplied by @troy.
It is interesting that the command_topic: works as upper case, but it could be the sonoff converts it. But if it works like that, leave it be.