Sonoff SNZB-01 Switches all started registering being pressed twice

  • Platform information:
    • Hardware: Virtualized, 4 cores, 4GB Ram
    • OS: Ubuntu 22.04.3 LTS
    • openHAB version: Started happening on OpenHAB 3 (OpenJDK 11), as well as continuing after upgrading to OpenHAB4 (OpenJDK 17)
  • Issue of the topic: I’m not sure exactly when, but a few months ago, my Sonoff SNZB-01 Switches all started doing the same thing, and that is pressing them (Single, Double, or Long press) will typically turn whatever I configured in it’s rules to turn on, but then it will never go off. I have my rules set that if light.state >= 1, then turn off, else if light.state <1, then turn on.

Thinking maybe it was an issue with openhab reading the value of the light (which is reporting correctly under the sitemap anyway), I even made some dummy switches that the rules control, based upon the input of the switch, and sometimes the switches will come on, but never go off (or toggle off for just a fraction of a second before coming back on again).

I can see via zigbee2MQTT that the switch is firing and detecting as single/double/long presses, and I have a rule that spits out in the openhab.log every time the switch is pushed, so I can see it’s triggering single/double/long presses, but the dummy switches will flick off and back on within a fraction of a second. Same goes for the lights, they’ll start to dim down to like 95% then go right back to 100%, and it’s been driving me crazy. I haven’t changed any of the rules between it working and then breaking.

My Ikea switches are not experiencing these issues, and they have the similar single/long press ability

  • Please post configurations (if applicable):
    • Items configuration related to the issue

mqtt.things:

    Thing topic bl_test_switch "Downstairs Office Test Switch" @ "Downstairs Office"
    {
        Channels:
            Type string : action "action" [ stateTopic = "zigbee2mqtt/BL_TestSwitch/action" ]
            Type number : voltage "voltage" [ stateTopic = "zigbee2mqtt/BL_TestSwitch/voltage" ]     
            Type number : battery "battery" [ stateTopic = "zigbee2mqtt/BL_TestSwitch/battery" ]     
            Type number : linkquality "linkquality" [ stateTopic = "zigbee2mqtt/BL_TestSwitch/linkquality" ]               
    }

sensors.items:

Switch    Switch_Dummy1
Switch    Switch_Dummy2
Switch    Switch_Dummy3

String     Switch_BL_TestSwitch                            "Test Switch [%s]"                    <button>     {channel="mqtt:topic:mosquitto:bl_test_switch:action"}
Number     Switch_BL_TestSwitchBatt                        "Test Switch Battery [%.0f %%]"       <battery>    {channel="mqtt:topic:mosquitto:bl_test_switch:battery"}

test.rules

rule "Test Switch Light Control"
when
    Item Switch_BL_TestSwitch received update
then

    switch(Switch_BL_TestSwitch.state.toString) {
        case "single": {
            logInfo("test.rules", "Test Switch fired single")

            if(Switch_Dummy1.state == ON){
                Switch_Dummy1.sendCommand(OFF)
            }

            else if(Switch_Dummy1.state == OFF){
                Switch_Dummy1.sendCommand(ON)
            }

        }
        case "double": {
            logInfo("test.rules", "Test Switch fired double")

            if(Switch_Dummy2.state == ON){
                Switch_Dummy2.sendCommand(OFF)
            }

            else if(Switch_Dummy2.state == OFF){
                Switch_Dummy2.sendCommand(ON)
            }

        }
        case "long": {
            logInfo("test.rules", "Test Switch fired long")

            if(Switch_Dummy1.state == ON || Switch_Dummy2.state == ON){
                Switch_Dummy1.sendCommand(OFF)
                Switch_Dummy2.sendCommand(OFF)
            }

            else if(Switch_Dummy1.state == OFF || Switch_Dummy2.state == OFF){
                Switch_Dummy1.sendCommand(ON)
                Switch_Dummy2.sendCommand(ON)
            }

        }
    }

end

My other rules are similar although instead of just checking the current dummy switch state, they check light levels

autolights_kitchen.rules

rule "Kitchen Counter Light Control"
when
    Item Switch_UL_NorthCounterSwitch received update
