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



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


Review:(link)
AliExpress Haozoe: (link)
NEO ZigBee On Off Power Metering Plug
image
Ultrasmart.pl : (link)
Lellki WK35 Plug Wall Socket EU BR IT JP FR IL
image

AliExpress: (link)
20A Tuya Zigbee Smart Plug Mini US Power Outlet
image
WARNING!
Plugs from the latest batches (_TZ3000_okaz9tjs application A0) DO NOT WORK with HE!

DO NOT BUY!


AliExpress: [link]
Ajax / Zignito Zigbee Plug 13Amps with Energy Monitoring UK image WARNING!
Ajax/Zignito plugs from the latest batches DO NOT WORK with HE!

DO NOT BUY!


Amazon:(link)
AliExpress: link
Smart ZigBee Socket NOUS A1Z
image
Nous: (link)
Tuya Smart Zigbee Plug AU 16A
image
AliExpress: (link)
Plugue Zigbee 16a brasil br tomada de energia
image
AliExpress:(link)
AliExpress: (link)
Lellki Smart Wall Socket 220v
image
Alixpress: (link)
DIN rail metering switch
image
AliExpress: (link)
Tuya TS0601 (TOMZN DDS238-2)
image
(AE link)

Review: (link)
Tongou Zigbee Rail Switch MODEL TO-Q-SY1-JZT
image
Model: TS011F
Manufacturer: _TZ3000_qeuvnohg _TZ3000_8bxrzyxz

Features:
* Voltage, Current, Power, Energy monitoring
* Current rating: 10A, 16A, 25A, 32A, 40A, (ugh..?..) 63A

AliExpress: (link)

This model does not have overcurrent and overvoltage configurable settings!

Driver status: fully functional.
Tongou Zigbee Rail Switch (MCB) MODEL TO-Q-SY2-JZT
image
Model: TS011F
Manufacturer: _TZ3000_qeuvnohg _TZ3000_8bxrzyxz

Features:
* Voltage, Current, Power, Energy monitoring
* Current rating: 0...63A adjustable
* Over-voltage protection : 220-265V
* Under-voltage protection : 76-240V
* Temperature protection : 40-100℃
* Over-Power protection : 1-26KW

AliExpress: (link)

Driver status: fully functional

Circuit Breakers :

Device Links
Tuya RC-RCBO Circuit Breaker 2P w/ Energy Monitoring
image
Model: TS0601
Manufacturer: _TZE200_hkdl5fmv

AliExpress: link
Tuya RC-MCB Circuit Breaker 2P
image
Model:TS0601
Manufacturer: TZ3000_1hwjutgo TZ3000_lnggrqqi

AliExpresslink
RTX Controlled fuse 4x 25A ZigBee TUYA
image
Model: TS0601
Manufacturer: _TZE200_abatw3kj

Features:
* 4 lines on/off;
* Over-current protection: 4x 25A
* Mains voltage: 85-265V AC 50-60Hz
* Maximum power : 4x 5750Watt (25A)
* Surge protection up to 6KV
* DIN rail mounting

RTX24.pl: (link)

Note: NO POWER MONITORING

Supported non-Tuya devices:

Device Links
frient Electricity Meter Interface
image
frient :
vesternet:
smartify.in :

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)
13 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
    • 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
  • ver. 1.4.6 2022-06-02 - added on/off switches for power, amperage, voltage, and energy reporting (logs+Events); added device display name in all logs
  • ver. 1.5.0 2022-06-05 - Bug fix - all settings were reset back in to the defaults on hub reboot; parsing 'other Tuya oddities..'; over current alarm 0x8003; 'Freeze' LED mode (sets the backlight to the current state);
  • ver. 1.5.1 2022-06-12 - ChildLock bug fix
  • ver. 1.6.0 2022-09-11 :
    • removed 'Health Check' and 'Polling' capabilities (ping and poll buttons);
    • added _TZ3000_okaz9tjs fingerprint for tests; automatic reporting configuration bug fixes;
    • added individual thresholds for W,A,V; added autoReportingEnabled switch(default:false);
    • added resetEnergy command; disabled attributes states are now deleted; added energyPrice (decimal) preference;
    • added setEnergyPrice command; added energyCost calculation and event
  • ver. 1.6.1 : added html attribute; added energyDuration; added hourlyEnergy; energy and energyCosts are reset when Initialize button is clicked; fixed autoPoll bug
  • ver 1.6.2 (2022/09/28) : added NON-Tuya plugs fingerprints; removed hardcoded EPVA dividers; SmartThings outlet power and voltage correction; added warning for _TZ3000_okaz9tjs'; removed lastAmperage, lastVoltage, lastPower states; negative energy automatic correction; * ignoring false zero W,A,V values from Tuya devices automatic reports; Frient A/S SPLZB-131 voltage correction; added processing for power Instantaneous Demand
  • ver. 1.6.3 2022-11-24 : * added OSRAM 'Plug 01'; maximum power cap set to 13KW; added 'Develco Products A/S' as Frient manufacturer; fixed power events when on/off; added lastHour energy in HTML; added _TZ3000_zloso4jk; 'not present' bug fix when polling is disabled; removed lastPresenceState; added SiHAS products; * added frequency; added powerFactor; fixOtherTuyaOddities() and extendedTuyaMagic() for _TZ3000_okaz9tjs
  • ver. 1.6.4 2022-11-26 : added Frient Energy Monitor (ZHEMI101); pulseConfiguration; energyMeterMode; removed fixed destEndpoint; isRefreshRequest fix; added rejoinCounter; fixed null Zigbee commands bug;
  • ver. 1.6.5 2022-12-19 - added _TZE204_cjbofhxw Smart Meter w/ Current Transformer ; fixed bug in html for Power attribute; added new models HIKING TOMZN DDS238-2 _TZE200_bkkmqmyo; added MatSee _TZE200_eaac7dkw
  • ver. 1.6.6 2023-01-20 - Zigbee 3.0 incompatible with HE _TZ3000_r6buo8ba and _TZ3000_okaz9tjs fingerprints commented out; added SONOFF Z111PL0H-1JX to the isHEProblematic() list; added _TZ3000_7dndcnnb
  • ver. 1.7.0 2023-01-29 - added healthStatus;
  • ver. 1.7.1 2023-02-02 - added capability 'Health Check'
  • ver. 1.7.2 2023-02-16 - IntelliJ lint +bug fixes; added ThirdReality 3RSP02028BZ metering plug; powerOnState for non-Tuya plugs
  • ver. 1.7.3 2023-03-28 - Third Reality amperage divisor fix; added frequency polling; completely removed presence capability; improved logging for disabled attributes; hourlyEnergy is not sent of disabled or the deviceHealth is offline; dummy ping; Frient freq. divisor fix; added Instantaneous Demand (power) configuration;
  • ver. 1.7.4 2023-04-22 kkossev - added TS011F _TZ3000_1hwjutgo _TZ3000_lnggrqqi Tuya Circuit Breaker 2P; TS0601 _TZE200_hkdl5fmv circuit breaker w/ energy: power, energy, voltage, amperage; polling and energyMode are set automatically depending on the device type; automatic reporting configuration thresholds bug fix;
  • ver. 1.7.5 2023-05-12 kkossev - (dev. branch) added Tongou TO-Q-SY1-JZT DIN Rail Switch TS011F _TZ3000_qeuvnohg; added toggles for enabling Frequency, Power Factor and temperature (if device supports it); added _TZE200_fsb6zw01;
  • ver. 1.7.6 2023-05-13 - added partial support for TS0601 _TZE200_abatw3kj RTX Circuit Breaker 4x25A ZCB25-4P; added Tongou SY2 TZ3000_cayepv1a; thresholds decoding for RTX
  • ver. 1.7.7 2023-06-10 - isTuyaE00xCluster procesing of known attributes; Tongou SY2 over/under V/A/P protection parameters decoding and encoding; moved TS011F non-power-reporting plugs to Zemismart driver
  • ver. 1.7.8 2023-07-29 kkossev - added TS0001 _TZ3000_kqvb5akv; bug fix: report containing multiple 0x0006 attributes was not processed correctly; added setSwitchType configuration command; suppressed some warning logs;
  • ver. 1.8.0 2023-09-03 kkossev - added TS011F _TZ3000_qystbcjg Somgoms ZigBee MCB Circuit Breaker DIN Rail; added TS0601 _TZE200_bcusnqt8 (matches partially the RTXCircuitBreaker)
  • ver. 1.9.0 2024-01-18 - Groovy Linting; added TS0601 _TZE204_81yrt3lo Bidirectional energy meter with 80A current clamp (PJ-1203A); added TS0601 _TZE200_rks0sgb7 (one channel only!)
  • ver. 1.9.1 2024-03-02 - currentEvent bug fix; reduced debug logging; debug logs raw value bug fixes;
  • ver. 1.9.2 2024-03-24 -more Groovy Linting;

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 another driver, make sure you press once the 'Initialize' button. Initialize button will load the default settings depending on your plug model and manufacturer!

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

4 Likes

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

1 Like

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