Being not extremely experianced, I have managed to setup a Energy and Daily Energy sensor, that reads my Tasmota Power, and integrate Watt into kWh and daily cut them off (code at bottom)
However, while this method seems very popular with many examples, I wonder if this is the wisest method: The Tasmotas have their own integration. It is much more precise with a 1-sec read time, compared to the 15-sec (I think) tele-read time. And maybe the chips themselves are even integrating sub-second.
And even worse things happen if the network is down for a bit.
I believe by redoing the integration, we loose a lot of precision, and also expose ourselves to even more mistakes due to network issues.
Is there, and if not should there be, a summation method based on the Tasmota Energy instead of Power? But in such a way that if the Tasmota resets to 0, that this is recognized and the HA counter keeps counting.
So something like, for every new tele-read, it takes the delta-energy, the delta-time, and integrates those, regardless off whether 5 seconds or 5 minutes have passed.
Or am I making some huge thinking mistakes?
My current sensor examples
template:
- platform: integration
source: sensor.tuya_esp12f_energy_power
name: tuya_esp12f_energy_mytoday1
unit_prefix: k
round: 2
- trigger:
- platform: time
at: "11:59:55"
sensor:
- name: Daily Maximum Energy
state: "{{ states('sensor.tuya_esp12f_energy_mytoday1') }}"
unit_of_measurement: 'kWh'