Sonoff Docker MQTT Home Assistant: Sonoff not working in HA [SOLVED]


I working on this issue for a full week now and not able to solve it (I think it is not too difficult for a person with experience):

I have a sonoff device (R2 Power V1) connected with a fan (to switch it on/off), flashed with Tasmota, it is connected to the Wifi and working fine. But, with HA (0.96) and does not work. I have put in my config files so you can check my config (sonoff is connecting with mqtt of HA, seems to be working, also in the console of the sonoff).

Can you help me out why HA cannot switch the sonoff? If I put on the switch, after a couple of second the switch is turning off by itself but nothing is happening to the sonoff.

Hi @Edo

I ran in exactly the same thing, when i started just this week with HA. Here is one of my MQTT switches:

  - platform: mqtt
    name: ho_links
    icon: mdi:lamp
    state_topic: "stat/ho_links/POWER"
    command_topic: "cmnd/ho_links/POWER"
    payload_on: "ON"
    payload_off: "OFF"
    state_on: "ON"
    state_off: "OFF"

It helped me to add the state_on and state_off command. As HA seems to use this to actually turn (and keep) the switch on.

Hope this helps!


check the console to ensure the command is indeed endintg in POWER and not POWER1

hi Roe and Juan,

thanks for helping me out! I tried/checked both but no succes yet. If I add state_on and state_off, HA does accept that and states an error in the configuration.yaml. POWER seems to be right, if I put the power on, the console reports POWER (I will include the screen shots). Do you have other ideas? Thanks for the help.


I copy/paste your configuration fully, reloaded my HA (adjusted the path), and now it works!
Wauw, thank you so much!