Added Tuya smart plugs - where is the energy monitoring?

sensor.yaml

  - platform: template
    sensors:        
      ac_lacaltuyawatt:
        value_template: "{{ state_attr('switch.ac_tuya_local', 'current_consumption' ) | float | round (2) *0.1}}" 
        friendly_name: "AC Tuya local Watt"
        unit_of_measurement: "W" 
        device_class: energy     
        unique_id: aclacaltuyawatt

  - platform: integration
    source: sensor.ac_lacaltuyawatt
    name: Tuya local kWh
    unit_prefix: k
    round: 2
    unique_id: tuyalocalkwh


Hi krskrab,

I don’t have a switch for the tuya energy plug :(.
i think i have to stick to the solution of Tobse?

Hi I would really need the power statistics in my HA project, but somehow I cannot see the details of my Tuya smart plug with power consumption details in my HA devices overview. Anyone can see what I am doing wrong? Should I upgrade to a certain version HA?

I cant really flash these plugs as I am using them in other automations (ie homebridge for example)

devices tab in HA:

1 Like

Example statistics in Tuya Smart Life APP:

I am on Synology so cant easily upgrade to any other version. info tab HA:

Home Assistant 2021.9.7

Path to configuration.yaml: /volume1/@appdata/homeassistant/config

Frontend version: 20210830.0 - latest

System Health

Version core-2021.9.7
Installation Type Home Assistant Core
Development false
Supervisor false
Docker false
User sc-homeassistant
Virtual Environment true
Python Version 3.8.13
Operating System Family Linux
Operating System Version 3.10.108
CPU Architecture armv7l
Timezone UTC

Home Assistant Cloud

Logged In false
Reach Certificate Server ok
Reach Authentication Server ok
Reach Home Assistant Cloud ok

Lovelace

Dashboards 2
Resources 0
Views 2
Mode storage

For whatever reason, for most (not all, interestingly) of my Tuya-connected sockets, the power entities were initially deactivated. Maybe that’s the case for you, too? Just go to the Home Assistant entities list (/config/entities) and change the filter so you also see deactivated entities. If the ones in question appear now, just activate them and go ahead.

16 Likes

Am only known to tuyalocal and there you can select the individual sensor-attributes when setting it up
But… there are many more entries on the same topic with tuya devices, tuyalocal may not work too.

how exactly to setup sum helper?

with setup like this:

  1. does not appear in energy dashboard settings until I restart HA
  2. even after that does not show any actual values in energy dashboard - always 0, but I can see that socket does have power readings in home assistant history

I had similar issues - not always, interestingly, but it seems it just takes some time, because it probably needs a certain amount/timespan of statistics to show meaningful values. That’s at leas my guess :-). Did you check again a couple of hours later? Still nothing shown?

1 Like

I did and the values are now showing, but the helper sensors with other interval then 1 hour do not show.
So 1 hour, left, kilo prefix seems to be best way how to set it up. I still don’t understand left right trapezoid difference Riemann sum - Wikipedia
I’m running test today with the 3 helper sensors sensors for the same thing set up as left, right and trapezoid

Good to hear. To be honest, I did not fiddle around with all these settings. So, for me it’s also 1 hour and kilo (I think). The left, right, trapezoid is mathematical stuff. I can recommend looking into the wikipedia article Riemann sum - Wikipedia. Try NOT to read and understand :smiley: but look at the graphs on the right side when you scroll down. They give you a simple explanation also for why “trapezoid” is the most precise approximation for the most use cases.

2 Likes

my question: is the data saved in the HA database and is it about to fill my device disk or download data from the tuya cloud?
at the beginning i had 0 now growing

For those who are still not able to pull in the power usage metrics with the standard Tuya integration, have a look at Local Tuya (where you are able to monitor your devices locally instead of over the cloud) plus it has the added benefit of configuring the state_attr (consumption, voltage, current) - GitHub - rospogrigio/localtuya: local handling for Tuya devices

Here is a screenshot where I hooked up my Connex Connect Smart plug (installed and added with the Tuya app on iOS)

I hope this helps someone.

I have just set up 9 of these power monitoring plugs from different manufacturers on Local Tuya, and all plugs are based on Tuya protocol 3.3.

When configuring the plug initially in the Local Tuya Integration, note that the switched socket is listed as ‘switch’, and then the other entities for Current, Power and Voltage are noted as ‘sensor’. When choosing which attribute to assign from a drop-down list taken directly from the type of plug… (in my case there were numerous items, with a value noted afterwards) which was very confusing at first, but I came to the conclusion after doing the first two that the items in the list correspond to different figures produced by the plug i.e. kWh, total kWh, current, voltage etc

Based on Tuya protocol 3.3, they were:-

  • 18 = power
  • 19 = current
  • 20 = voltage

The list of attributes from the plug extended well into the 20’s with some much longer figures after the item number - I suspect these are kWh, and Total kWh figures calculated by the plugs - but I may be wrong. I didn’t get as far as including these as entities (I presumed that HA could calculate these if needed) so couldn’t compare to the Tuya phone app.

I hope this helps somebody when installing their own power monitoring plugs. :+1:t2:

5 Likes

18 - current mA
19 - power W
20 - voltage V (1 decimal)
23 - total kWh (0.0…)
25 - today kWh (0.0…)

8 Likes

same situation here.

I’m using S-Link SWAPP SL-03 model smart plugs which has power meter function and I can monitor power consumption on Tuya app, (and also in Tuya IOT platform as logs too) but can’t see any entity in Home Assistant even if it’s disabled.

Is there any option that I can do or did you find any solution?

Even I couldn’t find those sensors with local tuya custom integration too :frowning:

finally made it by this part:

1 Like

can u share your yamls for that?

Hi, How do you retrieve IDs 23 and 25 using localtuya?

@Muddy_Boots is this the way i need to fill it in?