then

    //logInfo("autolights_kitchen.rules", "Kitchen Counter Lightswitch fired")
    switch(Switch_UL_NorthCounterSwitch.state.toString) {
        case "single": {
            
            if(Light_UL_Kitchen_CounterN_Dimmer.state >= 1){
                Light_UL_Kitchen_CounterN_Dimmer.sendCommand(OFF)
            }

            else if(Light_UL_Kitchen_CounterN_Dimmer.state < 1){
                Light_UL_Kitchen_CounterN_Dimmer.sendCommand(ON)
            }

        }
        case "double": {

            if(Light_UL_Kitchen_CounterW_Dimmer.state >= 1){
                Light_UL_Kitchen_CounterW_Dimmer.sendCommand(OFF)
            }

            else if(Light_UL_Kitchen_CounterW_Dimmer.state < 1){
                Light_UL_Kitchen_CounterW_Dimmer.sendCommand(ON)
            }

        }
        case "long": {

            if(Light_UL_Kitchen_CounterN_Dimmer.state >= 1 || Light_UL_Kitchen_CounterW_Dimmer.state >= 1){
                Light_UL_Kitchen_CounterN_Dimmer.sendCommand(OFF)
                Light_UL_Kitchen_CounterW_Dimmer.sendCommand(OFF)
            }

            else if(Light_UL_Kitchen_CounterN_Dimmer.state < 1 || Light_UL_Kitchen_CounterW_Dimmer.state < 1){
                Light_UL_Kitchen_CounterN_Dimmer.sendCommand(ON)
                Light_UL_Kitchen_CounterW_Dimmer.sendCommand(ON)
            }

        }
    }

end

And it’s worked fine for well over a year so I’m not sure what happened, nor why every one of my Sonoff SNZB-01 Switches are exhibiting the same issue.

The only thing I can see is the switch logs (in openhab) are reporting as if they have received the command twice:

single tap (registered twice):
2023-09-15 08:03:57.070 [INFO ] [openhab.core.model.script.test.rules] - Test Switch fired single
2023-09-15 08:03:57.071 [INFO ] [openhab.core.model.script.test.rules] - Test Switch fired single

single tap (registered twice):
2023-09-15 08:04:01.400 [INFO ] [openhab.core.model.script.test.rules] - Test Switch fired single
2023-09-15 08:04:01.402 [INFO ] [openhab.core.model.script.test.rules] - Test Switch fired single

double tap (registered twice):
2023-09-15 08:04:04.948 [INFO ] [openhab.core.model.script.test.rules] - Test Switch fired double
2023-09-15 08:04:04.951 [INFO ] [openhab.core.model.script.test.rules] - Test Switch fired double

single tap (registered twice):
2023-09-15 08:04:25.205 [INFO ] [openhab.core.model.script.test.rules] - Test Switch fired single
2023-09-15 08:04:25.208 [INFO ] [openhab.core.model.script.test.rules] - Test Switch fired single

double tap (registered twice):
2023-09-15 08:04:40.639 [INFO ] [openhab.core.model.script.test.rules] - Test Switch fired double
2023-09-15 08:04:40.641 [INFO ] [openhab.core.model.script.test.rules] - Test Switch fired double

long press (registered once correctly):
2023-09-15 08:04:53.176 [INFO ] [openhab.core.model.script.test.rules] - Test Switch fired long

long press again (registered twice):
2023-09-15 08:05:08.110 [INFO ] [openhab.core.model.script.test.rules] - Test Switch fired long
2023-09-15 08:05:08.117 [INFO ] [openhab.core.model.script.test.rules] - Test Switch fired long

Any suggestions? I tried searching the community but not even sure what the issue is or why this suddenly started happening in June.

Further investigation shows via zigbee2MQTT shows in it’s logs that it’s detecting double press too

