ecoen66 / homebridge-solaredge-inverter

SolarEdge Inverter plugin for homebridge
MIT License
14 stars 8 forks source link

Frequency of API calls #11

Closed gdotp01 closed 3 years ago

gdotp01 commented 3 years ago

Looking at the logs it looks like every 2 minutes or so there is a call to solar edge. I looked at previous issues and you mentioned it only made a call when a user looked at the Home app. However I’ve not had it open and it’s continued to make calls.

ecoen66 commented 3 years ago

You are correct. That changed after merging in a contributor's code which provided all of the additional functionality, beyond my original current production monitoring.

gdotp01 commented 3 years ago

It looks like it makes a call every 15 minutes but then reports this 9? Times in the log within a space of a couple of minutes. Would it be possible to reduce the log writes to just one? As it does clog the log up a bit.

Also is there a limit with Solar edge on the number of api calls, I presume that 100 or so a day is ok?

ecoen66 commented 3 years ago

Try 0.1.7. I added a polling interval to throttle the API calls and use the cache instead. It will only poll when looked at in HomeKit, which is the way it worked prior to the addition of many ancillary light meters, etc...

I still need to rewrite this when I have time. I need to change it from a pull model to a push model - where the plugin sends update notifications to HomeKit, versus allowing HomeKit to ask the plugin for new data. That will be much more efficient, and will still use the polling interval.

gdotp01 commented 3 years ago

Ok thanks. I’ll give it a go and get back

ecoen66 commented 3 years ago

FYI... The Solaredge API has a limit of 300 requests a day.

gdotp01 commented 3 years ago

Hi, I’ve got 0.1.7 and it now only calls when I open home which is good as it limits API calls. Of course the issue is now that the automation I’ve set up as the values don’t change unless I’m looking at Home. What would’ve good is a bit of both, an update if you use home but an API called every n minutes that is configurable via the setup parameters?

ecoen66 commented 3 years ago

No more changes from my end for now. Day job is a bit busy. I have a full re-write in mind.

gdotp01 commented 3 years ago

Ok. In which case I’ll revert to V 0.1.5 and set the API calls to every 30 minutes for now. Thanks for your effort on the plugin it’s appreciated.

ecoen66 commented 3 years ago

Entire re-write in V 0.2.2. Using a push vs. pull model for updating HomeKit. Minimized API calls to a single one at startup, and a single call per API (as required for power & for battery based on config settings) every update_interval.

Please let me know if this works for you. If so, I will close this.

gdotp01 commented 3 years ago

Ok thanks. Brilliant job. I’ve downloaded and it appears to be working but I’ll see tomorrow when we get some sun.