Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch updating? #164

Open
lukescott opened this issue Feb 18, 2020 · 2 comments
Open

Batch updating? #164

lukescott opened this issue Feb 18, 2020 · 2 comments

Comments

@lukescott
Copy link

lukescott commented Feb 18, 2020

Looking at the protocol it seems that it might be possible to capture a batch of updates destined for an Accessory. Currently all the HomeKit libraries just distribute the characteristic updates to each service making it difficult to know if it came from a batch or a single request.

What I mean by "batch" is lets say you issues a Siri command "Hey Siri, Turn Off all the Lights". From what I can tell iOS collects all the changes and sends it to the Bridge Accessory responsible for those lights. Compared to "Hey Siri, Turn Off the Living Room Light" would be a single update.

The reason why I am looking into this is because issuing multiple requests over the Z-Wave protocol is expensive. If you have 20 lights to turn off it takes a long time to complete the request.

With the Z-Wave protocol you can broadcast a command to the entire network. And one thing I'm specifically looking into is multicast (addressing a range of devices). If I was able to get HomeKit to give me a batch of updates I could compose a single command rather than 20.

Does this sound about right? If so, is this something you would accept the PR for?

@brutella
Copy link
Owner

This library currently doesn't distinguish between a single command or a batch of commands. The callback function (see example) is called for every characteristics which is included in the command from the client.

What you could do is to collect those commands over a period of time (eg. 50ms) and then send them via Z-Wave to the actual devices.

@lukescott
Copy link
Author

lukescott commented Feb 18, 2020

I was thinking about adding an "Accessory Updated" event callback around here:

https://github.com/brutella/hc/blob/master/hap/controller/characteristic_controller.go#L93

This could either take []data.Characteristics or an interface array of characteristic.Characteristic[] as an argument. This would allow for updates to be done in batch.

Does that sound good?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants