dxdc / homebridge-blinds

:sunrise: Homebridge Plugin to control my blinds over HTTP
https://www.npmjs.com/package/homebridge-blinds
ISC License
54 stars 25 forks source link

Any way to group multiple HTTP requests in only one? #36

Closed mrreview closed 4 years ago

mrreview commented 4 years ago

Hello! I'm testing this cool plugin to control my blinds making HTTP requests to python API that I'm developing and is running on a raspberry connected to blind remote controller using GPIO's... I was wondering if it's possible to do this:

When for example I say to Siri to open or close all blinds from specific zone, every accessory from this zone makes its own HTTP request.. is there any way to group all these requests in only one request? because i'm facing a problem to handle multiple requests at the same time...

I should probably do a queue system or something similar to handle all the requests one by one, because for each request I have to "press" a specific button sequence on the controller in order to control each blind. Thank you in advance.

dxdc commented 4 years ago

is there any way to group all these requests in only one request?

Your proposal is somewhat anti how HomeKit / Homebridge works. Because, 1) you still want the option to move blinds individually, 2) even though you chose a "zone" or "scene", that HomeKit (the actual hub) will still send individual requests to each accessory. So, each accessory would have to wait for some prescribed amount of time to even know which requests it should group.

I think your best options would be to:

  1. Add some kind of middleware which can queue your requests (as you pointed out).
    • Node-RED is a great development tool for this and there are terrific plugins for it (including some for Homebridge). I would suggest in this case that you use mqttthing for your blinds plugin, and recreate the logic of this plugin within Node-RED using mqtt to receive those requests. It will be fastest that way.
    • Use some other type of queuing system.
  2. Use multiple blind controllers instead of just one; or, just change your device entirely. This device works great - and can handle 5+ simultaneous requests almost instantaneously: https://bondhome.io/
  3. Just make a new accessory for a "grouped" blind and use that one instead.
mrreview commented 4 years ago

Thank you! much appreciated for your recommendations.