Tuya Plug Energy Monitoring

After adding the plug to Tuya (Using cloud integration) and adding an integral to monitor the consumption, the energy displayed is way off. What am I doing wrong here? Please ask question so I can provide correct information.

You could start by telling in what way the energy is “off” , i.e. to high , to low etc.
Also you have not told anything, so hard to tell if/where you did something wrong( if at all)

If you have some code/card, please post it “formatted correctly”
Format code in posts>
How to help us help you - or How to ask a good question.

also show your “Integral” , as you just shows pictures of entities, which ALL shows values, which are not unlikely, it’s impossible to guess what you mean

I have read more and tried different setups but I got lost. I got something working but it was something that was left over from an attempt that was not existing.

Here is where I am at now. I have the Tuya plug power sensor attached to a custom sensor but it does not seem to work as it should.

My guess is that I am not setting the state properly to update the statistics.

template:
  - sensor:    
      - name: "PC Energy Consumption"
        unique_id: pc_energy_consumption
        state: >
          {{ (states('sensor.pc_plug_power') / 1000 | float )}} 
        device_class: energy
        state_class: total_increasing  # total or total_increasing
        unit_of_measurement: kWh

This is coming from Tuya (not local I couldn’t get that to work)


I realized that I am trying to divide a string by 1000 so I updated that from

          {{ (states('sensor.pc_plug_power') / 1000 | float )}} 

to

        state: >
          {{ (states('sensor.pc_plug_power') | float / 1000 ) }} 

Now going to wait and see if that works as it should. Please let me know if you see anything else that I done wrong.

Here is an error I got in the logs. Also the tracking is not correct compared to the Tuya App

Logger: homeassistant.components.sensor.recorder
Source: components/sensor/recorder.py:302
integration: Sensor (documentation, issues)
First occurred: 10:50:10 AM (1 occurrences)
Last logged: 10:50:10 AM

Entity sensor.pc_energy_consumption from integration template has state class total_increasing, but its state is not strictly increasing. Triggered by state 0.21 (0.2237) with last_updated set to 2024-07-02T08:47:35.075646+00:00. Please create a bug report at https://github.com/home-assistant/core/issues?q=is%3Aopen+is%3Aissue+label%3A%22integration%3A+template%22

Currently testing this.

sensor:
    - platform: integration
      name: "PC Energy Consumption"
      unique_id: pc_energy_consumption
      source: sensor.pc_plug_power
      unit_prefix: k
      round: 2
      method: left