dresden-elektronik / deconz-rest-plugin

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

[Device Support Request] Zemismart 3 Gang Remote Switch (2nd attempt) #3524

Closed stevewull closed 3 years ago

stevewull commented 3 years ago

Device

Listed here: https://zigbee.blakadder.com/Zemismart_ZM-ZS3.html

Purchased here: https://www.aliexpress.com/item/4000460643839.html?aff_platform=link-c-tool&cpt=1579460387259&sk=_sPA71V&aff_trace_key=1ea588879adf4a71b69472fcc8469bea-1579460387259-01187-_sPA71V&terminal_id=5ab3b3bf703c438dac102dcfef054d7e

I have the three gang version

Screenshots

image

image

Switch 01:

image

image

image

image

image

Switch 02: image

image

Switch 03: image

image

Smanar commented 3 years ago

Hello, so I have made a mistake on PR and removed a part of code, can you try this code pls.

To test it, you need an Unix OS, and take a look here https://github.com/dresden-elektronik/deconz-rest-plugin#install-deconz-development-package-optional-linux-only with a modification for step 1

git clone --branch tuya 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
stevewull commented 3 years ago

Thanks Smanar,

I will try to set up a test environment. I have done this in the past. This has caused problems as I only have one Conbee and have to bring down the production environment. Some of the devices get confused and have trouble pairing properly when I try to restore them to production.

Smanar commented 3 years ago

If you have an unix machine, no danger, just make a backup of the file lib (in other folder), and you just need 10s to rollback, the code don't change anything to c,onfig.

stevewull commented 3 years ago

Hi Smanar, I now have a Pi4 running the stable version of deConz that I can use for testing. You provided a link with instructions but I am not quire sure where to start.

Should I uninstall the stable version of deconz? Should I start with the line that installs deconz-dev?

Smanar commented 3 years ago

Hello, no depend of the deconz version you have, but there is a major modification on deconz core for button gestion (use now a json file), so I think it s better if you can install the last beta (if you have no issue with it)

Then after yes https://github.com/dresden-elektronik/deconz-rest-plugin#install-deconz-development-package-optional-linux-only

So it will be for you

sudo apt install deconz-dev
git clone --branch tuya 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

If you want to avoid re-installation, you can make a backup of the file "libde_rest_plugin.so", in another folder, so if you have problem, the rollback just take 30s.

stevewull commented 3 years ago

Thanks for the instructions. Test environment is working using your branch for the plug-in.

The Zemismart switch now appears in the Phoscon App as three "On/Off lights."

I think they are supposed to act like a switch with each of the three buttons having single press, long press, and hold.

Smanar commented 3 years ago

Sorry my bad, was wired device in my mind. I have corrected the code to use them as wirelesss device now

Pls make a new try, will be faster

cd deconz-rest-plugin
git pull
qmake && make -j2
sudo cp ../libde_rest_plugin.so /usr/share/deCONZ/plugins
stevewull commented 3 years ago

Ok. I loaded your new code. Not sure exactly what to check for testing.

Each of the three buttons still show up in Phoscon App as an on/off light.

Smanar commented 3 years ago

You have deleted them, before the new inclusion ?

Smanar commented 3 years ago

Ok I think I have found the problem, the tuya hack was working if you have only 1 endpoint, can you make another try pls ?

stevewull commented 3 years ago

Hi Sameer, I performed a new git pull and compiled your code. I launched deConz and, using Phoscon app, removed the switch from deConz.

I then put the switch in pairing mode. The Phoscon app does not detect or display when I choose add new lights, switches, or sensors.

However, the switch is visible as a node in the deConz gui, not connected to other nodes. The light on the switch continues to flash indicating that it did not leave pairing mode. I see the cluster info for three different on/off switches.

Separately, I connected the switch to a non-deConz controlled Zigbee network. This also detected the three clusters as on/off switches. I didn't see a way to detect single press, long press, hold.

Smanar commented 3 years ago

Can you make a try.

The device will to be visible in sensor part but invisible in phoscon.

Smanar commented 3 years ago

I m sorry but I need to finalize the code sunday if I want it be in next beta. There is no one that can try the code ? On "tuya" branch or "tuya_pr" (based on last code possible)

I just need to know if the "switches group" is working (mean all buttons are working in the same entry), else I will make a roolback to have 1 sensor device by endpoint.

Mimiix commented 3 years ago

@Smanar release will be today.

stevewull commented 3 years ago

testing now

stevewull commented 3 years ago

When you say "device will be visible in sensor part". Do you mean in the API?

stevewull commented 3 years ago

