Sonoff toggle button does not revert status

Hello everyone!,

I have searched for all possible information but I can not find the problem. In summary, if the state is ON and I press the button of the sonof it changes to OFF and just instantly again to ON: S: S

The first thing that happened to me is that the HA did not recognize the status and I added the sonoff by console: “PowerRetain 1”

After this, I could control the state change from HA.

The configuration that I currently have in configuration.yaml:

mqtt:
broker: 192.168.1.70
port: 1883
client_id: casa
username: xxxx
password: xxxxx

switch:

  • platform: mqtt
    name: “Lampara Television”
    command_topic: “cmnd/salonlamparatv/power”
    state_topic: “stat/salonlamparatv/POWER”
    qos: 1
    payload_on: “ON”
    payload_off: “OFF”
    retain: true

  • platform: mqtt
    name: “Lampara Sofa”
    command_topic: “cmnd/salonlamparasofa/power”
    state_topic: “stat/salonlamparasofa/POWER”
    qos: 1
    payload_on: “ON”
    payload_off: “OFF”
    retain: true

And the console of the sonoff when I try to turn off the button:

19:51:33 UPP: Multicast (re)joined
19:51:34 MQT: Attempting connection…
19:51:34 MQT: Connected
19:51:34 MQT: tele/salonlamparasofa/LWT = Online (retained)
19:51:34 MQT: cmnd/salonlamparasofa/POWER =
19:51:34 MQT: stat/salonlamparasofa/RESULT = {“POWER”:“ON”}
19:51:34 MQT: stat/salonlamparasofa/POWER = ON (retained)
19:51:34 UPP: Multicast (re)joined
19:51:35 MQT: Attempting connection…
19:51:35 MQT: Connected
19:51:35 MQT: tele/salonlamparasofa/LWT = Online (retained)
19:51:35 MQT: cmnd/salonlamparasofa/POWER =
19:51:35 MQT: stat/salonlamparasofa/RESULT = {“POWER”:“ON”}
19:51:35 MQT: stat/salonlamparasofa/POWER = ON (retained)
19:51:35 MQT: stat/salonlamparasofa/RESULT = {“POWER”:“OFF”}
19:51:35 MQT: stat/salonlamparasofa/POWER = OFF (retained)
19:51:36 UPP: Multicast (re)joined
19:51:36 MQT: Attempting connection…
19:51:36 MQT: Connected
19:51:36 MQT: tele/salonlamparasofa/LWT = Online (retained)
19:51:36 MQT: cmnd/salonlamparasofa/POWER =
19:51:36 MQT: stat/salonlamparasofa/RESULT = {“POWER”:“ON”}
19:51:36 MQT: stat/salonlamparasofa/POWER = ON (retained)
19:51:37 UPP: Multicast (re)joined

Any ideas? I can not find the error :frowning:

Thank you very much!!!