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 Smart Plug missing metering data (_TZ3000_cphmq0q7) #4838

Closed
muratcorlu opened this issue May 5, 2021 · 177 comments · Fixed by #5206
Closed

Tuya Smart Plug missing metering data (_TZ3000_cphmq0q7) #4838

muratcorlu opened this issue May 5, 2021 · 177 comments · Fixed by #5206
Labels
Device Improvement Additional tag to attach to a existing issue. Device Request

Comments

@muratcorlu
Copy link

muratcorlu commented May 5, 2021

Describe the bug

I bought 4 Tuya Zigbee smart plugs and easily connected to Phoscon (running with Conbee II on Rpi4). I use them on my HomeKit setup via Homebridge. One of them worked perfectly with metering functionality but 3 of them doesn't report metering data. Working one has _TZ3000_8nkb7mof vendor name and others has _TZ3000_cphmq0q7.

Steps to reproduce the behavior

  1. Start pairing a smart plug with _TZ3000_cphmq0q7 vendor name.
  2. Pair with with Phoscon GW
  3. Restart HomeBridge
  4. Check if you have consumption data on Eve Home app. (Or in HomeAssistant)

Expected behavior

I expect to see consumption data on Eve Home App or HomeAssistant.

Screenshots

Here is the list of devices in Phoscon App:

image

Detail screen of working one:

image

Detail screen of one of the non working devices (be aware this has version info):

image

Eve Home screenshot of working device:

image

Eve Home screenshot of one of the non-working devices:

image

Environment

  • Host system: Raspberry Pi
  • Running method: Raspbian / HomeBridge / homebridge-hue plugin / Eve Home App
  • Firmware version: 266b0700
  • deCONZ version: 2.10.04
  • Device: ConBee II
  • Do you use an USB extension cable: no
  • Is there any other USB or serial devices connected to the host system? If so: P1 adapter, USB Bluetooth

deCONZ Logs

I use headless deconz. I currently couldn't figure out how to fetch debug logs. I'll update if I can.

Additional context

@NijsKei
Copy link

NijsKei commented May 19, 2021

I have exactly the same problem. Why it always must be difficult. 2 are working well a 2 are working not. Only the switches are doing their job but no measering.

@Mimiix Mimiix added Device Improvement Additional tag to attach to a existing issue. Device Request and removed Bug report labels May 19, 2021
@Mimiix
Copy link
Collaborator

Mimiix commented May 19, 2021

Unfortunately,this is the downside of having cheaper devices.

The support was added to the one that works. The others have new chips/manufacturer names. That needs to be whitelisted.

Can you provide screenshots from deconz as a device request?

@oywino
Copy link

oywino commented May 19, 2021

I have exactly the same problem.
Setup:
Conbee Firmware: 266B0700
deConz Version: 2.11.02 beta / 4/30/2021

Device is registered in Phoscon as a Light. No measuring data is present. On/Off works fine.
Here are my deConz screen dumps:

image

image

image

On/Off Cluster:
image

Simple Metering Cluster:
image

image

REST-API:

{
    "etag": "db47fd907f3381714dc29b86101ac2f3",
    "hascolor": false,
    "lastannounced": null,
    "lastseen": "2021-05-19T18:38Z",
    "manufacturername": "_TZ3000_cphmq0q7",
    "modelid": "TS011F",
    "name": "On/Off Tuya 1",
    "state": {
        "alert": "none",
        "on": true,
        "reachable": true
    },
    "swversion": "67",
    "type": "On/Off plug-in unit",
    "uniqueid": "84:71:27:ff:fe:8d:96:1d-01"
}

When I manually press the button on the device ( from On --> Off ) I get this event:

{
    "20:50:43:832": {
        "attr": {
            "id": "18",
            "lastseen": "2021-05-19T18:50Z",
            "manufacturername": "_TZ3000_cphmq0q7",
            "modelid": "TS011F",
            "name": "On/Off Tuya 1",
            "swversion": "67",
            "type": "On/Off plug-in unit",
            "uniqueid": "84:71:27:ff:fe:8d:96:1d-01"
        },
        "e": "changed",
        "id": "18",
        "r": "lights",
        "t": "event",
        "uniqueid": "84:71:27:ff:fe:8d:96:1d-01"
    },
    "20:50:43:873": {
        "e": "changed",
        "id": "18",
        "r": "lights",
        "state": {
            "on": false,
            "reachable": true
        },
        "t": "event",
        "uniqueid": "84:71:27:ff:fe:8d:96:1d-01"
    }
}

@Smanar
Copy link
Collaborator

Smanar commented May 19, 2021

For me the code is blocking for the reason exposed by @muratcorlu, the device have

  • No support attribute 0x4000
  • Empty value for 0x0006

And the code don't like that, there is a hack for light device but not for sensor.
There is many way to help

Ugly one like

        if (node->nodeDescriptor().manufacturerCode() == VENDOR_SAMJIN)
        {
            swBuildIdAvailable = false; // empty string
            dateCodeAvailable = false; // unsupported attribute
        }
        else if (modelId == QLatin1String("HG06323")) // LIDL Remote Control
        {
            swBuildIdAvailable = false; // unsupported attribute
            dateCodeAvailable = false; // empty string
        }

But for me it s possible with using dateCode.isNul(), but in this situation we will have swversion with null value.

Need to ask first the autorisation at others devs.

@oywino
Copy link

oywino commented May 19, 2021

@Smanar, thanks for stepping in - but what you just said is "gibberish" to me. Could you "translate" it into layman's English? 😊

@Smanar
Copy link
Collaborator

Smanar commented May 20, 2021

Lol.
I have a code to test

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

This code (if it work) try to get the Swbuild, then the date code and finaly the Application version to fill the "swversion" field.

You will have in log with "info"

DBG_Printf(DBG_INFO, "[4.1] Get sw build id\n");
DBG_Printf(DBG_INFO, "[4.1] Get date code\n");
DBG_Printf(DBG_INFO, "[4.1] Get Application version\n");

And after the device will be included.

@oywino
Copy link

oywino commented May 20, 2021

Sorry, I don't understand.
The issue in this thread is: Tuya Smart Plug missing metering data (_TZ3000_cphmq0q7)
That is my problem too.
Is your "code" going to solve this problem if your "test" is successful ?

@muratcorlu
Copy link
Author

@oywino Smanar has a fix on his/her fork and asks for test it if it fixes our problem.

But I also couldn't understand this part:

This code (if it work) try to get the Swbuild, then the date code and finaly the Application version to fill the "swversion" field.

@Smanar What is swbuild?

@oywino
Copy link

oywino commented May 20, 2021

swbuild is Software Build number, I guess.
I'd love to test whatever it is @Smanar want us to test, but I have no clue how to do this.
Is it possible to prove a step-by-step in human understandable terms ? 😊
sudo apt install deconz-dev
isn't something I can do on my system. I have deconz running in a docker container and it needs a ton of environment variables set correctly in order to run at all.

@Smanar
Copy link
Collaborator

Smanar commented May 21, 2021

Sorry.

To make short, the deconz code ATM, prevent sensor creation for device without "swbuild", it s a field visible in the Json.
By defaut it s the attribute 0x4000, visible on capture on first post, if this attribute is not available, the code take the datacode (0x0006) but for this device the value is empty, so the code stop here.
With my change it will use the application version.

The procedure is explained here https://github.com/dresden-elektronik/deconz-rest-plugin#install-deconz-development-package-optional-linux-only

But you need a linux OS with full OS, I can't explain how to do on docker.

@oywino
Copy link

oywino commented May 21, 2021

Ok, I see.
But what did @Mimiix mean when he wrote that "It needs to be whitelisted" ?
I was hoping that meant that a quick-fix was imminent.... 😢

@Smanar
Copy link
Collaborator

Smanar commented May 21, 2021

And not sure my fix will work too ^^.
In all situation, we realy need a test, and for that we need you, we haven't the device.

@oywino
Copy link

oywino commented May 22, 2021

I would need another ConBee dongle and a test system to do this. ANd I don't have that. My existing set up is a productions system that I cannot take down. It would be easier for me to send a device to you.
But it would be nice if @Mimiix would join us again and clarify his opinion.

