[RELEASE] Tuya Zigbee Metering Plug

This is a new topic on the Tuya Zigbee Metering Plug driver that was first published in November 2021.

The focus of the driver is to provide an optimized way for reporting Power, Energy, Voltage, Amperage, and switch events (where available) for these Tuya plugs/outlets models that do not report the metering attributes automatically.

The driver is available for download from Hubitat Package Manager (HPM), search for 'Tuya Zigbee Metering Plug'. The direct link to the code in GitHub repository is here .

Supported devices:

Device Links
Tuya TS0121 (BlitzWolf)
image
(AE link)
Tuya TS011F (many brands)
image
Lellki WK35 Plug Wall Socket EU BR IT JP FR IL
image

AliExpress: (link)
Tuya TS0601 (TOMZN DDS238-2)
image
(AE link)

COMING SOON! :

Tuya RC-RCBO / HOCH Automatic Circuit Breaker w/ energy monitoring (link)
Manufacturer: _TZE200_hkdl5fmv
image


Other metering plugs that send energy measurement reports on Tuya cluster 0xEF00 or on the standard 0x0702 and 0x0B04 clusters.

Features:

  • Supports Tuya smart plugs models TS0121 (BlitzWolf), TS011F (many brands), TS0601 TOMZN DDS-238
  • Automatic polling for models that do not send power reports automatically (TS0121 and TS011F)
  • Configurable polling interval (default is 60 seconds)
  • Updates the new power/amperage readings in 5 seconds after switching on/off.
  • Debouncing functionality for some models that tend to send the switch status updates twice
  • 'digital' or 'physical' property in the switch events
  • 'Always On' option prevents accidental switching off the power supply of the entire house! :slight_smile:
  • 'Presence' capability simulation - will send a 'not present' event if nothing is received from the plug in 3 consecutive poll cycles
  • Extended Debug logging (useful for tracking issues with unknown new models). Will be switched off automatically in 30 minutes.
  • Extended Info logging (when changing parameters or other important and useful information must be logged)
  • Automatically disables the polling for power, voltage, amperage or energy if the smart plug does not support this attribute.
  • Optimized polling of Power, Voltage, and Amperage attributes in one single command (reduces the Zigbee network load)
3 Likes

Revisions history:

  • ver. 1.0.0 2021-11-09 - first version: - reads Power, Energy, Voltage, Amperage once every 60 seconds
  • ver. 1.0.1 2021-11-10 - added 'pollingInterval' preference; 'amperage' attribute name bug fix;
  • ver. 1.1.0 2021-11-12 - added 'PresenceSensor' capability; the automatic polling can be switched off.
  • ver. 1.1.1 2021-11-25 - added Tuya Outlet TS011F fingerprint
  • ver. 1.1.2 2021-12-24 - added Tuya / Neo NAS-WR01 fingerprint; fingerprint inClusters correction
  • ver. 1.2.0 2021-12-29 - major refactoring and optimizations
  • ver. 1.2.1 2021-12-29 - added AlwaysOn option
  • ver. 1.3.0 2022-01-01 - added 'HIKING TOMZN DDS238-2 TS0601 (DIN rail)' support'; 'Optimizations' option.
  • ver. 1.4.0 2022-01-23 - debug & trace logging cleanup; initialize switch and energy automatic reporting mode; energy and switch are excluded from polling; default debug logging is disabled, optimizations are enabled by default; switch digital/physical bug fixed; added driver version check
  • ver. 1.4.1 2022-01-27 - added XH-002P Outlet TS011F fingerprint (no power monitoring!)
  • ver. 1.4.2 2022-02-20 - missing Switch capability bug fix
  • ver. 1.4.3 2022-02-15 - added 'Tuya RC-RCBO Circuit Breaker'
  • ver. 1.4.4 2022-05-08 - added new fingerprints; [overwrite: true] explicit option for runIn timers; settings reset bug fix;
  • ver. 1.4.5 2022-05-24 (dev. branch)
    • added _TZ3000_5f43h46b XUELILI 16A UK; _TZ3000_r6buo8ba; _TZ3000_ksw8qtmt NOUS A1Z; _TZ3000_1h2x4akh Ajax/Zignito; _TZ3000_ky0fq4ho DIN Relay;
    • GreenPower cluster 0xF2 fix?;
    • added childLock, ledMode, powerOnState configuration commands;
    • importURL is the development branch

The latest fingerprints for new models (manufacturers) and new features or bug fixes are available in the development branch: https://raw.githubusercontent.com/kkossev/Hubitat/development/Drivers/Tuya%20Zigbee%20Metering%20Plug/Tuya%20Zigbee%20Metering%20Plug

The development branch is not pushed to HPM, so you need to manually copy and paste the code from the link above.

If you were using a previous version of the same driver, make sure you press the 'Initialize' button for all plugs that used the same driver.

If any issues or suggestions for improvements - please comment in this thread.

Do you know if there is a UK version of this?

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 ) :

1 Like

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

1 Like

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.

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

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

Download the Hubitat app