Haoyu-UT / HomeAssistantNatureRemo

An integration for accessing Nature Remo from Home Assistant
MIT License
11 stars 1 forks source link

Polling interval for API #4

Closed Fury1SOG closed 3 weeks ago

Fury1SOG commented 1 month ago

Hello,

This integration seems very interesting! I'm currently using Nature Remo in Home Assistant with REST commands, but I am thinking about using your integration.

As you know, Nature Remo API has a very strict API polling limit of 30 requests in 5 minutes. (There is a discrepancy in the API doc; Japanese version says 30 requests in 5 minutes, English version says 30 requests in 1 minute)

May I ask how often your integration sends requests, and is it configurable?

Thank you very much!

Haoyu-UT commented 1 month ago

Hi @Fury1SOG ! Polling is only required for retrieving sensor data. Currently the API polling interval is fixed to 60 seconds, and we have to call 2 different APIs to get all data we need, so it consumes 2 API calls per minute. And each operation by user consumes 1 extra API call. I think it's a good point that we can have configurable polling intervals, like for people utilizing the movement sensor they may want much higher responsiveness. Please let me know if the answer resolves your concern, or whether you need that to be configurable.

Fury1SOG commented 1 month ago

@Haoyu-UT, thank you very much for your reply!

Yes, I think it would be more flexible if the polling frequency was user configurable. For example, I personally do not use the Nature Remo sensors at all, so I would not mind reducing the polling frequency to a very low value.

On the other hand, other people may have situations where they want to increase the frequency to improve the response time of their automations.

By the way, I contacted Nature Remo via their discord and received confirmation that the API polling limit is 30 requests in 5 minutes. The English doc is incorrect.

Haoyu-UT commented 1 month ago

Hi @Fury1SOG ! Thanks for your interest and advice. I'm currently on a vacation so it may take a while before I can implement and test it. As a quick patch you may replace all seconds=60 to some larger values in custom_components/nature_remo/sensor.py.

FYI the integration installation folder is accessible with Samba share add-on. It's in config/custom_components. Just modify the file as normal text file, save it and restart the Home Assistant to apply.

Haoyu-UT commented 3 weeks ago

Hi! I hope that commit 99625d8d44ed7ff70fec6ca5db15903cf48fe6da (v1.0.8) has resolved your issue. Now you can set the polling rates during the setup process. You may close the issue if you are satisfied with the commit.

image
Fury1SOG commented 3 weeks ago

Thank you very much!