info 2023-09-15 08:14:49MQTT publish: topic 'zigbee2mqtt/BL_TestSwitch', payload '{"action":"single","battery":100,"linkquality":72,"voltage":3000}'
info 2023-09-15 08:14:49MQTT publish: topic 'zigbee2mqtt/BL_TestSwitch/voltage', payload '3000'
info 2023-09-15 08:14:49MQTT publish: topic 'zigbee2mqtt/BL_TestSwitch/battery', payload '100'
info 2023-09-15 08:14:49MQTT publish: topic 'zigbee2mqtt/BL_TestSwitch/linkquality', payload '72'
info 2023-09-15 08:14:49MQTT publish: topic 'zigbee2mqtt/BL_TestSwitch/action', payload 'single'
info 2023-09-15 08:14:49MQTT publish: topic 'zigbee2mqtt/BL_TestSwitch', payload '{"action":"single","battery":100,"linkquality":69,"voltage":3000}'
info 2023-09-15 08:14:49MQTT publish: topic 'zigbee2mqtt/BL_TestSwitch/voltage', payload '3000'
info 2023-09-15 08:14:49MQTT publish: topic 'zigbee2mqtt/BL_TestSwitch/battery', payload '100'
info 2023-09-15 08:14:49MQTT publish: topic 'zigbee2mqtt/BL_TestSwitch/linkquality', payload '69'
info 2023-09-15 08:14:49MQTT publish: topic 'zigbee2mqtt/BL_TestSwitch/action', payload 'single'

I wonder if a few months ago it updated them all with a bugged update, I’m open to suggestions before I rip them all out and swap them with the ikea toggle switches instead.

I tried several things although unfortunately couldn’t fix it. Even re-installing zigbee2mqtt altogether with no change.

As I also ended up buying some SeeedStudio mmWave kits, which require ESPHome, I was unable to get them working with OpenHAB, so knowing that they worked with Home Assistant, I ended up setting up a Home Assistant VM, got them configured, and had Home Assistant push the specific presence statuses via a topic onto MQTT, which OpenHAB could read and run rules, although after a week of that, and still being frustrated with the Sonoff Switches not working correctly anymore, I thought it was silly to run (and have to keep) 2 separate automation platforms in sync with one another, so I’m sad to say, after 3 years and a couple weeks, I’ve decided to swap over to Home Assistant.

Took me about 2 weeks to get about 95% of my automations moved over. OpenHAB is still controlling my HVAC controls for our bedroom (I programmed a thermostat to use my Sensibo’s temperature and a smart plug to control an electric oil heater, as well as the sensibo to toggle the AC on depending on the time of year to regulate the bedroom which is always colder than other rooms, though that was my most complex rule as it only triggered depending on how many degrees the room was off from the set point in order to heat it up by 10pm for bed time. 1 degree under set point heating would come on at 9, 2 degrees 8:30, 3 degrees, 8pm, 4 degrees, 7:30, etc, same goes for cooling for every degree the room was above the set point in order to conserve energy and not have to remember when to toggle the ac or heater on to cool/heat the room. I’ve yet to tackle that one yet, but all my other automations are moved over and more.)

This community was great when I needed help, and I appreciate all the help others have provided in the past 3 years, although unfortunately due to those 2 issues that I was unable to get working figured I’d switch, and overall I’ve been happy.

A bit of a learning experience (especially when converting my old .rules files from OpenHAB to ones created through Home Assistant’s GUI, or by YAML (after re-creating 90-95% of them, I threw a complete OpenHAB rule at ChatGPT 4 and asked it to convert it to a Home Assistant Automation file in YAML, and to my surprise it did so perfectly, so I probably could have saved a bit of time using that, I had unfortunately alreadly manually ported over hundreds of my automations already at that point.)

I have to say HA has come a long way since I last tried it 3 years ago (just before saying no to it and moving over to OpenHAB.) I’ve been able to do heaps more with my house that I was unable to do previously (or couldn’t find a way to do with OpenHAB) like being able to create dynamic scenes that take a snapshot of all listed devices, change or turn off lights, and re-activate them after, for me I created an automation that when the “Movie” category in plex is active and it’s playing, it snapshots the living room lights, turns off extra lights, and dims the TV and Couch light to “movie watching” levels. If I pause the movie, the lights dim back up and any that were previously on when the snapshot was made, are restored to their previous state. This only happens when watching a movie, and is otherwise unchanged if I’m watching a tv show through plex etc.

I’m a bit sad to say goodbye to OpenHAB, but just wanted to say take care everyone, I wish you all the best.