Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tuya ZigBee Multi-Sensor 4 in 1 Smart PIR Motion Feuchtigkeit Licht Temperatur Sensor / TS0202 #4511

Closed
easybeat opened this issue Mar 3, 2021 · 86 comments · Fixed by #4518

Comments

@easybeat
Copy link

easybeat commented Mar 3, 2021

Device

  • Product name: Tuya ZigBee Multi-Sensor 4 in 1 Smart PIR Motion Feuchtigkeit Licht Temperatur Sensor
  • Manufacturer: _TZ3210_zmy9hjay
  • Model identifier: TS0202
  • Device type : Please remove all unrelated device types.
    • Sensor
    • Other: PIR, Temperature, Humidity, Luminance 4in1 sensor
    • Link to product page

Screenshot 2021-03-03 164153

Screenshots

Screenshot 2021-03-03 164739

Screenshot 2021-03-03 164304


Screenshot 2021-03-03 164636
Screenshot 2021-03-03 164616
Screenshot 2021-03-03 164553
Screenshot 2021-03-03 164526
Screenshot 2021-03-03 164508
Screenshot 2021-03-03 164450
Screenshot 2021-03-03 164424
Screenshot 2021-03-03 164358
Screenshot 2021-03-03 164333

Thank you very much for your help.

@Mimiix
Copy link
Collaborator

Mimiix commented Mar 3, 2021

@Smanar

@Smanar
Copy link
Collaborator

Smanar commented Mar 3, 2021

This device have the tuya cluster, but not sure it use it.

@easybeat do you have a real linux machine to test code modification ?

@easybeat
Copy link
Author

easybeat commented Mar 3, 2021

Yes I run deconz on a ubuntu workstation

@Smanar
Copy link
Collaborator

Smanar commented Mar 3, 2021

So here you have the procedure to test code https://github.com/dresden-elektronik/deconz-rest-plugin#install-deconz-development-package-optional-linux-only

sudo apt install deconz-dev
git clone --branch multisensor 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 have just added the device in white list, it use ikea mac adress range ...
There is already a motion sensor with the same model id, so I think your device will react same.

@easybeat
Copy link
Author

easybeat commented Mar 4, 2021

Good morning,

thank you for your immediate support. I will test today at lunch time!

@easybeat
Copy link
Author

easybeat commented Mar 4, 2021

@Smanar
Sorry really beginner on this....I get an error message if I try qmake...

Screenshot 2021-03-04 123705

Do I have to install something else before?

@easybeat
Copy link
Author

easybeat commented Mar 4, 2021

@Smanar

found the problem. Did "sudo apt install build-essential" and then it works

@easybeat
Copy link
Author

easybeat commented Mar 4, 2021

Screenshot 2021-03-04 130228
Screenshot 2021-03-04 130203

I think this did work!!

@easybeat
Copy link
Author

easybeat commented Mar 4, 2021

@Smanar
I did reset the device and joined it in Phoscon and it was successful.

Do I have to check something else?

@Smanar
Copy link
Collaborator

Smanar commented Mar 4, 2021

If you can see it in phoson (and not only deconz), can you just check if all is working ?
Temperature/humidity/motion and luminance ?

It s possible phoscon don't support all device feature, if you can check with third app or directly with the API if needed ?

@easybeat
Copy link
Author

easybeat commented Mar 4, 2021

@Smanar

No I can't see it in Phoscon but did check inside ioBroker with hueExtended Adapter and there all the datapoints are in. A bit strange as it did create 4 devices but that's maybe more a problem from the Adapter.

I also triggered an update on the device and new temperature und humidity etc. came through.

So I really think it's fine.

Thank you very much.

@Smanar
Copy link
Collaborator

Smanar commented Mar 4, 2021

Yep it create 1 devices by endpoint, and 1 by cluster, it s the normal working mode for deconz.
So if all is fine, I can make the PR ?

@easybeat
Copy link
Author

easybeat commented Mar 4, 2021

Yes I think so so...everything ready to go.

@easybeat
Copy link
Author

