Tuya
HA core-2021.11.3
Didn’t realise it was a new addition, heard people using it for centuries. Updated and they appear now, not sure if they work yet but that’s progress!
Hi! Did you get this working? Can you see statistics of consumption kWh? Which device are you using? Thanks!
If anybody else is wondering I purchased Deltaco smart outdoor plug SH-OP01. It measures Power, Current and Voltage but the most important Consumption kWh isn’t measured which I personally think is a big loss.
Personally i use TPlink kasa (go down occasionally but have the best energy consumption stats) or tapo switches, both of which are well supported in HA, and Salus zigbee switches (never go down once).
Not sure the tuya app even supports energy readings. But yes from what i understand the new tuya integration is only getting up to speed with the old one, and that is mainly due to the work from HA programmers.
That’s doable, also with Tuya. Problem is just that the Tuya integration does not deliver the cumulated power consumption, but only the momentary power, current and voltage. Luckily, this can easily be added using the “Integration - Riemann-Summen…” integration (sorry, all in German in my case):
In the next step you select the “Power” sensor of the socket, give it a name and some optional parameters:
And there you go - it’s showing up in the list of devices in the Energy Dashboard configuration:
Note that in my case I found that for my Tuya-based sockets the ootb values for voltage and power have some scaling issues (factor 0.1), which is why I created an additional “…_leistung” sensor that fixes this. If you need this correction, too, add something like this to your configuration.yaml:
template:
- sensor:
- name: 3D Drucker Leistung
state: >
{{ states('sensor.3d_drucker_power')|float(0) * 0.1 }}
unit_of_measurement: W
device_class: power
icon: mdi:flash
- sensor:
- name: 3D Drucker Spannung
state: >
{{ states('sensor.3d_drucker_voltage')|float(0) * 0.1 }}
unit_of_measurement: V
device_class: current
icon: mdi:sine-wave
Hope that helps
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:
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.
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:
- does not appear in energy dashboard settings until I restart HA
- 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?
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 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.
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.
18 - current mA
19 - power W
20 - voltage V (1 decimal)
23 - total kWh (0.0…)
25 - today kWh (0.0…)