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

Next in my TODO list it to make non-power reporting plugs like OSRAM Ligtify, IKEA and SONOFF calculate energy and energy costs, based on a fixed power consumption parameter. When the energyCost is changed, calculate and update the current energy and energyCosts, before switching to the new rate.

I.e. - an IKEA plug that controls a 60 watts bulb was turned on for 2 hours today and the energy price (rate) changed in the last 30 minutes from $0.12032 to $0.21326 :

  • the energy consumption should be 0.060 * 1.5 + 0.060 * 0.5 = 0.09 + 0.03 0.120 KWh.
  • the energy cost should be is 0.09 * 0.12032 + 0.03 * 0.21326 = 0.0108288 + 0.0063978 = 0.0172266. Energy cost will be rounded for dashboard displaying purpose to $0.02 for this period, but it is kept in an internal state with high precision.
3 Likes

This is not registered, so please register it.
It seems to work well.

Device pairing info
Manufacturer: _TZ3000_zloso4jk
Endpoint 01 application: 4A
Endpoint 01 endpointId: 01
Endpoint 01 idAsInt: 1
Endpoint 01 inClusters: 0003,0004,0005,0006,0702,0B04,E001,E000,0000
Endpoint 01 initialized: true
Endpoint 01 manufacturer: _TZ3000_zloso4jk
Endpoint 01 model: TS011F
Endpoint 01 outClusters: 0019,000A
Endpoint 01 profileId: 0104
Endpoint 01 stage: 4
Endpoint F2 application: unknown
Endpoint F2 endpointId: F2
Endpoint F2 idAsInt: 242
Endpoint F2 initialized: true
Endpoint F2 manufacturer: unknown
Endpoint F2 model: unknown
Endpoint F2 outClusters: 0021
Endpoint F2 profileId: A1E0
Endpoint F2 stage: 4

Summary

2022-10-01 08:38:05.460 pminfoTuya Plug Auto polling is enabled, polling interval is 1 minutes

dev:3592022-10-01 08:38:05.407 pminfoTuya Plug Debug logging is false Description text logging is true

dev:3592022-10-01 08:38:05.405 pminfoTuya Plug Updating Tuya Plug (Tuya Zigbee Metering Plug) model TS011F presence: present AlwaysOn is false

dev:3592022-10-01 08:37:59.843 pminfoTuya Plug refresh()...

dev:3592022-10-01 08:37:59.792 pminfoTuya Plug configure()..

dev:3592022-10-01 08:37:59.789 pminfoTuya Plug configuring the switch and energy reporting..

dev:3592022-10-01 08:37:59.786 pminfoTuya Plug Auto polling is enabled, polling interval is 1 minutes

dev:3592022-10-01 08:37:59.732 pminfoTuya Plug Debug logging is false Description text logging is true

dev:3592022-10-01 08:37:59.731 pminfoTuya Plug Updating Tuya Plug (Tuya Zigbee Metering Plug) model TS011F presence: present AlwaysOn is false

dev:3592022-10-01 08:37:49.378 pminfoTuya Plug energy is 0.21 kWh, energyCost=$0.03 (rate=$0.12), duration=2.79 Mins

dev:3592022-10-01 08:37:49.175 pminfoTuya Plug amperage is 0 A

dev:3592022-10-01 08:37:49.119 pminfoTuya Plug voltage is 222 V

dev:3592022-10-01 08:37:49.072 pminfoTuya Plug power is 0 W

dev:3592022-10-01 08:37:46.739 pminfoTuya Plug refresh()...

dev:3592022-10-01 08:37:46.699 pminfoTuya Plug configure()..

dev:3592022-10-01 08:35:14.313 pminfoTuya Zigbee Metering Plug voltage is 219 V

dev:3592022-10-01 08:35:11.940 pminfoTuya Zigbee Metering Plug refresh()...

dev:3592022-10-01 08:35:11.903 pminfoTuya Zigbee Metering Plug configure()..

dev:3592022-10-01 08:35:11.901 pminfoTuya Zigbee Metering Plug configuring the switch and energy reporting..