@Smanar
Copy link
Collaborator

Smanar commented May 22, 2021

Don't worry, you are not alone with this bug.
No one here have the device, the problem, and a linux machine ?

@Mimiix
Copy link
Collaborator

Mimiix commented May 22, 2021

@oywino where do you need my opinion on?

@oywino
Copy link

oywino commented May 23, 2021

@oywino where do you need my opinion on?

Hi @Mimiix , you wrote (if I understood correctly) that all that was needed was to whitelist the device (?)
#4838 (comment)

I was hoping that this could turn out to be an easy fix ?

@Mimiix
Copy link
Collaborator

Mimiix commented May 23, 2021

@oywino where do you need my opinion on?

Hi @Mimiix , you wrote (if I understood correctly) that all that was needed was to whitelist the device (?)
#4838 (comment)

I was hoping that this could turn out to be an easy fix ?

Well that's what I thought. But @Smanar says it isn't that easy, so I'm with him on this one. I'm not a developer so I can't change anything about this unfortunately.

@oywino
Copy link

oywino commented May 23, 2021

Well that's what I thought. But @Smanar says it isn't that easy, so I'm with him on this one. I'm not a developer so I can't change anything about this unfortunately.

Ok, I see.
@Smanar - are you a developer (maintainer) ?
I wish I could be of any help....

@Smanar
Copy link
Collaborator

Smanar commented May 23, 2021

For the moment need someone with the device, with the issue and with a linux machine to test the code modification.

@oywino
Copy link

oywino commented May 23, 2021

I guess a "linux machine" can be arranged by simply installing Linux on a laptop. Which Linux do you recommend, and what would be the preferred installation config?

@Smanar
Copy link
Collaborator

Smanar commented May 24, 2021

I think all Linux version are supported, I have see some issues with dev package not found for some X64 but I think now it s corrected.
There is that in doc

Ubuntu
Supported Ubuntu versions

    Ubuntu 16.04 LTS 64-Bit PC (AMD64)
    Ubuntu 18.04 LTS 64-Bit PC (AMD64)
    Ubuntu 20.04 LTS 64-Bit PC (AMD64)

Classic install, not "light" "custom", headless (the desktop can be usefull for debugging) or docker.

@oywino
Copy link

oywino commented May 24, 2021

Ok, I need to find one more ConeBee II because I cannot disconnect the one I have in production.
I hope setting up two ConBee coordinators in my house isn't going to cause any problems (interference) with my existing network (?)

@Smanar
Copy link
Collaborator

Smanar commented May 24, 2021

No, no danger, but just to make test, idk what is managed by your zigbee network, but you can just unplug the conbee from your production machine, make the test, and replug it.
You just need 2 mn to check if the code is working (if you have the sensor or not), and 15 mn to test it.

@oywino
Copy link

oywino commented May 24, 2021

Ok, do you have step-by-step on how to install and config deConz on Ubuntu 20.04 (inkluding links)?

@Smanar
Copy link
Collaborator

Smanar commented May 24, 2021

Yep, first update the OS then

https://phoscon.de/en/conbee2/install#ubuntu

Then after with command line

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

@oywino
Copy link

oywino commented May 24, 2021

Should I do all this first:

image

@oywino
Copy link

oywino commented Oct 19, 2021

BTW you haven't enabled DDF file yet ?
No. Not as far as I know.

@Smanar
Copy link
Collaborator

Smanar commented Oct 21, 2021

Have you tried to include it using the GUI ?

  • delete the node
  • set phoscon in permit join "add new light"
  • read basic attribute in deconz (cluster 0x0000 button "read") or node descriptor (the menu appear on clic on the first circle in node title) if needed, to trigger an inclusion

If deconz don't display 5 endpoints, no reason to have them in the API ....

@oywino
Copy link

oywino commented Oct 22, 2021

Have you tried to include it using the GUI ?

By "GUI" I suppose you mean Phoscon ?
And yes, I deleted the node in deConz
I used "Add new light" in Phoscon
And when the node appeared on deConz, (only a single node), I read the basic cluster.

