Deconz-rest-plugin: Sonoff SNZB-01

Created on 28 Jun 2020  路  87Comments  路  Source: dresden-elektronik/deconz-rest-plugin

Device

  • Product name: Wireless Switch
  • Manufacturer: Sonoff
  • Model identifier: SNZB-01
  • Device type:

    • [ ] Light

    • [ ] Lock

    • [x] Remote

    • [ ] Sensor

    • [ ] Siren

    • [ ] Thermostat

    • [x] Other: Wireless Switch

image
image

Awaiting Merge Device Request stale

Most helpful comment

Very interested on this switch

All 87 comments

Please add the missing information as mentioned in the device request, thanks!

Sorry, I'm new to this!

Are you talking about this?
image

Any update on this. Do you need more information?

Very interested on this switch

As there hasn't been any response in 21 days, this issue has been automatically marked as stale. At OP: Please either close this issue or keep it active It will be closed in 7 days if no further activity occurs.

As there hasn't been any response in 28 days, this issue will be closed. @ OP: If this issue is solved post what fixed it for you. If it isn't solved, request to get this opened again.

Hi! Guys, I just get this device, but one question, I have only two actions: double and long, and missing single click.

image

image

image

image

Any suggestion for this situation or at current moment device is not fully supported yet?

image

image

But from the code I see only "on" and "off" as return possible.

static const Sensor::ButtonMap sonoffOnOffMap[] = {
//    mode                          ep    cluster cmd   param button                                       name
    { Sensor::ModeScenes,           0x01, 0x0006, 0x01, 0,    S_BUTTON_1 + S_BUTTON_ACTION_SHORT_RELEASED, "On" },
    { Sensor::ModeScenes,           0x01, 0x0006, 0x00, 0,    S_BUTTON_2 + S_BUTTON_ACTION_SHORT_RELEASED, "Off" },
    // end
    { Sensor::ModeNone,             0x00, 0x0000, 0x00, 0,    0,                                           nullptr }
};

Wich one numeric value you have ?

If I correctly understood your question 'bout values of buttons... double 1002, long 2002 (at Home Assistant events)

Ok so it seem this devices have other return value.
I have used the @SAOPP log to make the table, but will be nice if someone can test it ?

The new code

static const Sensor::ButtonMap sonoffOnOffMap[] = {
//    mode                          ep    cluster cmd   param button                                       name
    { Sensor::ModeScenes,           0x01, 0x0006, 0x01, 0,    S_BUTTON_1 + S_BUTTON_ACTION_DOUBLE_PRESS, "Double" },
    { Sensor::ModeScenes,           0x01, 0x0006, 0x00, 0,    S_BUTTON_1 + S_BUTTON_ACTION_LONG_RELEASED, "Long" },
    { Sensor::ModeScenes,           0x01, 0x0006, 0x02, 0,    S_BUTTON_1 + S_BUTTON_ACTION_SHORT_RELEASED, "Short" },
    // end
    { Sensor::ModeNone,             0x00, 0x0000, 0x00, 0,    0,                                           nullptr }
};

To test the code

git clone --branch sonoff https://github.com/Smanar/deconz-rest-plugin.git
cd deconz-rest-plugin
qmake && make -j2
sudo cp ../libde_rest_plugin.so /usr/share/deCONZ/plugins

I would be very happy to test this, but I am running DeConz in docker. Is that possible?

Nope, need a classic OS to compile the code.
But not in hurry.

I would like to test to but don't know how on RPI2

Does it works only for snzb-01 or maybe also with 03?

@pippo73 The 03 is a motion sensor ? not a switch ?

@NovaGL If you have a Rpi with a classic OS (not HA for exemple), you have the procedure on homepage https://github.com/dresden-elektronik/deconz-rest-plugin#install-deconz-development-package-optional-linux-only

Just change a little for step (1- 4)

git clone --branch sonoff https://github.com/Smanar/deconz-rest-plugin.git
cd deconz-rest-plugin
qmake && make -j2
sudo cp ../libde_rest_plugin.so /usr/share/deCONZ/plugins

How do I install qmake?

You have tested
sudo apt install deconz-dev

Doesn't work for me, can you make a package for RPI2 and I'll test it.

I tried I built it on ubuntu but get login failed

Yes @Smanar I'm talking about the motion sensor

I tried I built it on ubuntu but get login failed

Login failed - what u r mean? U can't login into phoscon with ur creds or?

The error was misleading, it actually wasn't compiled for the right arch i believe.

