heyajohnny / cryptoinfo

Provides Home Assistant sensors for all cryptocurrencies supported by CoinGecko
GNU General Public License v3.0
49 stars 14 forks source link

feature request: poll distribution #48

Closed h8hr1pzdo3rmiqv5 closed 5 days ago

h8hr1pzdo3rmiqv5 commented 2 months ago

Problem encountered: I want to track a lot of coins (say, 60), and only need a daily update. I could poll the CoinGecko API once every minute during 60 minutes, which would meet their API rates. However, the current version of CryptoInfo sends a poll for every coin at once when starting, then will poll according to update_frequency.

Possibles ways to resolve this: • poll queue: set an extension-wide variable (minutes between each poll, for example), which would serve to queue the sensor updates if the rate has been reached; • poll hour: on a sensor level, instead of update_frequency, have the possibility of setting update_schedule, which would let the user set when exactly the poll has to be sent (crontab-like, for example).

Thank you.

heyajohnny commented 1 month ago

I'll see what i can do I first need to refactor some code and probably can add this feature while doing the refactor. I'll let you know when I'm starting on this

heyajohnny commented 3 weeks ago

I've made a beginning with the code update. I'll let you know when I've got something usefull

heyajohnny commented 6 days ago

I've just released a new version. Please let me know if this fixes your problem.

You can now use multiple cryptocurrencies in 1 sensor. This has the advantage that only 1 request goes to the Coingecko API that updates the values ​​of the multiple cryptocurrencies. Also a property has been added to set the minimum request time between multiple sensors

h8hr1pzdo3rmiqv5 commented 5 days ago

Hello, big refactor indeed! Thank you. It seem to solve that issue in particular.