Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: bring back some sort of caching #31

Open
grahambrown11 opened this issue Oct 30, 2022 · 1 comment
Open

Suggestion: bring back some sort of caching #31

grahambrown11 opened this issue Oct 30, 2022 · 1 comment

Comments

@grahambrown11
Copy link

With the free API Token from ESP, you get 50 credits a day, on startup and every hour there after the integration uses 2 of those credits... In normal circumstances this is OK as there are 24 hours a day times 2 is 48, which is under that limit, but I was trying to workout something this afternoon and restarted my home assistant way too many times now my load shedding sensors are broken (except the quota one) 😞
image

I see in the HA Dev Docs they have Restoring sensor states which might be an option, I know last time you used a custom json file in the .cache folder...
It would be nice if you're out of credits the previous state is maintained instead of going to Unavailable/Unknown...
I guess there is danger in having that stale state forever, so it could go unavailable if you couldn't update for more than 24 hours 🤷🏻‍♂️ ...

If I had a better understanding of Python I'd maybe tackle these, who knows maybe next weekend I'll give it a go 😄

Thanks again for making the integration and doing change to ESP

@wernerhp
Copy link
Owner

Thanks for the suggestions.

The .cache used previously was built into the the load shedding abstraction of the library I wrote, but with the way the ESP API works it became a bit complicated, so I've changed the integration to just call the API directly and not work through the abstractions.

I have started looking at restoring sensor states, because I've also run into this problem, but still figuring out how exactly restoring the sensor state this work.

I'm also looking at ways to reduce the number of API calls that are required. Currently it checks every 90 minutes which is around 34 API calls per day for the 2 sensors. I think I might be able to get it down to around 20 calls, which might then also open up the option of adding more than one area sensor in future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants