davidusb-geek / emhass

emhass: Energy Management for Home Assistant, is a Python module designed to optimize your home energy interfacing with Home Assistant.
MIT License
260 stars 51 forks source link

Improvement: Use HomeAssistant Statistics #256

Closed nateguchi closed 1 month ago

nateguchi commented 2 months ago

Hi

My energy usage is updated every few seconds and that causes the data fetch from home assistant to take quite a while. Is it possible to use the statistics API to get the totals / averages for an hour or half hour period to speed things up?

davidusb-geek commented 2 months ago

Yes this could be great, but I just don't know how to do it. The HA API is only able to retrieve normal data, not HA statistics data. Here are the two APIs documentations that are used in the code:

In neither of those it is possible to retrieve statistics data. If anyone finds a solution I'm wiling to take a look at this possibility.

gieljnssns commented 2 months ago

Can statistics be retrieved through the websocket api?

davidusb-geek commented 2 months ago

Can statistics be retrieved through the websocket api?

I don't know, how?