Yep it create 1 devices by endpoint, and 1 by cluster, it s the normal working mode for deconz.
So if all is fine, I can make the PR ?

Hi Smanar

Just updated to 2.11.01 and now finally paired TS0202 succesfully. Unfortunately small problem. Temperature and Humidity values do not update automatically. If I press read on cluster then the values are updated.

Is there something you can do about it?

Thank you

@Smanar
Copy link
Collaborator

Smanar commented Apr 28, 2021

Can be reporting issue, but all seem fine in the code, it have worked on your first try ?

Just Humidity and Temperature ?
Can you share the Json from thoses 2 entries.

Perhaps a step haven't worked during the inclusion, the set reporting part.

@easybeat
Copy link
Author

Yes it is only Humidity and Temperature which is not working.

I will try to do the inclusion again.

@Smanar
Copy link
Collaborator

Smanar commented Apr 28, 2021

Will be fine if you can catch logs during inclusion in same time with "info" and "info_l2" (but can be hudge, just need all about the cluster 0x0402 and 0x0405, log about reporting or bind)

@easybeat
Copy link
Author

Ok Smanar,

I deleted the device and restarted deconz and the joined it again. It looks wierd now as "lightlevel 71"

image

And also no temperature or humidity comes through.

here is the log-fiel during paring:
deconz 4-1senor-log.txt

Hope this is helping?

@Smanar
Copy link
Collaborator

Smanar commented Apr 29, 2021

17:58:19:493 0x14B457FFFE0BDA59 (TS0202) create binding for attribute reporting of cluster 0x0001 on endpoint 0x01
17:58:19:493 0x14B457FFFE0BDA59 (TS0202) create binding for attribute reporting of cluster 0x0500 on endpoint 0x01
17:58:19:497 0x14B457FFFE0BDA59 (TS0202) create binding for attribute reporting of cluster 0x0001 on endpoint 0x02
17:58:19:498 0x14B457FFFE0BDA59 (TS0202) create binding for attribute reporting of cluster 0x0402 on endpoint 0x02
17:58:19:500 0x14B457FFFE0BDA59 (TS0202) create binding for attribute reporting of cluster 0x0405 on endpoint 0x02
17:58:19:502 0x14B457FFFE0BDA59 (TS0202) create binding for attribute reporting of cluster 0x0001 on endpoint 0x03
17:58:19:503 0x14B457FFFE0BDA59 (TS0202) create binding for attribute reporting of cluster 0x0400 on endpoint 0x03

At least bind seem good ...
Can you check report setting for temperature or humidity ?