I performed a git pull from the Tuya branch listed above. The switch shows up in the sensors section of the API. Three entries.

"2": {
  "config": {
    "battery": 95,
    "on": true,
    "reachable": false
  },
  "ep": 1,
  "etag": "a3a55398dd4805c633e6d0d75e201e70",
  "lastseen": null,
  "manufacturername": "_TZ3400_key8kk7r",
  "mode": 1,
  "modelid": "TS0043",
  "name": "TS0043 2",
  "state": {
    "buttonevent": 1002,
    "lastupdated": "2020-11-10T04:31:17.116"
  },
  "type": "ZHASwitch",
  "uniqueid": "60:a4:23:ff:fe:a0:f1:30-01-0006"
},
"3": {
  "config": {
    "battery": 95,
    "on": true,
    "reachable": false
  },
  "ep": 2,
  "etag": "a3a55398dd4805c633e6d0d75e201e70",
  "lastseen": null,
  "manufacturername": "_TZ3400_key8kk7r",
  "mode": 1,
  "modelid": "TS0043",
  "name": "TS0043 3",
  "state": {
    "buttonevent": 2002,
    "lastupdated": "2020-11-10T04:31:21.146"
  },
  "type": "ZHASwitch",
  "uniqueid": "60:a4:23:ff:fe:a0:f1:30-02-0006"
},
"4": {
  "config": {
    "battery": 95,
    "on": true,
    "reachable": false
  },
  "ep": 3,
  "etag": "a3a55398dd4805c633e6d0d75e201e70",
  "lastseen": null,
  "manufacturername": "_TZ3400_key8kk7r",
  "mode": 1,
  "modelid": "TS0043",
  "name": "TS0043 4",
  "state": {
    "buttonevent": 3003,
    "lastupdated": "2020-11-10T04:31:48.870"
  },
  "type": "ZHASwitch",
  "uniqueid": "60:a4:23:ff:fe:a0:f1:30-03-0006"
}

} }

Smanar commented 3 years ago

@Mimiix I have ask manup, I have until tonight.

@stevewull It s strange, on other issue the user have the 3 entries grouped with the same code, BTW if it s working it s the principal, thx.

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.

petosak commented 3 years ago

Anybody knows how to change and use as a button? image HA recognize as switch but never switched anything

Smanar commented 3 years ago

You have a battery device ? I don't know HA, the 3 "3 button No 1" are "light" ? If yes, there is a problem, don't delete your device but remake inclusion, you need to have a field that use "buttonevent"

petosak commented 3 years ago

I have exactly same 3button controller as in this case: https://github.com/dresden-elektronik/deconz-rest-plugin/issues/3220 Each button can do different things. I thought that i'll can use push/hold/click for each button for action in HA.... What you mean "remake inclusion"? How can i do that?

Smanar commented 3 years ago

Ok is the battery powered one, you nned to have a sensor entry with "buttonevent". Just re-pair (or re-include) the device but without deleting the old entry.

petosak commented 3 years ago

I still can't see events as in Aqara. Still see only On/Off for every 3 buttons. Is it right? On right side is one button 3state Aqara. image

Smanar commented 3 years ago

Not normal at all, you haven't 0x0006 cluster so to have on/off .... Can you find the complete device JSON somewhere ? (On deconz logs for exemple)

petosak commented 3 years ago

do you mean this?: { "config": { "battery": 100, "on": true, "reachable": true }, "ep": 1, "etag": "bdeab4a89df6691c0dd5acbe0d8b38b0", "lastseen": "2020-12-21T19:33Z", "manufacturername": "_TZ3000_bi6lpsew", "mode": 1, "modelid": "TS0043", "name": "TS0043", "state": { "buttonevent": 1002, "lastupdated": "2020-12-21T09:57:57.397" }, "type": "ZHASwitch", "uniqueid": "5c:02:72:ff:fe:c2:43:78-01-0006" }

Smanar commented 3 years ago

Yep exactly. And I don't understand how you can have this display on HA ! There is no on/off entries, it s not you that have configured something ?

To use this device, you need to use the field "buttonevent", atm it s 1002, if you press another button, the value will change.

petosak commented 3 years ago

I understand you. But HA gives me 3x switch which is not meaningfull image I can't make automation on buttonevent....(via GUI) Only when switch is changed image

stevewull commented 3 years ago

I have the exact same issue using the battery device. Plan to use this in Home Assistant. Each of the three buttons shows up as an on/off light in HA.

I had given up. Will make another attempt to detect button events.

Steve

Smanar commented 3 years ago

You can have 3 lights created by error during inclusion ( and you can remove them in API) But they are not usable, you need to use the device with name "TS0043" for you. (it s the one it have on json) The only working field for battery device is always buttonevent for this kind of tuya device. on/off are generaly for wired switches.

clovisdivay commented 3 years ago

I have the same issue with this product I just purchased (it seems to be a rebrand of the same switch) : https://fr.aliexpress.com/item/1005001687942333.html?spm=a2g0s.9042311.0.0.4e3d6c375gipch

I hope you will be able to make it work :)

Smanar commented 3 years ago

Do you have the basic info panel, and the basic attribute ? Tuya stuff can be different

clovisdivay commented 3 years ago

Hi. I took screen captures of everything I could find. It's the first time I open the deCONZ app to find info so maybe I don't have everything you need, sorry. I also won't be able to test any beta versions as I use an integrated version of deCONZ in Home Assistant (https://www.home-assistant.io/integrations/deconz/) so I hope it will be enough.

Thanks for your help !

Switches : switches

Node Info : node_info

Basic Cluster Info : basic_cluster_info

Power Configuration Cluster Info : pc_cluster_info

On/Off Cluster Info : on_off_cluster_info

OTAU Cluster Info : otau_cluster_info

Time Cluster Info : time_cluster_info

Mimiix commented 3 years ago

Manufact name being empty? That's a new one.

Smanar commented 3 years ago

Yep this device seem present on the code

{ VENDOR_EMBER, "TS0043", silabs7MacPrefix }, // Tuya wireless switch

Iike have said Mimix, you can check the manufacture name again (it faild sometime), you NEED to have one of those


                    else if ((sensorNode->manufacturer() == QLatin1String("_TZ3000_bi6lpsew")) ||
                        (sensorNode->manufacturer() == QLatin1String("_TZ3400_keyjhapk")) ||
                        (sensorNode->manufacturer() == QLatin1String("_TYZB02_key8kk7r")) ||
                        (sensorNode->manufacturer() == QLatin1String("_TZ3400_keyjqthh")) ||
                        (sensorNode->manufacturer() == QLatin1String("_TZ3400_key8kk7r")) ||
                        (sensorNode->manufacturer() == QLatin1String("_TZ3000_vp6clf9d")) ||
                        (sensorNode->manufacturer() == QLatin1String("_TYZB02_keyjqthh")))

If you haven't it, the API can't reconize it, but if you can see it in deconz, the API can use deconz value to help for inclusion.

But your problem is a problem to include it ?

petosak commented 3 years ago

Yep this device seem present on the code

{ VENDOR_EMBER, "TS0043", silabs7MacPrefix }, // Tuya wireless switch

Iike have said Mimix, you can check the manufacture name again (it faild sometime), you NEED to have one of those


                    else if ((sensorNode->manufacturer() == QLatin1String("_TZ3000_bi6lpsew")) ||
                        (sensorNode->manufacturer() == QLatin1String("_TZ3400_keyjhapk")) ||
                        (sensorNode->manufacturer() == QLatin1String("_TYZB02_key8kk7r")) ||
                        (sensorNode->manufacturer() == QLatin1String("_TZ3400_keyjqthh")) ||
                        (sensorNode->manufacturer() == QLatin1String("_TZ3400_key8kk7r")) ||
                        (sensorNode->manufacturer() == QLatin1String("_TZ3000_vp6clf9d")) ||
                        (sensorNode->manufacturer() == QLatin1String("_TYZB02_keyjqthh")))

If you haven't it, the API can't reconize it, but if you can see it in deconz, the API can use deconz value to help for inclusion.

But your problem is a problem to include it ?

My battery powered has this: image But still is as 3x on/off switch that doesn't make sense....

clovisdivay commented 3 years ago

@Smanar I once managed to get a manufactor name, which was _TZ3400_key8kk7r. But now every time I try to apair it, it shows nothing...

Smanar commented 3 years ago

@petosak yes can be normal, this device create normally 3 switches (visibles as lights), deconz create a sensor device and try to prevent the switches creation. But It can faild so you will have the 3 switches + the sensor, only the sensor is usable.

The procedure can need 2 inclusion, the first one to have the manufacture name to reconize the device, and the second one to create the sensor and block the switches creations.

Take a look in the sensors part if you haven't a new device ?

@clovisdivay where are you looking ? in deconz , phoscon or third app ? If you are in deconz, you can't faild.

You can avoid the creation of the 3 bad switches if you set phoscon in permit join beetween the 2 attributes asking.

Remember you need to wake up the device when sending command.

petosak commented 3 years ago

@Smanar i'm not sure what you mean: Take a look in the sensors part if you haven't a new device ? But i can catch events in HASSIO: Event 9 fired 9:37 PM: { "event_type": "deconz_event", "data": { "id": "ts0043", "unique_id": "5c:02:72:ff:fe:c2:43:78", "event": 2002, "device_id": "c46838e8661a564b792a8c11de56b9f2" }, "origin": "LOCAL", "time_fired": "2021-01-05T20:37:13.331299+00:00", "context": { "id": "fb89f6a405497727d3a5d847bb250966", "parent_id": null, "user_id": null } } Event 8 fired 9:37 PM: { "event_type": "deconz_event", "data": { "id": "ts0043", "unique_id": "5c:02:72:ff:fe:c2:43:78", "event": 2002, "device_id": "c46838e8661a564b792a8c11de56b9f2" }, "origin": "LOCAL", "time_fired": "2021-01-05T20:37:12.323096+00:00", "context": { "id": "fee5a52c82f85c68fd4a70dbceacc849", "parent_id": null, "user_id": null } } I don't know why two times, but it's usable now. In Phoscon i can see 3x light: image

image I really appreciate your help.

Smanar commented 3 years ago

But light are not working if I m right (and can be removed using api command), you need to use the event to use this device.

"event": 2002,

2002 mean you have used the second button. But I suspect you have the double event problem.

petosak commented 3 years ago

Yes. You're right. Lights not working. I know how to use events. I meant that i see 2 events on one push button. On every one push/click/hold i get 2 events. I can see only diffent id. I don't know why, but it works.

Smanar commented 3 years ago

It s not your fault ^^. I m still searching why this double event, in my mind was the pooling, but if you have the problem for other event, for me it s realy 2 command send by the device. And I don't understand why some users don't have the problem.

clovisdivay commented 3 years ago

@Smanar Okay I did what you asked, now I have the manufacturer's name. I don't have the 3 switches in Phoscon (I removed them before doing what you told me), but I don't have anything now... Maybe I should start over ? Should I reset the switch to factory settings and start the process over ?

image

Smanar commented 3 years ago

All seem fine. If you realy have nothing in sensor (not in light), in your third app, the sensor can be invisible in phoscon. Just set phoscon in permit join (add new sensor/light), and read again the basic attribute (a second time), deconz already know the manufacture name, so you will not have the light creation, but you need have the sensor one. Else can you show the log during the inclusion ?

clovisdivay commented 3 years ago

Okay it seems to work now, though it is still invisible in Phoscon (not a big deal for me).

I also have the "double event" issue.

Thanks for your help ! :)

Smanar commented 3 years ago

@clovisdivay I don't think it will change something, but can you show me the long during the double event too pls. On deconz / help with debug log 'info" and "info_l2"

clovisdivay commented 3 years ago

INFO : image

For INFO_l2, there is too much going on in the log, I don't know what would be of interest for you. What should I be looking for ?

Smanar commented 3 years ago

Right, hard to see something usefull. If I add some debug line in code, are you able to recompile it to test it ?

clovisdivay commented 3 years ago

Sorry, no :( I use deconz as a plugin in Home Assistant (I think it uses pydeconz) and I can't chose the version.

Flow-tech-lab commented 3 years ago

Yep this device seem present on the code

{ VENDOR_EMBER, "TS0043", silabs7MacPrefix }, // Tuya wireless switch

Iike have said Mimix, you can check the manufacture name again (it faild sometime), you NEED to have one of those


                    else if ((sensorNode->manufacturer() == QLatin1String("_TZ3000_bi6lpsew")) ||
                        (sensorNode->manufacturer() == QLatin1String("_TZ3400_keyjhapk")) ||
                        (sensorNode->manufacturer() == QLatin1String("_TYZB02_key8kk7r")) ||
                        (sensorNode->manufacturer() == QLatin1String("_TZ3400_keyjqthh")) ||
                        (sensorNode->manufacturer() == QLatin1String("_TZ3400_key8kk7r")) ||
                        (sensorNode->manufacturer() == QLatin1String("_TZ3000_vp6clf9d")) ||
                        (sensorNode->manufacturer() == QLatin1String("_TYZB02_keyjqthh")))

If you haven't it, the API can't reconize it, but if you can see it in deconz, the API can use deconz value to help for inclusion.

But your problem is a problem to include it ?

Hello @Smanar, first of all, thank you all the work on these Tuya switches!

I have a Zemismart 3gang switch and tried everything you described, but never saw the sensor in the Rest API.

Might it be because of the manufacturer name? Mine is "_TZ0300_qzjcsmar", which is not in your list. Model identifier is correct, TS0043.