homebridge-plugins / homebridge-roomba2

Homebridge plugin to connect iRobot Roomba devices with Homebridge/HomeKit.
MIT License
143 stars 17 forks source link

[Request] Changing polling interval behavior #112

Closed Write closed 1 year ago

Write commented 2 years ago

Hi, my Roomba makes a huge coil whine as well as LEDs On, when connected to it (either app opened, or this plugin).

I would like to change the behavior to the polling system, maybe add multiples mode. My idea is to have 3 modes : Interval, on HomeKit opening, and Hybrid.

Thanks a lot for reading.

Edit :

After watching the source code, such behavior is already implemented, though, timers should be able to be changed through the config.

I don't know exactly how HomeKit Sensors automation work. I'm guessing that we must actively watch Roomba's status if we want to do so.

Would be great to have the status constantly refreshed only while cleaning, and such timer cancelled if docked and charging. If we instruct Roomba to go home, use WATCH_IDLE_TIMEOUT_MILLIS timeout instead. That would allow sensors automation while not constantly pulling status (and waking up it's led + coil whine).

Thanks.

Write commented 2 years ago

I made a patch to implement a new TIMEOUT timer, which keeps the plugin actively watching Roomba while the vacuum is busy. (Either if not charging or running or docking).

Once the Roomba is not 'busy' anymore, it'll decrease then decrease this new timer, instead of WATCH_IDLE_TIMEOUT_MILLIS.

WATCH_IDLE_TIMEOUT_MILLIS would still be used of course, for example when the Home app is opened.

This allows me to put a much shorter WATCH_IDLE_TIMEOUT_MILLIS while still watching actively the Roomba when it's running or not charging.

My code certainly doesn't respect best practice, and maybe out of the scope of this plugin.

Either way, there is the link of my fork accessory.ts.

And the commit's link

karlvr commented 1 year ago

@Write thank you for this description of your thinking. This sounds like a good addition. I will take a look at what you've done today—I've already looked at it in the context of #127, but this information will help me to understand what you're intending.

I wanted to avoid adding too many configuration options. I wonder if the only timing configuration people might need is how often to check status when Roomba is idle, to support automations etc.

karlvr commented 1 year ago

@Write I've decided to adapt what you've done along with refactoring the connect and watching parts of the plugin. I've referenced the relevant commits above. As above, I'm aiming not to have too many configuration options, but I have added the option for how long the long watch interval should be. Please take a look and let me know what you think; if I've captured everything that you intended; and if it works in your situation.

karlvr commented 1 year ago

The new behaviour is released in v1.4.0. Please re-open this issue if there are any problems or deficiencies.