Both not tested and written on-the-fly, you should name the sensor correctly and use it as an example, not a copy&paste code, please. I haven’t used unit_prefix myself, but should work, as the documentation states.
I had a further play last night and managed to get the Wh in to kWh so that was one step forward. I created a separate .yaml fine for the conversion and addition of both kWh values. Still not quite there yet as the ‘sensor.solcast_latest_today_forecast’ is just displaying the two kWh values side by side…maybe something to do with using a template…?
Example:
Value #1: 6.52
Value #2: 12.50
sensor.solcast_latest_today_forecast output: 6.5212.50
Yes, the errors are the points where you can learn from.
I was struggling with the sensors too cause they did not seem to work. They only showed 0,00 and I could not believe that after an hour suddenly the energy show 0,01 or 10 Wh burned cause the couch meters only a lamp and an echo show
The example is rounding to early with round 2. Round 4 would be better for newbies to see that their code was right cause it took over an 1hour till I saw a change and result.
I had already struggled a lot till I found out how to get my sensor right “integrated” and here s a list of trial and errors cause I came across this thread due to my google search for “platform integration wh” in the hope to find a code that would.
Here is a list of trials but the first one is the right one. I had started to try with a “direct” access to the tuya plug with source: switch.couch.current_consumption"
And the then I went the attribute way and so on till I found that I simpy had to use my power sensor which I had created before for the Lovelace card to show the W graphs not the Wh which is the area below that graph, therefore the Riemann integration.
But how can I structure my code better cause every sensor now needs its own
“- platform integration” line - I tried to work like in the template section and added sensors: but that brought an error. I have a dozen of these plugs and that looks ugly
OK, thanks - I had thought I am missing something and I can live with that.
I had thought that the platform lines can be reduced like in sensors / template section and that I was missing something.