Don't know what I'm doing. Tried in an ubuntu vm i can build it but don't know what arch its building for.

Any tips for compiling would be appreciated.

@pippo73 this code is for the switch what is the problem with the motion sensor ? It seem work since the version 79 > https://github.com/dresden-elektronik/deconz-rest-plugin/issues/2991

@NovaGL You just need to use sudo apt install deconz-dev it will make the correct "environnement" according to your system. If this command work, the rest will be fine

And after use the same commands than me, what is your error displayed, it can come from me, I don't test all the code.

Hi @Smanar I struggle at this stage
sudo cp ../libde_rest_plugin.so /usr/share/deCONZ/plugins

Before I copy the file everything works fine, the moment I copy the file I can't access anything. No error

If you can tell me how to debug it I'll send you what error I can find but the logs I have dont show errors.

See what are the access rights for the new library that you compiled?

I think I was getting confused and rebooting the computer shows it not as accessible.
So it looks like it was compiled for the wrong arch when used on the PI and it shouldn't have been accessible on Ubuntu as it wasn't physically connected to it.

Is there anyway I can compile for the Raspberry PI when using Ubuntu VM.

as far I remember, it's a universal library, I can of course be wrong, the last time I compiled a few months ago

Compilation are machine specific, you can't compile on a machine and use the file on a different one.

Before I copy the file everything works fine, the moment I copy the file I can't access anything. No error

The system freeze ? Better to close deconz before replacing the file.

I don't have a proper computer to test it on as Hyper-V doesn't do USB Passthrough and can't compile on a RPI2 so I'll have to leave this for others to test.

@Smanar I've bought 5 of them, and I can connect only 2 of them. anyway I will try to ask in the 3d yo indicated me. Thank you anyway

I moved to zigbee2mqtt and these devices are working flawlessly

@NovaGL This is not a proper solution 馃槈

@Smanar Do we need to re-open this?

I agree this issue needs to be re-opened as it is not implemented correctly. Missing single click.

Happy to test but I just can't build it.

The current code base allows you to "fix" that on your own with a little guidance.

Awesome, can you point me in the right direction and I'll try and report back.

I can put my raspbee at official image, so maybe I can tested it...

You need to compile the current code of the offical repo. The instructions are mentioned there, in the readme.
Additionally, you need to copy file button_maps.json to the location where your database (zll.db) resides. In the json file, you cann add the missing entry which is either known or can be taken from deconz debug output.

Thanks I gave up on that cause I couldn't compile it on my RPI2

@SwoopX It s an old code make before your change so for this one they don't need yet to use the button_maps.json

Hey guys, has this now been tested and confirmed working and will be merged into the next release?

It s not tested yet ^^

It s not tested yet ^^

Will it be pushed into beta branch for testing? Seems odd to have half of the sonoff range working and the other half not.

PR done, untested, but you will be able to edit the file yourself on next version, will be json file.

PR done, untested, but you will be able to edit the file yourself on next version, will be json file.

Excellent, I'll wait for it to be released. Good job and thanks.

@Smanar I just received this exact switch in the mail today and stumbled upon this thread when it didn't work. I cloned down your branch, compiled, and copied over the libde_rest_plugin.so and button_maps.json file. It didn't work for me. I still see the following logged when I do any of the button presses:

# Short
[INFO] - No button map for: WB01 endpoint: 0x01 cluster: 0x0006 command: 0x02 payload[0]: 000
# Double
[INFO] - No button map for: WB01 endpoint: 0x01 cluster: 0x0006 command: 0x01 payload[0]: 000
# Long
[INFO] - No button map for: WB01 endpoint: 0x01 cluster: 0x0006 command: 0x00 payload[0]: 000

What device are you using with the combee? Maybe you have to update button maps json

I'm using the ConBee 2. I copied the button maps file from Smanar's branch to the ~/.local/share/dresden-elektronik/deCONZ/button_maps.json. I guess I'm not sure if that is the right place, but its the same directory as the zll.db file.

I mean what device is the combee connected too? A raspberry Pi?

Oh sorry. Deconz is installed on an LXD container running ubuntu 18.04. The ConBee USB stick is passed through to the container just like you would for docker.

Try creating a folder called devices where your zll.db resides and copy the json file there.

@SwoopX Yeah that made a difference. However the double press and the long press might be mixed up.

# Short
[INFO] - Button 1002 short
# Double
[INFO] - Button 1003 Long
# Long
Button 1004 double

