How to get energy (kWh) out of power (W) entity?

Friends of HA,

Today I included this Gosund Tuya socket into my HA. I wanted to integrate it into my energy dashbord. However, entity was not showing up. In this FAQ I found out that the entity attributes are wrong, i.e. device_class was “power” instead of “energy” and state_class was also wrong. I tried to manually set the correct values:


However, that did not seem to have any effect. Still cant add the device in my energy dashbord.

All my other plugs are zigbee devices. Never had problems.

Any other ideas what to do?

Here’s how to convert power to energy:

Basic energy monitoring.

2 Likes

The outlets attributes aren’t ‘wrong’ - you can’t change what it reports just by editing items in the development console. They are reporting device class Power not Energy because that’s what it reports. Power is NOW. Energy is the measurement of power over time.

You need to undo that change before you read the article StillJack posted…

1 Like

Gosh, did I really mix up power and energy? I blame it on the language barrier :innocent:

Anyways, thanks for the link to the basic energy monitoring. I was able to create the helpers:


However, I still struggle to integrate the new helpers in my energy dashbord. Wont show up as new device to add:
grafik

And given that the energy dashbord requires a sensor entity to have “state_class: energy” it makes sense that its not visible. Any idea how to change that?

Couldn’t things ONCE be easy? :wink:
But of course, that change does not make sense since its only showing W not Wh.

It seems to have just taken a while until the helper became available to the energy dashbord. Today it was showing up:
Bildschirmfoto 2024-04-02 um 17.38.09
I integrated it and it displays reasonalble values (its a cettle):

My advice to anyone reading this: dont buy this plug if your are interested in energy values.

thanks @NathanCu and @Stiltjack