mindmelting / hass-powerpal

Home Assistant custom integration to fetch data from Powerpal
MIT License
44 stars 11 forks source link

Consumption chart seems to be linked to time of sync, not time of usage #5

Closed maxw3l closed 2 years ago

maxw3l commented 2 years ago

Version of the custom_component

f7e8b30

Describe the bug

The Total Consumption chart seems to be calculated based on the time of syncing the data, not the actual time of usage. This shows it fairly clearly: image

Compare with actual usage per hour from Powerpal app: image

Is this a bug or a limitation of the API?

mindmelting commented 2 years ago

Hey @maxw3l - thanks for using - in its current implementation this is not a bug - it evaluates total_watt_hours from the API (which is total consumption) every minute. This works fine if your Powerpal app is updating the servers with readings consistently - which means you need to have it running on a device that is connected to Powerpal 24/7 (I have mine running on an old iPad which I also use as a HA wall mounted dashboard)

Now there is also an API for getting historical usage - however I haven't found a neat way of getting that to play nicely with HA and the energy dashboard yet (will look at it again).

If all works nicely you should get a dashboard that is pretty close to what Powerpal reports - and within a few cents of what your bill shows for that day.

Let me update the documentation shortly to be clear on how this works internally!

maxw3l commented 2 years ago

@mindmelting cheers, thanks for the explanation.

As you thought, I'm using it on my phone which isn't connected full time, explaining the disconnect in the figures.

Awesome work getting HA to interface with Powerpal at all! Very clever.

mindmelting commented 2 years ago

@maxw3l I will relook into using batched historical data (which would more suit use cases where devices are not 24/7 connected) soon!