Sonoff S40 Energy Usage Accuracy

I bought Sonoff S40 Wifi. I use Sonoff LAN to integrate with HA. However, I found out that I need to install the eWeLink app on my phone and add my device there. After adding the device is now visible to Sonoff LAN. However, it does not have entities for energy usage (kwh)

image

I found this thead and follow the guide below:

How to configure a Sensor so that is useable in in the energy Dashboard - #24 by EdwardTFN

I put the Power (W) sensor as the input on the helper using the Riemann. Is this correct?

Because the reflected energy usage is different from eWeLink app.

HA energy report:

eWeLink app report:

So what’s the real deal here? Am I missing something in the config or what?

That looks correct, however you have to be aware that the Riemann integration is calculated based on points collected over time and the quality of the result will depend on the frequency of the updates (how often your integration gets the info from the device) and the method on sum used, which will depend on the type of device you are connecting to your plug.
Take a look about the methods here and maybe you can find one which reflects better what you see in the Ewelink app.
And I have no idea how the info shown in the eWeLink app is calculated, so I cannot tell you which one is more accurate.

One option for you is to try the eWeLink add-on from this link. I’ve used it before and it worked fine, but I don’t have the same device as you have and then I’m not sure if it would be supported or if the energy value will be imported, but I think it worth a try. However this one is cloud-based.