It still comes up with 5 endpoints in both Phoscon and Home Assistant, but not in deConz.

@Smanar
Copy link
Collaborator

Smanar commented Oct 22, 2021

Nope the GUI mean on desktop (with the application), phoscon is a webapp.

It still comes up with 5 endpoints in both Phoscon and Home Assistant, but not in deConz.

Ok, it s realy a mystery, can you take some log with "info" and "info_l2" during the inclusion ?

@oywino
Copy link

oywino commented Oct 22, 2021

What does "inclusion" mean?
Do mean pairing?

@Smanar
Copy link
Collaborator

Smanar commented Oct 22, 2021

Yep

@oywino
Copy link

oywino commented Dec 10, 2021

I was uncertain where to post, so I did it here:
#5334

@karsie1994
Copy link

Hello all,

Today I tried adding the mentioned switch/sensor to Deconz and showup to my Home Assistant frontend. However only the switch/plug is displayed. No information is shared about power consumption. I can however see the power consumption in the cluster information in Deconz.

It also appears that there is a new subversion of this device because the suffix is different:
TZ3000_typdpbpg

Has anyone seen this type before and was able to get it to work?

@DennisvDijk
Copy link

Hello all,

Today I tried adding the mentioned switch/sensor to Deconz and showup to my Home Assistant frontend. However only the switch/plug is displayed. No information is shared about power consumption. I can however see the power consumption in the cluster information in Deconz.

It also appears that there is a new subversion of this device because the suffix is different:

TZ3000_typdpbpg

Has anyone seen this type before and was able to get it to work?

I follow.

@basdejong95
Copy link

Hello all,

Today I tried adding the mentioned switch/sensor to Deconz and showup to my Home Assistant frontend. However only the switch/plug is displayed. No information is shared about power consumption. I can however see the power consumption in the cluster information in Deconz.

It also appears that there is a new subversion of this device because the suffix is different: TZ3000_typdpbpg

Has anyone seen this type before and was able to get it to work?

Same issue here... It seems that only switch is supported.

@Mimiix
Copy link
Collaborator

Mimiix commented Jan 27, 2022

Should be fixed with a DDF.

@Mimiix
Copy link
Collaborator

Mimiix commented Jan 27, 2022

@Smanar Can you give some pointers on that?

@Smanar
Copy link
Collaborator

Smanar commented Jan 27, 2022

Sure, for all plugs, same method #5633 (comment)

If the value is updated only one time, when you read it in deconz, it's because of bind (will explain later)

@rzechu
Copy link

rzechu commented Jun 7, 2022

Same issue
image

image
image

@Smanar
Copy link
Collaborator

Smanar commented Jun 7, 2022

Hello can you try that #5633 (comment) ?

@bigcookie
Copy link
Contributor

bigcookie commented Jun 13, 2022

In general I noticed that the manufacturer ID even is different if I order 4 in one lot...:
TZ3000_typdpbpg
the bold part seems to change. I then duplicated the DDF, changed the manufacturer ID and it picked up the correct DDF. In some cases I needed to add the Zigbee devices AGAIN via Sensors. Basically I paired it twice.

What I noticed:
(+) power, voltage and current sensors seem to be working fine
(-) consumption is clearly off...

Has somebody else similar experiences? I have one plug on a system which normally consumes 11W straight - constantly. But the consumption reads +0,01kwh after about 6-8 hours. I would expect it to add ~10W each hour.
Did somebody experience similar odd measurements?

@muratcorlu
Copy link
Author

muratcorlu commented Jun 13, 2022

Adding a file to ~/.local/share/dresden-elektronik/deCONZ/devices/tuya with name _TZ3000_cphmq0q7.json and with content given by @Smanar here (by replacing model id and vendor with _TZ3000_cphmq0q7 ) solved my issue.

PS: I didn't check the situation that @bigcookie mentioned above.

@bigcookie
Copy link
Contributor

I found the issue... Actually you have tu multiply the consumption from TS011F plug with 10 to make it accurate.
I hooked up multiple meters in parallel - see attached screenshot.

