Sonoff basic, switch local problems

Hi,
I have some sonoff basic switches.
All works good with hass.
But if i want to switch them with a button via gpio 14 or locally push the button something strange happends.
If hass is switch is off, then locally i cant turn it on. Only for few secs and then it turns off.
The same with hass on, it switches back when i locally press the button on sonoff.
How can i make it working together?

Hi @Wesley2004, are you using tasmota?
If so, take a look at the SwitchMode
I had to set SwitchMode=3 with a push button, so on every button press the switch toogles the relay.

Yes i use tasmota.
The problem is also there when i dont use external switch. Just push the button on the sonoff itself.

I tried, in console it gives me an unknown command…

Sorry, you have to type SwitchMode 3 to set.

Ok he understands the command with that.

But the problem is still here.
If i go to the browser of the sonoff and try to switch it. Hass overrules it!

Can you show the HA config of your switches?

switch:      
  - platform: mqtt
    name: "Sonoff1"
    command_topic: "cmnd/sonoff1/POWER"
    state_topic: "stat/sonoff1/POWER"
    qos: 1
    optimistic: true
    payload_on: "ON"
    payload_off: "OFF"
    retain: true
    
  - platform: mqtt
    name: "Sonoff2"
    command_topic: "cmnd/sonoff2/POWER"
    state_topic: "stat/sonoff2/POWER"
    qos: 1
    optimistic: true
    payload_on: "ON"
    payload_off: "OFF"
    retain: true```

Have you got PowerRetain enabled on the Sonoff?

if i have to activate it manually i think not…
how do i do that? What is it?

if i put powerretain in console it says off

when i give command powerretain on it goes on

but still same problem

Not sure, but have you tried without the optimistic variable?
I think you only need it if there’s no state topic.

I found the problem!
In the webbrowser of the sonoff they had all the same client name.
First i had two sonoffs, and didnt found that error.
Now i have 7 i discovered the problem.
Thanks for helping!

1 Like