Hi sorry in advance for typos, translation by deep.
Ok. I need to ask for some help.
I’ve searched through a really good amount of forms, threads, topics in the last 2 weeks, tested various settings and…poof.
I have a GoSund socket which I have connected to Tuya.
I have Tuya version 2 hooked up to Home Assistant.
I have 3 entities in my devices:
1 - mA
2 - Watts
3 - Volt
4 - On/Off
I am trying to use the 2nd entity to count the power consumption on this outlet.
In the application it somehow works and counts fine but in HA I fail.
And so I tried based on the forums to add for example:
sensor:
- platform: statistics
name: ‘Zm_stat_40’
entity_id: sensor.test_zm_wat40
sampling_size: 12
precision: 5
sensors:
test_zm_wat40:
friendly_name: ‘Zm_Actual current consumption_1’
value_template: ‘{{ ((states(‘sensor.socket_dishwasher_2’) | float / 10000 ) | round(6) ) }}’"
unit_of_measurement: ‘kWh’
device_class: energy
That is, I have an entity that gives information about power consumption in watts something along the lines of (if I skip tuya and take by localtuya):
value_template: '{{ ((state_attr(‘switch.lt_g_dishwasher’, ‘current_consumption’)
I divide by 10000 because there is an offset of one 0 so instead of 1k I have 10k.
This gives the value of the current consumption in kWh, for example: 0.020
Then this goes to the statistics.
There I have:
sampling_size: 12
because (if I understand correctly) the value 60 is given if the reading is one per second. In my case it is every 5s, hence the value 12 (correct me if I am wrong).
And now if I turn on the dryer which consumes 1840 w then in 1 minute the power consumption should be
0.0306 kWh
And now if with:
- platform: statistics
name: ‘Zm_stat_40’
I make an entity that extracts the mean value, and in the other entity total:
test_zm_zuz40:
friendly_name: ‘Zm_zuz_total_4’
value_template: “{{ (state_attr(‘sensor.Zm_stat_40’, ‘mean’) | round(5) ) }}”
unit_of_measurement: ‘kWh’
device_class: energy
test_zm_zuz_t40:
friendly_name: ‘Zm_zuz_total_t_4’
value_template: ‘{{ (state_attr(‘sensor.Zm_stat_40’, ‘total’) | round(5) ) }}’
unit_of_measurement: ‘kWh’
device_class: energy
It doesn’t matter how I would divide it afterwards e.g.: value from entity: Zm_zuz_total_t_4 / (1000*60 (or 12))
or from an entity that takes data from mean, then in no way I get the value of current consumption as in tuya application.
I also tried to do in customize.yaml
sensor.test_kwh40:
friendly_name: Zm_energy_40
state_class: total_increasing
unit_of_measurement: ‘kWh’
device_class: energy
last_reset: ‘1970-01-01T00:00:00+00:00’
while in configuration.yaml it is as follows:
test_kwh40:
friendly_name: ‘Zm_kwh_5’
value_template: “{{ (state_attr(‘sensor.Zm_stat_40’, ‘total’) | round(5) ) }}”
unit_of_measurement: ‘kWh’
device_class: energy
I have the same.
In addition, I wanted to plug in the Energy tab, but no matter which entity, sensor, counter I plug in the values no matter how I multiply, divide do not give the actual consumption.
What am I doing wrong? Help…
Teaching aids: