dresden-elektronik / deconz-rest-plugin

deCONZ REST-API plugin to control ZigBee devices
BSD 3-Clause "New" or "Revised" License
1.88k stars 485 forks source link

Sonoff SNZB-01 #2990

Closed madman2143 closed 3 years ago

madman2143 commented 4 years ago

Device

image image

madman2143 commented 4 years ago

Product Page: https://sonoff.tech/product/smart-home-security/snzb-01

SwoopX commented 4 years ago

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

madman2143 commented 4 years ago

Sorry, I'm new to this!

Are you talking about this? image

NovaGL commented 4 years ago

Any update on this. Do you need more information?

lbouriez commented 4 years ago

Very interested on this switch

stale[bot] commented 3 years ago

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.

stale[bot] commented 3 years ago

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.

SAOPP commented 3 years ago

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?

SAOPP commented 3 years ago

image

SAOPP commented 3 years ago

image

Smanar commented 3 years ago

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 ?

SAOPP commented 3 years ago

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

Smanar commented 3 years ago

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
bonelessc commented 3 years ago

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

Smanar commented 3 years ago

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

NovaGL commented 3 years ago

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

pippo73 commented 3 years ago

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

Smanar commented 3 years ago

@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
NovaGL commented 3 years ago

How do I install qmake?

Smanar commented 3 years ago

You have tested sudo apt install deconz-dev

NovaGL commented 3 years ago

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

NovaGL commented 3 years ago

I tried I built it on ubuntu but get login failed

pippo73 commented 3 years ago

Yes @Smanar I'm talking about the motion sensor

SAOPP commented 3 years ago

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?

NovaGL commented 3 years ago

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.

Smanar commented 3 years ago

@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.

NovaGL commented 3 years ago

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.

SAOPP commented 3 years ago

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

NovaGL commented 3 years ago

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.

SAOPP commented 3 years ago

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

Smanar commented 3 years 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.

NovaGL commented 3 years ago

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.

pippo73 commented 3 years ago

@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

NovaGL commented 3 years ago

I moved to zigbee2mqtt and these devices are working flawlessly

Mimiix commented 3 years ago

@NovaGL This is not a proper solution 😉

Mimiix commented 3 years ago

@Smanar Do we need to re-open this?

NovaGL commented 3 years ago

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.

SwoopX commented 3 years ago

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

NovaGL commented 3 years ago

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

SAOPP commented 3 years ago

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

SwoopX commented 3 years ago

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.

NovaGL commented 3 years ago

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

Smanar commented 3 years ago

@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

Jimmy-SafeCash commented 3 years ago

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

Smanar commented 3 years ago

It s not tested yet ^^

Jimmy-SafeCash commented 3 years ago

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.

Smanar commented 3 years ago

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

Jimmy-SafeCash commented 3 years ago

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.

jdonofrio728 commented 3 years ago

@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
NovaGL commented 3 years ago

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