if I edit the button_maps.json to switch the two like this then the log output is as expected:

"sonoffOnOffMap": [
                        [1, "0x01", "ONOFF", "ON", "0", "S_BUTTON_1", "S_BUTTON_ACTION_LONG_RELEASED", "double"],
                        [1, "0x01", "ONOFF", "OFF", "0", "S_BUTTON_1", "S_BUTTON_ACTION_DOUBLE_PRESS", "Long"],
                        [1, "0x01", "ONOFF", "TOGGLE", "0", "S_BUTTON_1", "S_BUTTON_ACTION_SHORT_RELEASED", "short"]
                ]

Thx, corrected on my side.

So, now with some more freedom and keyboard in front of me ;)

Manu changed the file path and obviously forgot to mention it. I found this out just yesterday myself. The path must be

~/.local/share/dresden-elektronik/deCONZ/devices/button_maps.json

@jdonofrio728 Glad it worked out, so the new approach already paid off.

I will say that even though the log messages look better, something still doesn't seem right. Home assistant (out of scope here) doesn't see this switch as a "switch", rather only detects the battery level. Deconz also only shows the same.

I expected the cluster object for On/Off or something else to be available. Perhaps I'm just misunderstanding something?

You got your ZHASwitch resource, don't you?

The only entity that home assistant found was the battery:

image

I'm sorry, I re-read the deconz integration documentation and found out that this is working correctly. Button pushes only fire events which I am fully able to capture. Everything seems to be working as expected. Sorry about that!

Seems to be working now with the new button map which is good.

Glad to hear this.

What's the current status of this regarding v2.05.84 and latest FW?

Do we still require the above workaround? For me, the switch does not work at all via the normal method. It is seen by phoscon but never registers and event in developer listening tab.

Not working with 84 too.

Only like as before, 1002 double, and long 1003 events.

Only like as before, 1002 double, and long 1003 events.

I cannot see any events in HA when listening to deconz_events :/

Try to reconnect the device, because initially there was no only a the single click event, double and long clicks should work.

Try to reconnect the device, because initially there was no only a the single click event, double and long clicks should work.

I've removed and added 3 times with no difference. Not sure what I'm doing wrong.

Strange, what the stick u have?

Strange, what the stick u have?

Conbee II, RPi 4, Docker

@SwoopX @Smanar guys, could u please clarify this situation with this device? Thanks in advance!

@SAOPP @Jimmy-SafeCash As far as i can see, it is added properly. Tagging Swoop won't help, he didn't integrate it.

I have checked with the latest HA deconz addon with version 2.05.84. Short button press is still not recognized.

Using the button map file works maybe update your button map and try again

The change will come with .85 Why does nobody read the release notes, it's not mentioned there.

Thanks buddy, I didn't read and know it. I thought these fixes should have been at 83 or 84... okay. So wait for 15th October. :)

Thanks buddy, I didn't read and know it. I thought these fixes should have been at 83 or 84... okay. So wait for 15th October. :)

Have now updated to 85 and re-added the switch. Still not working for me. Listening to deconz_events shows nothing for any of my sensors (but they still work). Any ideas why the switch doesn't? It used to work on double press and long press (not single), but now nothing at all. It also used to show in events.

I can confirm that all other sonoff sensors work fine.

I do not see any apparent reason why it shouldn't work. Can you share some deconz logs which include the button presses?

I do not see any apparent reason why it shouldn't work. Can you share some deconz logs which include the button presses?

Thanks @SwoopX for the prompt reply. Here are my logs:

23:50:01:032 GW firmware version: 0x26660700 23:50:01:032 GW firmware version is up to date: 0x26660700 23:50:08:837 [INFO] - No button handler for: SML001 endpoint: 0x02 cluster: 0x0406 command: 0x0A payload[0]: 000 23:50:08:837 ZCL attribute report 0x0017880106F4F8F9 for cluster: 0x0406, ep: 0x02, frame control: 0x08, mfcode: 0x0000 23:50:25:112 New websocket 192.168.2.40:51170 (state: 3) 23:50:54:971 Current channel 15 23:50:54:979 Device TTL 836 s flags: 0x7 23:51:26:761 [INFO] - No button handler for: SML001 endpoint: 0x02 cluster: 0x0406 command: 0x0A payload[0]: 000 23:51:26:761 ZCL attribute report 0x0017880106F4E208 for cluster: 0x0406, ep: 0x02, frame control: 0x08, mfcode: 0x0000 23:51:26:845 [INFO] - No button handler for: SML001 endpoint: 0x02 cluster: 0x0400 command: 0x0A payload[0]: 000 23:51:26:845 ZCL attribute report 0x0017880106F4E208 for cluster: 0x0400, ep: 0x02, frame control: 0x08, mfcode: 0x0000 23:51:30:306 [INFO] - No button handler for: SML001 endpoint: 0x02 cluster: 0x0402 command: 0x0A payload[0]: 000 23:51:30:306 ZCL attribute report 0x0017880106F4F8F9 for cluster: 0x0402, ep: 0x02, frame control: 0x08, mfcode: 0x0000 23:51:54:967 Current channel 15 23:51:54:975 Device TTL 776 s flags: 0x7 23:52:36:484 [INFO] - No button handler for: SML001 endpoint: 0x02 cluster: 0x0402 command: 0x0A payload[0]: 000 23:52:36:484 ZCL attribute report 0x0017880106F4E208 for cluster: 0x0402, ep: 0x02, frame control: 0x08, mfcode: 0x0000 23:52:39:063 [INFO] - No button handler for: RWL021 endpoint: 0x02 cluster: 0x0001 command: 0x0A payload[0]: 021 23:52:39:064 ZCL attribute report 0x0017880104F32359 for cluster: 0x0001, ep: 0x02, frame control: 0x08, mfcode: 0x0000 23:52:54:959 Current channel 15 23:52:54:967 Device TTL 716 s flags: 0x7 23:53:12:460 [INFO] - No button handler for: SML001 endpoint: 0x02 cluster: 0x0406 command: 0x0A payload[0]: 000 23:53:12:460 ZCL attribute report 0x0017880106F4D4F9 for cluster: 0x0406, ep: 0x02, frame control: 0x08, mfcode: 0x0000 23:53:12:555 [INFO] - No button handler for: SML001 endpoint: 0x02 cluster: 0x0400 command: 0x0A payload[0]: 000 23:53:12:555 ZCL attribute report 0x0017880106F4D4F9 for cluster: 0x0400, ep: 0x02, frame control: 0x08, mfcode: 0x0000

The device is added via phoscon and shows as it always has. I have added the button_maps.json in the /devices folder

Update: The switch is connected to the network. When I press the button the VNC map shows the switch blinking blue and green.

deconz_events in HA shows nothing and never has (no matter which sensor I activate).

Latest logs when spamming button presses:

22:29:32:390 [INFO] - No button handler for: SML001 endpoint: 0x02 cluster: 0x0402 command: 0x0A payload[0]: 000 22:29:32:390 ZCL attribute report 0x0017880106F4F8F9 for cluster: 0x0402, ep: 0x02, frame control: 0x08, mfcode: 0x0000 22:29:33:961 Current channel 15 22:29:33:969 Device TTL 5639 s flags: 0x7 22:29:39:220 [INFO] - Button 1002 short 22:29:42:004 [INFO] - Button 1002 short 22:29:45:960 [INFO] - No button handler for: TH01 endpoint: 0x01 cluster: 0x0402 command: 0x0A payload[0]: 000 22:29:45:960 ZCL attribute report 0x00124B002228CA84 for cluster: 0x0402, ep: 0x01, frame control: 0x18, mfcode: 0x0000 22:29:46:151 [INFO] - Button 1003 long 22:29:53:344 sensor 2 (SML001): disable presence 22:29:53:548 [INFO] - No button handler for: SML001 endpoint: 0x02 cluster: 0x0406 command: 0x0A payload[0]: 000 22:29:53:548 ZCL attribute report 0x0017880106F4ECA3 for cluster: 0x0406, ep: 0x02, frame control: 0x08, mfcode: 0x0000 22:30:13:926 [INFO] - Button 1002 short 22:30:15:927 [INFO] - Button 1004 double 22:30:16:941 [INFO] - No button handler for: SML001 endpoint: 0x02 cluster: 0x0406 command: 0x0A payload[0]: 000 22:30:16:941 ZCL attribute report 0x0017880106F4D4F9 for cluster: 0x0406, ep: 0x02, frame control: 0x08, mfcode: 0x0000 22:30:17:031 [INFO] - No button handler for: SML001 endpoint: 0x02 cluster: 0x0400 command: 0x0A payload[0]: 000 22:30:17:031 ZCL attribute report 0x0017880106F4D4F9 for cluster: 0x0400, ep: 0x02, frame control: 0x08, mfcode: 0x0000 22:30:18:366 [INFO] - Button 1002 short 22:30:18:530 [INFO] - No button handler for: SML001 endpoint: 0x02 cluster: 0x0400 command: 0x0A payload[0]: 000 22:30:18:530 ZCL attribute report 0x0017880106F4D4F9 for cluster: 0x0400, ep: 0x02, frame control: 0x18, mfcode: 0x0000 22:30:19:225 [INFO] - No button handler for: SML001 endpoint: 0x02 cluster: 0x0400 command: 0x0A payload[0]: 000 22:30:19:225 ZCL attribute report 0x0017880106F4F8F9 for cluster: 0x0400, ep: 0x02, frame control: 0x08, mfcode: 0x0000 22:30:20:792 [INFO] - Button 1004 double 22:30:24:050 [INFO] - Button 1002 short 22:30:27:196 [INFO] - Button 1002 short 22:30:31:694 [INFO] - No button handler for: SML001 endpoint: 0x02 cluster: 0x0402 command: 0x0A payload[0]: 000 22:30:31:694 ZCL attribute report 0x0017880106F4E208 for cluster: 0x0402, ep: 0x02, frame control: 0x08, mfcode: 0x0000 22:30:33:958 Current channel 15 22:30:33:966 Device TTL 5579 s flags: 0x7 22:31:20:908 [INFO] - No button handler for: RWL021 endpoint: 0x02 cluster: 0x0001 command: 0x0A payload[0]: 021 22:31:20:908 ZCL attribute report 0x0017880104F32359 for cluster: 0x0001, ep: 0x02, frame control: 0x08, mfcode: 0x0000 22:31:25:859 [INFO] - No button handler for: TH01 endpoint: 0x01 cluster: 0x0405 command: 0x0A payload[0]: 000 22:31:25:859 ZCL attribute report 0x00124B002228CA84 for cluster: 0x0405, ep: 0x01, frame control: 0x18, mfcode: 0x0000 22:31:33:968 Current channel 15 22:31:33:976 Device TTL 5519 s flags: 0x7 22:31:47:732 [INFO] - No button handler for: SML001 endpoint: 0x02 cluster: 0x0402 command: 0x0A payload[0]: 000 22:31:47:732 ZCL attribute report 0x0017880106F4D4F9 for cluster: 0x0402, ep: 0x02, frame control: 0x08, mfcode: 0x0000 22:31:53:383 [INFO] - Button 1002 short 22:32:33:960 Current channel 15 22:32:33:969 Device TTL 5458 s flags: 0x7 22:32:40:047 dev /dev/ttyAMA0 22:32:40:047 GW firmware version: 0x26660700 22:32:40:047 GW firmware version is up to date: 0x26660700 22:33:05:271 [INFO] - No button handler for: RWL021 endpoint: 0x02 cluster: 0x0001 command: 0x0A payload[0]: 021 22:33:05:271 ZCL attribute report 0x0017880106A7F62F for cluster: 0x0001, ep: 0x02, frame control: 0x08, mfcode: 0x0000 22:33:17:495 [INFO] - No button handler for: SML001 endpoint: 0x02 cluster: 0x0402 command: 0x0A payload[0]: 000 22:33:17:495 ZCL attribute report 0x0017880106F4ECA3 for cluster: 0x0402, ep: 0x02, frame control: 0x08, mfcode: 0x0000

Fixed! For some reason when I had added the switch it had created a light group with the same switch ID? I deleted the light group, reloaded the integration and bingo, it worked.

Guys 86th version, any events is not presents :(

Hi guys
I have a SNZB-01 that i try to get to work with the phoscon app, at the moment i use a win10 PC.
For me in deCONZ everything looks fine since the new version 86. In Debugview i see that the events are printed out correct:
[1248] 19:37:50:010 [INFO] - Button 1002 short
[1248] 19:37:52:487 [INFO] - Button 1004 double
[1248] 19:38:00:549 [INFO] - Button 1003 long

In Phoscon the switch is detected but i can not add it to a group

image

image

Does anybody know if the switch is only fully supported for deCONZ but not for Phoscon?

Please check out the Phoscon beta repository for your question. Phoscon is just another REST API client, the switch itself is fully supported.

This device don't have group capabilities, it s possible to make group with it in phoscon ?

I wouldn't place a sure bet on it yet. However, I cannot check it as I don't have any such device.

Was this page helpful?
0 / 5 - 0 ratings