Hi all
Just thought this might help someone else. I have some Arlec branded “Smart Plug” devices that can monitor energy usage (for the Australians out there, they are about $20 from Bunnings). Rather than use the Grid Connect app I have added them into Smart Life and they appear in HA using both the Tuya and Tuya2 integrations. Only minor issue is although Smart Life tracks the energy usage, in HA they show the amount of W being used at the moment, but not the total kWh use over time. After some mucking around I found that literally all I needed to do was add the following into my configuration.yaml file:
- platform: integration
source: sensor.ty314159265666666666
name: Main Fridge Energy
unit_prefix: k
round: 2
Where “sensor.ty314159265666666666” is the name of the sensor in tuya2 that directly shows the amount of W being consumed by the appliance plugged into the device. The unit_prefix and round settings converts the data to kWh, and the new sensor will start to log the energy being used over time. After testing your config then restarting the server, and some data has been collected, the new sensor should appear in the drop down options in the energy section configuration.
If you are still using the older Tuya integration, it will be a little more complex as you will likely need to create a sensor for that by using a template to grab the info out of the sensor attributes.
Info about this is here: Integration - Riemann sum integral - Home Assistant