Tuya - possibility to add on energy dashoards

Current Tuya integration provides power, voltage and current for smart sockets, but although SmartLife app shares also total electricity (kWh) it is not available through integration. I believe adding it and enabling usage on the energy dashboard will be really helpful :slight_smile:

I was not aware that smartlife is capable of this, good to know.

On the other hand, until it is exposed by the integration itself, you can create integration (mathematical term) sensor to calculate kwh inside home assistant and add it to energy dashboard.

Yes, I plan to do it that way for now, but just it would be easier if no migration is needed and would be visible together with whole device :wink:

Here you have SmartLife example:

1 Like

One more thing - I think that integration based entities are unable to be mounted under Energy dashboard :confused:

Work for me.

Got it - I changed sth in Tuya and as I removed data it just didn’t have anything to integrate :sweat_smile:

First, i created a specific sensor for W data. If you don’t have it as it might be just an attribute of a switch, first expose it as a separate sensor. Then using integration integration, created kwh sensor. Pasting my example below. Excuse me if there is any mis alignment

  - platform: template
    sensors:
      washing_machine_current_consumption:
        unique_id: washing_machine_current_consumption
        friendly_name: Washing Machine Current Consumption
        value_template: "{{ state_attr('switch.washing_machine','current_consumption') }}"
        unit_of_measurement: 'W'
        device_class: power


  - platform: integration
    source: sensor.washing_machine_current_consumption
    unit_prefix: k
    round: 2
    name: washing_machine_energy_consumption

1 Like

Sorry, I wrote wrong - it didn’t work, because it was undefined (there was no current to start calculating power). As a result - it didn’t show as selectable for the energy dashboard. When current started to flow - it started to work.
Unfortunately inaccurate due to some Tuya integration/API bug (it makes my voltage usage 10 times greater).

Does anyone have this working? I’ve just added a Tuya plug and can see in the Smart Life app that it tracks kWh but in Home Assistant I am not able to add anything for the plug to the energy dashboard.

current and voltage, you should add " 0.1 " as “scale/scaling-factor” , due-able direct in local-tuya integration, for “official_tuya” you might wanna do it in configuration.yaml (or where you configure the devices)