dev:3592022-10-01 08:35:11.899 pminfoTuya Zigbee Metering Plug Auto polling is enabled, polling interval is 1 minutes

dev:3592022-10-01 08:35:11.851 pminfoTuya Zigbee Metering Plug Debug logging is false Description text logging is true

dev:3592022-10-01 08:35:11.849 pminfoTuya Zigbee Metering Plug Updating null (Tuya Zigbee Metering Plug) model TS011F presence: present AlwaysOn is false

dev:3592022-10-01 08:35:09.137 pminfoTuya Zigbee Metering Plug amperage is 0 A

dev:3592022-10-01 08:35:09.093 pminfoTuya Zigbee Metering Plug voltage is 220 V

dev:3592022-10-01 08:35:09.051 pminfoTuya Zigbee Metering Plug power is 0 W

dev:3592022-10-01 08:35:05.222 pminfoTuya Zigbee Metering Plug energy is 0.21 kWh, energyCost=$0.03 (rate=$0.12), duration=0.06 Mins

dev:3592022-10-01 08:35:05.032 pminfoTuya Zigbee Metering Plug amperage is 0 A

dev:3592022-10-01 08:35:04.984 pminfoTuya Zigbee Metering Plug voltage is 220 V

dev:3592022-10-01 08:35:04.945 pminfoTuya Zigbee Metering Plug power is 0 W

dev:3592022-10-01 08:35:02.980 pminfoTuya Zigbee Metering Plug Tuya Zigbee Metering Plug switch is on

dev:3592022-10-01 08:35:02.818 pminfoTuya Zigbee Metering Plug refresh()...

dev:3592022-10-01 08:35:02.039 pminfoTuya Zigbee Metering Plug Energy (total:0.0 kWh) was reset on 2022-10-01 20:35:01.780

dev:3592022-10-01 08:35:01.995 pminfoTuya Zigbee Metering Plug hourlyEnergy is 0 kWh

dev:3592022-10-01 08:35:01.991 pminfoTuya Zigbee Metering Plug energy is 0.0 kWh, energyCost=$0.0 (rate=$0.12), duration=0 Mins

dev:3592022-10-01 08:35:01.779 pmtraceresetEnergy() : state.lastEnergyRaw = 0.0

dev:3592022-10-01 08:35:00.659 pmwarnstate.lastResetEnergy = null, resetting it back to 0!

dev:3592022-10-01 08:35:00.627 pmwarnTuya Zigbee Metering Plug Initialize()...

dev:3592022-10-01 08:34:58.363 pminfoTuya Zigbee Metering Plug energy is 0.21 kWh, energyCost=$0.03 (rate=$0.12), duration=0.05 Mins

dev:3592022-10-01 08:34:58.163 pminfoTuya Zigbee Metering Plug amperage is 0 A

dev:3592022-10-01 08:34:58.113 pminfoTuya Zigbee Metering Plug voltage is 220 V

dev:3592022-10-01 08:34:58.062 pminfoTuya Zigbee Metering Plug power is 0 W

dev:3592022-10-01 08:34:56.145 pminfoTuya Zigbee Metering Plug Tuya Zigbee Metering Plug switch is on

dev:3592022-10-01 08:34:55.713 pminfoTuya Zigbee Metering Plug refresh()...

dev:3592022-10-01 08:34:55.654 pminfoTuya Zigbee Metering Plug configure()..

dev:3592022-10-01 08:34:55.499 pmwarnstate.lastResetEnergy = null, resetting it back to 0!

dev:3592022-10-01 08:34:55.488 pminfoTuya Zigbee Metering Plug Installed()...

1 Like

This is the RM5.1 rule that I use to change the energy price automatically :

The 'dailyRateStartHour' and 'nightlyRateStartHour' variables are (should be) updated automatically on 1st of April and 1st of November every year.

Every hour, the RM checks if it is the time to change between daily energy rate or nightly energy rate. If the rate was changed, then the custom command 'setEnergyPrice' is used to automatically change the energy price every morning and every evening:

2 Likes

I conducted the test at C-4 (home), C-5 (office), and C-7 (office).
Rules work well on C-5, C-7.
But the rules don't work on C-4.
I'm going to test it again with the C-5 at home and post it on the rule machine category.

I did a test at home on C-4, C-5.
Also, we brought the device of C-4 to C-5 using hub mesh and conducted the test.

My plug does not work with rules only on C-4.
It is very difficult for me to understand this result.

Is your C4 hub updated to the latest HE platform version? ( 2.3.3.127 at the moment)

1 Like

Ok, I am good at updating.
I am at home today. So I changed all the devices in C-4 to C-5. All you have to do is solve automation.

Any thoughts on why the Samsung plug didn't show energy usage?

The device doesn't offer it as far as I am aware.

@tim.ocallag what is your Samsung plug model? "outlet" or "outletv4" ?

sorry for delay....watching 4 grandkids under 6 : )
The model says STS-OUT-US-2

This Samsung plug provides measurements of voltage, amperage, and power only. No energy readings are available.
I have in my plans to calculate the energy in the driver (power multiplied by time periods), but it is not implemented yet, have to finish some other projects first.

1 Like

Hi !

The tests were done with Shelly Em, the results are below:

1 Like

So it seems that Zemismart plug is reporting the active power much higher than it is?

What is Shelly showing as Power Factor?

So it seems that Zemismart plug is reporting the active power much higher than it is?

Could it be a problem with the divider ?

What is Shelly showing as Power Factor?

PF = 0.99

PF = 0.76

Not a divider problem in my opinion, as the ratio of the measurements EM2/Tuya seems to be non-linear. Seems like it depends on the power factor not being measured correctly in the Zemismart plug.

I could add a correction coefficient for the power in the driver, however, it will affect only the momentary power. The energy reported by the plug will still be (possibly) wrong, as it is calculated internally in the device firmware.

Comparing the daily energy the problem seems to be the same. Would be interesting to add the coefficient. Do you think it is also necessary to add a coefficient for the energy?

@joaomf to be honest, I don't think that adding correction coefficients for both the power and the energy is a good idea... It will complicate even more the already too-complicated preferences section in this driver. The measurement error is definitely not linear, so any multipliers will add another error, just in the opposite direction when the load is mostly resistive. And also, I haven't seen any similar corrections in other drivers in HE but also in other systems.

Hello everyone,
I recently installed this smart plug using this driver, however, l am noticing that the smart plug is switching itself off from time to time.
image

I have set the 'Power On State' driver setting to 'On' and within the driver's preferences, I have played around with the setting 'Always On' but it didn't make much difference regardless of the setting.

This smart plug is used to monitor the washing machine to send me a notification when the washing is done i.e. using the power monitoring feature.

I have noticed the switch is switching itself off during the washing cycle and when the washing machine is not in use.

Note sure if perhaps l have a faulty plug or perhaps some sort of bug in the driver?

Appreciate any help

Thanks in advance

Unfortunately, your smart plug most probably suffers from the automatic switching itself off bug in the Tuya firmware when the voltage exceeds 250 V for a fraction of a second.. This is a problem for many Tuya-based plugs produced in the last year.

The best approach would be to check with the seller if they have a firmware upgrade that fixes this issue. Some manufacturers have, and others don't... You will need however a Tuya Zigbee gateway to perform the OTA update. Or try to return it if possible. The random turn-of problem happens even when the plugs are used fully offline, i.e. not connected to any Zigbee hub.

The option 'Always on' prevents the plug from being accidentally switched by HE command ( 'Alexa, turn all lights off' as example...). It does not prevent it from switching off when the 'safety protection' kicks in.. : (

I was thinking about adding another option 'Force on' as a workaround of this problem - when HE receives an 'switch off' message from the plug. the driver could automatically switch it back on. But first, I am not sure whether this could not become a safety problem and secondly, the electronic equipment that is powered from this plug will be reset from the off->on sequence. So most probably your washing machine will stop the washing cycle and will need manual reactivation again?