Static power usage attribute for devices to calculate power usage over time

I have a lot of devices which have a known (and steady) power usage.
So i’m thinking of defining a static usage once in an attribute (eg 12 watt for a LED bulb) and count the power usage during the time it’s switched on so we are able to add them together and display power usage of all devices.

Anyone know if such a component exists, or have an idea how to do this with standard tools already part of Home Assistant?