Can somebody help me, how we can change the DDF to change the multiplication?
Screenshot 2022-06-13 at 14 46 15

@bigcookie
Copy link
Contributor

bigcookie commented Jun 13, 2022

In DDF Editor (while connected via VNC), I changed the following under state/consumption:
Item.val = Attr.val
to
Item.val = 10*Attr.val

then "save" and "hot reload". Seems to work >happy< :-)
Accuracy is 1/10th of the Wifi sockets I do have, but I think fully acceptable. The TS011F seems to measure from 3W upwards (as already posted by others). So not good for low power measurements, but good for the rest imho.

@Smanar
Copy link
Collaborator

Smanar commented Jun 13, 2022

And pls share the DDF for others, can make PR yourself or ask for someone make it, but you can at least copy/paste the DDF on github.

@bigcookie
Copy link
Contributor

bigcookie commented Jun 13, 2022

@Smanar: Will try to make a PR (not a developer, but will manage ;-) )- but can you comment on the different manufacturer IDs?
_TZ3000_cphmq0q7
vs
_TZ3000_typdpbpg
vs
_TZ3000_STRING-I-DONT-KNOW

-> I have at least 2 more manufacturer identifiers in my pool of TS011F devices :-)

Before I will make a PR, please let me know, if we shall create a DDR for each manufacturer ID, or if in this case, the DDF application logic will be adapted to be "flexible" on the string part after "_TZ3000_"?
Depending on that my PR might look different.

Also I would like to get confirmation, if others see the same issue with consumption being reported. I would then make the changes accordingly.

Attached the two DDFs I modified - to be renamed to "*.json":
NAS-WR01B_2.txt
NAS-WR01B_3.txt
for two different manufacturer IDs for TS011F

@Smanar
Copy link
Collaborator

Smanar commented Jun 13, 2022

So first, don't worry, you can make error. (for me better having a broken code than no code at all, as it can't break others devices)

On my side I m trying to mix DDF, when they are absolutely clone, mean they use the same DDF (with same value convertion for power for exemple)
For exemple for this one https://github.com/dresden-elektronik/deconz-rest-plugin/blob/master/devices/tuya/_TZ3000_yd2e749y_temp_hum_sensor.json

You can that with

  "manufacturername": ["_TZ3000_yd2e749y", "_TZ3000_fllyghyj"],
  "modelid": ["TS0201", "TS0201"],

rules are

  "manufacturername": ["manufacturename1", "manufacturename2"],
  "modelid": ["modelid1", "modelid2"],

Else can make a new file.

If I m right they are all NAS WR10B, and use same code ? so can mix them in the same DDF.

Wana make the PR yourself ? need to put the file in the devices/tuya folder, Try to use same kind of file name than others.
Have checked the code, no DDF files for thoses devices yet.

@bigcookie
Copy link
Contributor

Thanks. Will try to do the PR - give me some time :-). If I recall, I can even do that with the github web interface :-)... Otherwise will do that from my computer. I like the option to use the DDF for multiple models/manufacturers... Will handle it accordingly.

@bigcookie
Copy link
Contributor

Easier than thought - I could create the file in the web GUI. PR is here:
#6131

@Smanar
Copy link
Collaborator

Smanar commented Jun 13, 2022

Nice have just it ^^, thx.

@rzechu
Copy link

rzechu commented Jun 17, 2022

Hello can you try that #5633 (comment) ?

I saw that but have no idea how to make it and stay persistent in HomeAssisant + Deconz as docker image.
I can access HA files but No idea how to access deconz docker image data.
Any ETA for this feature available inside common version?

Will try with
https://forum.phoscon.de/t/how-to-add-edit-a-ddf-on-home-assistant-using-text-editor/1839/2

@hubertgruber
Copy link

I currently have this issue for TZ3000_5f43h46b

@Smanar
Copy link
Collaborator

Smanar commented Dec 19, 2024

This device don't have DDF, so you need to create one or add your model to an existing one, generaly tuya are clones, so all devices are using the same DDF.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Device Improvement Additional tag to attach to a existing issue. Device Request
Projects
None yet
Development

Successfully merging a pull request may close this issue.