Endpoint 0x02
Cluster 0402 or 0405
Attribute 0x0000
double clic on the value, and press" read config" on the new panel (probably need to awake the device.

Value used by deconz are

  • For humidity
        rq.minInterval = 10;
        rq.maxInterval = 300;
        rq.reportableChange16bit = 100; // resolution: 1%
  • For temperature
            rq.minInterval = 10;           // value used by Hue bridge
            rq.maxInterval = 300;          // value used by Hue bridge
            rq.reportableChange16bit = 20; // value used by Hue bridge

Edit:

Ok, I have found the problem, the device use tuya cluster, so perhaps need to enable something before, need to write some code.

@Smanar
Copy link
Collaborator

Smanar commented Apr 29, 2021

Can you try this new code

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

With this code you will have new log starting with "tuya debug", if the code don't work, logs can be usefull.

There is too a command to enable reporting, but idk if this setting is usefull yet, what is the utility to disable a reporting ....

@easybeat
Copy link
Author

Hi

it looks different now but still no luck with temperature and humidity

image

image

Luminance is working but it should also have presence.

Here the log file:
deconz 4-1senor-log2.txt

I did connect this sensor with zigbee2mqtt and attributes created there were as follows:

image

Does this help?

Thanks for help

@Smanar
Copy link
Collaborator

Smanar commented Apr 30, 2021

You don't need to re-include it, the inclusion is fine.
It s just this device don't use classic cluster
Something you can do is looking logs (with "info" and "info-l2"), and try to change the temperature.

You need to see some logs about a cluster 0xFC00 or better logs starting by

Tuya debug 4 : ............
Tuya debug 5 : ............

If you realy see nothing I will make the command to enable reporting

@easybeat
Copy link
Author

easybeat commented May 1, 2021

OK started the dev instance again and now it is showing like this:

image

and the log is here when I read temperature:
deconz 4-1senor-log3.txt

if you search for /sensors/61 then you find the event.

Does this help?

Thanks

@Smanar
Copy link
Collaborator

Smanar commented May 1, 2021

Ok so still nothing about the tuya cluster ..
Have inluded the "reporting" command, on the temperature sensor and (only this one), you will be able to see it in his json, to activate it, need to use the API

curl -H 'Content-Type: application/json' -X PUT -d '{"reporting": true}' http://IP:PORT/api/KEY/sensors/61/config

@easybeat
Copy link
Author

easybeat commented May 1, 2021

Hi

Do I have to rebuild deconz? As I get this error:

[{"error":{"address":"/sensors/62/config/reporting","description":"parameter, reporting, not available","type":6}}]

Thanks

@Smanar
Copy link
Collaborator

Smanar commented May 1, 2021

Yep, like for previous tests, but no need to re-include the device (I think the restart will be enought)

@Smanar
Copy link
Collaborator

Smanar commented May 11, 2021

Yeah, using the GUI permit to learn a lot on zigbee working mode, the app is so usefull for me.

@Smanar
Copy link
Collaborator

Smanar commented May 19, 2021

@easybeat I have a question !
If you disable the reporting using the API {"reporting":false}, it realy disable the reporting ? what can be the utility of this ?

If you are sure of that I will need to make a change. for the command was send natively by deconz during the inclusion.

@easybeat
Copy link
Author

@Smanar No it doesn't make sense to do "reporting:false". Why do you think I would do this?

No need for me.

@Smanar
Copy link
Collaborator

Smanar commented May 19, 2021

it s exactly the manup reaction ^^.

But I don't see the utility of this command, it realy disable TOTALY the reporting for temperature and humidity ?

@Smanar
Copy link
Collaborator

Smanar commented May 22, 2021

@easybeat if you still have your dev machine ?

I have a new branch to test

cd deconz-rest-plugin
git pull
git checkout tuya_sensor_test
git pull
qmake && make -j2
sudo cp ../libde_rest_plugin.so /usr/share/deCONZ/plugins

On this one I have remove the field "config/reporting" as this setting is probably useless, so now the code send itself the command to enable it

To test it, you just need to re-include your device, you will have in log (with "info")

Send Tuya request: Dp_type .................
Tuya device ....... reporting status state ........

@easybeat
Copy link
Author

Do I have to install latest release to do that?

@easybeat
Copy link
Author

e_web_plugin.cpp: In member function ‘virtual bool DeRestPlugin::isHttpTarget(const QHttpRequestHeader&)’:
de_web_plugin.cpp:17615:13: error: ‘const class QHttpRequestHeader’ has no member named ‘pathAt’; did you mean ‘path’?
17615 | if (hdr.pathAt(0) == QLatin1String("api"))
| ^~~~~~
| path
de_web_plugin.cpp:17619:18: error: ‘const class QHttpRequestHeader’ has no member named ‘pathAt’; did you mean ‘path’?
17619 | else if (hdr.pathAt(0) == QLatin1String("description.xml"))
| ^~~~~~
| path
In file included from /usr/include/x86_64-linux-gnu/qt5/QtCore/qcoreapplication.h:43,
from /usr/include/x86_64-linux-gnu/qt5/QtCore/QCoreApplication:1,
from de_web_plugin.cpp:11:
de_web_plugin.cpp: In member function ‘virtual int DeRestPlugin::handleHttpRequest(const QHttpRequestHeader&, QTcpSocket*)’:
de_web_plugin.cpp:17646:81: error: no matching function for call to ‘asString(const QUrl&)’
17646 | DBG_HTTP, "HTTP API %s %s - %s\n", qPrintable(hdr.method()), qPrintable(hdr.url()), qPrintable(sock->peerAddress().toString()));
| ^~~~~~~~~~

