user2684 / imou_life

Home Assistant custom component for controlling Imou devices
MIT License
128 stars 21 forks source link

API usage #97

Closed Roby2002 closed 1 month ago

Roby2002 commented 8 months ago

Hi, how do I get a counter of calls made to API? In one day I went from about 29500 available calls to 0, but I practically didn't use the integration, in the sense that I have 4 cameras configured but I only used the .ptz_location service to move them a couple of times, I don't understand how it's possible. Before purchasing other calls I would like to solve the problem that caused them to be reset.

Thank you

user2684 commented 8 months ago

Hi, https://community.home-assistant.io/t/imou-life-cloud-integration/462439/202, for your reference. I'm evaluating to provide a way to count api calls, now you can enable debug mode but you would need to count them by yourself which is not handy. But you should not have reached the limit so quickly with just few cameras. Do you have a polling interval different from the default? (15 minutes)

Roby2002 commented 8 months ago

Hi, first of all thanks for the quick response. No, I didn't change the polling time, but now I'll raise it. Just to understand how calls are counted, is a camera call made every 15 minutes (default)? And is every action, like moving (imou_life.ptz_location) or activating a button another call? Or is a call made to each camera entity every 15 minutes? Can it be useful to reduce the number of monitored entities? Thanks again

user2684 commented 8 months ago

Every 15 minutes each camera makes a call for updating the status of each configured switch, this is it. Changing the status of a switch would result in an API call, regardless of the polling interval. ptz would result in a single call as well. If you don't call the service, no calls are made. Reducing monitored entities would reduce the calls, definitely. But still 30000 calls are a lot to consume in a single day....

Roby2002 commented 8 months ago

Yes, you're right, maybe it's also due to the fact that I was doing some tests and I restarted it several times HA. However, I did the calculations and with my 4 cam configuration with 25 entities I would have used up the calls in just over 3 days (25*4 entities for 24 hours, 4 times an hour makes 9600 calls per day). Possibly there is the possibility of disabling polling for example by setting 0 sec

user2684 commented 8 months ago

0 does not disable polling, maybe this could be added as an option in the future, good idea. But if you put there very high values, should do the same job. And then you can verify if the api call counter continues to increase. For any doubt, if you enable debug logging in the integration (https://github.com/user2684/imou_life?tab=readme-ov-file#debugging) you should see if something unexpected takes place.

tapsystem commented 6 months ago

Hello, another questions on this point : do you think i can reduce api call disabeling unused sensors ? or it's a bad id ?

tapsystem commented 6 months ago

Hello, another questions on this point : do you think i can reduce api call disabeling unused sensors ? or it's a bad id ?

Still testing but it's llok to be a good solution : more than dive by 2 at the moment

user2684 commented 5 months ago

Hi, the more entities you disable, fewer calls are made against the API so definitely yes. Have a look here for more details: https://github.com/user2684/imou_life/wiki/Imou-API-usage-restrictions