[RELEASE] Tuya Zigbee Metering Plug (w/ healthStatus)

There seems to be : tuya smart plug uk - Buy tuya smart plug uk with free shipping on AliExpress

I'd been looking but I can't find any zigbee ones that say they do metering. They may do, but the sellers aren't making it clear. So I just asked on the off-chance you happened to know one specifically.

Check this one: (link) .
It is Zigbee and it is advertized to provide power and energy monitoring:

50 day shipping!! :o I found something that looks like this on Ebay finally and should have it by the end of the month. Hopefully it's the same one :slight_smile: Thanks!

1 Like

Ali Express orders are hit-or-miss... I have received small items from China in just one week, although it states more than a month. Seems like it depends whether the same item is already present in Amsterdam or not. And at the same time - items that are claimed to be available in Spain or France warehouses may travel several weeks inside the EU countries, although there are no customs... go figure!

This is my Energy dashboard ( HubiGraphs ) :

7 Likes

This is the RM rule that is used to calculate the hourly and the daily energy:

The rule (and Hubigraphs ) use two global Hub variables of a type Decimal and Connector type Variable :
image

4 Likes

I've just found this in my logs from this plug

2022-01-19 09:41:38.796 warnUnprocessed ZDO command: cluster=8038 command=00 attrId=null value=null data=[00, 00, 00, F8, FF, 07, 16, 00, 06, 00, 10, A7, C9, C3, AC, C4, C1, DA, D6, D6, B8, CE, D9, D3, CD, B5, C1]

Device details are

  • endpointId: 01
  • outClusters: 0021
  • model: TS011F
  • application: 45
  • inClusters: 2101,0000
  • manufacturer: _TZ3000_cphmq0q7

Does it represent a bug or anything?

Hi,

I see now there are some debug/information messages that I have missed to suppress when the Debug option is switched off, will correct this in the next update. This is a network update message that is not of interest.

Does the driver work OK with your device? Does it need the polling option to be enabled in order to receive power readings?

Second question: does the plug report the On/Off status immediately when you switch it locally pressing the plug button, or the status is reported after a delay (on the next polling cycle) ?

These are my current settings

State Variables

  • energyPollingSupported : true
  • lastEnergy : 12.46
  • lastPower : 0
  • isDigital : false
  • lastSwitchState : off
  • isRefreshRequest : false
  • notPresentCounter : 0
  • switchPollingSupported : true
  • lastPresenceState : present
  • powerPollingSupported : true
  • lastAmperage : 0
  • voltagePollingSupported : true
  • lastVoltage : 245
  • currentPollingSupported : true
  • switchDebouncing : false
  • model : TS011F
  • destinationEP : 01

It seems to be working as expected so far. I'll test to answer your other questions when I get time later on.

And in answer to your two questions, it only updates the status at the polling intervals, and without polling on it reports nothing at all, not even on/off state (unless instigated via the hub)

1 Like

It turns out that Tuya has made a strange (for us) decision to disable the automatic reporting of the switch and energy readings in the firmware of the plugs produced in the last year. So the automatic reporting of the switch state actually depends on the 'application' version:

  • Application version: 0x41 (65 decimal) - switch state and energy are reported automatically

  • Application version: 0x45 (69 decimal) - switch state and energy needs polling

The power, voltage, and amperage attribute of TS0121 and TS011F models always need polling, regardless of the application version. Only the TOMZN DDS238-2 model reports all the measured attributes automatically.

The good news is that there seems to be a possibility/workaround to initialize the newer models to work in a backward-compatible mode, i.e. to start reporting the switch and energy states automatically. If this works for all different types of Tuya plugs, it will reduce the unnecessary Zigbee network communication load even more. I hope will be ready to publish the new version for testing later tonight or tomorrow.

3 Likes

This is the link to the development branch: https://raw.githubusercontent.com/kkossev/Hubitat/development/Drivers/Tuya%20Zigbee%20Metering%20Plug/Tuya%20Zigbee%20Metering%20Plug

Can you give it a try? You'll need to press the Initialize() button again. Now the automatic switch state reporting works OK with my TS011F plug app. version 0x45, even if I use the inbuilt Generic Zigbee Outlet driver.

There are also a lot of other small bug fixes and improvements, if this version works OK, I will update also the 'production' version that is available from HPM.

1 Like

Ok I think this is working as you intended. Without automatic polling enabled it now briskly updates the On/Off state as initiated via the physical device, but does not update power readings etc. (they update when automatic polling is reinstated)

1 Like

Thank you for the tests! If you have any other suggestions for improvements, please let me know. I have too many items in this driver TODO list, but it is difficult for me to decide which of them are really worth spending the time and could be useful for anyone else than me :slight_smile:

Version 1.4.0 is now available for update from HPM.

It works really well, great job, no one had hit on the key to make this work so far. a great job, congratulations and thank you for the driver. Cheers

1 Like

My TS011F doesn't seem to want to do power metering. Even though the seller (aliexpress) advertises it as capable.
Could it be that this is a different version or something?

  • endpointId: 01
  • application: 43
  • softwareBuild:
  • inClusters: 0003,0004,0005,0006,E000,E001,0000
  • outClusters: 0019,000A
  • model: TS011F
  • powerCluster: none
  • manufacturer: _TZ3000_v1pdxuqq

The box indicates the model as XH-002P
From manufacturer: shenzhen Sparkle IOT

After pairing the outlet, selecting your driver and pressing initialize:

  • I can control the on / off state
  • I can see (under state variables) all kinds of vallues, but lastEnergy, lastPower, lastAmperage and lastVoltage remaine at 0.

Thanks :slight_smile:

1 Like

And you have automatic polling on with a reasonable polling interval?

Automatic polling is set to true
Polling interval is at 60 seconds, but i've tried it at 10 sec as well
Always on = false
Optimise polling and logging = True
Energy shortest reporting interval = 60
Energy longest reporting interval = 3600
Energy minimum change to be reported = 1

It has been connected for 1,5 hours now and the last*** values are still at 0

I will research this particular _TZ3000_v1pdxuqq model in more detail sometime later, it has not been tested until now.

Can you check in the State variables what are the values of powerPollingSupported , switchPollingSupported, etc... Better copy all the State variables.