In file included from /usr/include/x86_64-linux-gnu/qt5/QtCore/qcoreapplication.h:44,
from /usr/include/x86_64-linux-gnu/qt5/QtCore/QCoreApplication:1,
from de_web_plugin.cpp:11:
/usr/include/x86_64-linux-gnu/qt5/QtCore/qstring.h:1871:23: note: candidate: ‘const QString& QtPrivate::asString(const QString&)’
1871 | inline const QString &asString(const QString &s) { return s; }
| ^~~~~~~~
/usr/include/x86_64-linux-gnu/qt5/QtCore/qstring.h:1871:47: note: no known conversion for argument 1 from ‘const QUrl’ to ‘const QString&’
1871 | inline const QString &asString(const QString &s) { return s; }
| ~~~~~~~~~~~~~~~^
/usr/include/x86_64-linux-gnu/qt5/QtCore/qstring.h:1872:18: note: candidate: ‘QString&& QtPrivate::asString(QString&&)’
1872 | inline QString &&asString(QString &&s) { return std::move(s); }
| ^~~~~~~~
/usr/include/x86_64-linux-gnu/qt5/QtCore/qstring.h:1872:37: note: no known conversion for argument 1 from ‘const QUrl’ to ‘QString&&’
1872 | inline QString &&asString(QString &&s) { return std::move(s); }
| ~~~~~~~~~~^

got these errors

@easybeat
Copy link
Author

OK I have now updated to 2.12.00...could you please assist me how to get your code from there?

@Smanar
Copy link
Collaborator

Smanar commented May 27, 2021

Ha yes, the version is moving a lot ATM.
So need to have last libs version on OS

sudo apt update
sudo apt full-upgrade

Then need to clean the project

cd deconz-rest-plugin
make clean

After that it s classic, if you start from scratch

sudo apt install deconz-dev
git clone --branch tuya_sensor_test https://github.com/Smanar/deconz-rest-plugin.git
cd deconz-rest-plugin

Else

cd deconz-rest-plugin
git pull
git checkout tuya_sensor_test

And to finish

qmake && make -j2
sudo cp ../libde_rest_plugin.so /usr/share/deCONZ/plugins

@easybeat
Copy link
Author

bindings.cpp: In member function ‘void DeRestPluginPrivate::checkLightBindingsForAttributeReporting(LightNode*)’:
bindings.cpp:2581:93: error: conversion from ‘std::vectordeCONZ::ZclCluster::const_iterator’ {aka ‘__gnu_cxx::__normal_iterator<const deCONZ::ZclCluster*, std::vectordeCONZ::ZclCluster >’} to non-scalar type ‘QListdeCONZ::ZclCluster::const_iterator’ requested
2581 | const_iterator i = lightNode->haEndpoint().inClusters().begin();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~

bindings.cpp:2582:93: error: conversion from ‘std::vectordeCONZ::ZclCluster::const_iterator’ {aka ‘__gnu_cxx::__normal_iterator<const deCONZ::ZclCluster*, std::vectordeCONZ::ZclCluster >’} to non-scalar type ‘QListdeCONZ::ZclCluster::const_iterator’ requested
2582 | const_iterator end = lightNode->haEndpoint().inClusters().end();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~

bindings.cpp: In member function ‘bool DeRestPluginPrivate::checkSensorBindingsForAttributeReporting(Sensor*)’:
bindings.cpp:3396:35: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::vectordeCONZ::SimpleDescriptor::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
3396 | for (int j = 0; j < sensor->node()->simpleDescriptors().size(); j++)
| ~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
make[1]: *** [Makefile.Release:617: release/bindings.o] Fehler 1
make[1]: *** Auf noch nicht beendete Prozesse wird gewartet …
make[1]: Verzeichnis „/home/beat/deconz-rest-plugin“ wird verlassen
make: *** [Makefile:42: release] Fehler 2

doesn't like me anymore!!

@Smanar
Copy link
Collaborator

Smanar commented May 27, 2021

doesn't like me anymore!!

Lol, no, don't worry was my fault, the lib was updated but not the branch
Have updated it too

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

@easybeat
Copy link
Author

Now it did work and after re-include the device works as it should...

@Smanar
Copy link
Collaborator

Smanar commented May 28, 2021

Ha nice ^^.
Good news, and now it have no more the config/reporting flag ?
Just by curiosity, can you see the logs

Send Tuya request: Dp_type .................
Tuya device ....... reporting status state ........

when including it ?

@Smanar
Copy link
Collaborator

Smanar commented Jun 2, 2021

@easybeat do you had time to take a look on logs during inclusion ?

@easybeat
Copy link
Author

easybeat commented Jun 2, 2021

No sorry...not yet...will try tomorrow morning

@easybeat
Copy link
Author

easybeat commented Jun 4, 2021

@Smanar Hi
Ok I deleted the device and reincluded it again. Here is the log file:

deconz 4-1senor-log8.txt

I haven't found an entry about "reporting status".

There are a lot of these entries:
Tuya debug 7 : Missing manufacture name, till missing in DB.
13:10:11:837 Tuya debug 7 : Missing manufacture name for 0x14b457fffe0bda59

Does that help?

Thanks

@Smanar
Copy link
Collaborator

Smanar commented Jun 4, 2021

Yep, thx a lot

13:10:12:210 Send Tuya request: Dp_type: 0x01, Dp_identifier 0x70, data: 01

So deconz have send the request, but the device haven't answer.
I can be wrong somewhere, or the device can just have skipped the command.

Have modified the code again, but not sure will be usefull to test it again, I will make the PR with it, your device is working, so the command is probably not needed. When you include it, you reset setting.

@easybeat
Copy link
Author

@Smanar
Do you need me to do something else?

I can confirm the device is working for me.

Thanks for help.

@Smanar
Copy link
Collaborator

Smanar commented Jun 17, 2021

Nope, thx, I m waiting for PR validation, but I have just see I need to upate it first.

@easybeat
Copy link
Author

Hi Smanar

did this ever go into "production"? Not sure if it's in 2.12.6?

Kind regards and Thanks

@Smanar
Copy link
Collaborator

Smanar commented Oct 10, 2021

I think he is in the stable no ? I don't find PR in waiting list about it.
Your device is the "_TZ3210_zmy9hjay" ?

@easybeat
Copy link
Author

easybeat commented Oct 10, 2021 via email

@easybeat
Copy link
Author

easybeat commented Nov 6, 2021

Hi

Ok sensor is working and reporting correctly all values! Model is "_TZ3210_zmy9hjay".

But tried to connect a second sensor to the system. It works but the first sensor disappears in deconz gui. I can still see it in the API. Also it shows as "LightLevel15" all the time. The sensors also do not show up in Phoscon App. Is this something you can fix?

Kind regards
Beat

@Smanar
Copy link
Collaborator

Smanar commented Nov 6, 2021

But tried to connect a second sensor to the system. It works but the first sensor disappears in deconz gui

You mean including a second device will delete the first one on the GUI ?

The device was correclty included ? have the 2 circle on th node title ? Not possible a node is deleted if it was correclty included, disconnected ok, but deleted ....

The sensors also do not show up in Phoscon App

This don't depend of the API, Phoscon use white/black list.

@easybeat
Copy link
Author

easybeat commented Nov 6, 2021

Hi

I think it was a problem on my system...I deleted the first sensor completely in deconz and re-added it. Now I've added 2 more sensors and everything is fine!

Screenshot 2021-11-06 151624

Thanks for help!

@easybeat
Copy link
Author

easybeat commented Nov 6, 2021

I think it takes several minutes until the sensor is completely configured and all reports did run once. Now also the little battery is showing on the 4th sensor
Screenshot 2021-11-06 151922

@Smanar
Copy link
Collaborator

Smanar commented Nov 6, 2021

several minutes

Hur several hours will be better, thoses devices are not called sleeping device for nothing ^^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants