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

Improvement: use the callback instead of polling #62

Closed
jghaanstra opened this issue Sep 22, 2020 · 4 comments
Closed

Improvement: use the callback instead of polling #62

jghaanstra opened this issue Sep 22, 2020 · 4 comments

Comments

@jghaanstra
Copy link

As far as I can tell this library is using a polling mechanism to get the lockState. As the resource from the bridge are limited this often results in 503 errors. A better approach would be to use the callback mechanism. You can set an endpoint which the bridge calls when a change in state has been detected. This is more reliable, gives faster feedback and reduces the network traffic and load on the bridge.

https://developer.nuki.io/page/nuki-bridge-http-api-1-12/4#heading--callback

It would be a big improvement to have this in Home Assistant.

If you know any javascript you could have a look at this library which was initially developed by me and uses the callbacks: https://github.com/pfreguia/nuki.homey . I can answer questions about this all but I dont know Phyton so I cant actually code it.

@pschmitt
Copy link
Owner

This is a Home Assistant issue rather than a pynuki one.
The callback functionality is outside the scope of this library.
Also, the callback stuff is only useful in regards of observing the state of a Nuki device, you won't be able to perform lock action (lock/unlock) with it. That being said it would make sense to have the hass integration start a local webserver that receives the callback and sets the entity states from there though. I haven't looked into it because of one big limitation of the callbacks: there's no HTTPS support.

@jghaanstra
Copy link
Author

There is no need for an extra local webserver. The Nuki integration for Home Assistant would just have to create an endpoint / webhook within the Home Assistant install where the callbacks can be send and then process them. Not having HTTPS is not a real issue here as probably 99% of the users will be running Home Assistant within the same LAN as the Nuki Bridge. The current integration (as most WiFi integrations in HA) does not use HTTPS as well so why see this as limitation for the callback.

Anyway, seeing the reaction this is not something that is going to happen. I have no experience with coding in Python so it's not something I can pick up myself. Looks like I'm sticking to my own javascript integration.

@pschmitt
Copy link
Owner

I didn't want to be dismissive there. This FR of yours is just out of scope in regards to pynuki.

Please do open an issue on home-assistant/core for this ;)

@jghaanstra
Copy link
Author

Sure no problem. For people who stumble upon this, the feature request can be found here: https://community.home-assistant.io/t/nuki-use-callbacks-instead-of-unreliable-polling/229064

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