jordenc / io.nuki.smartlock

Nuki Smartlock control for Homey
5 stars 0 forks source link

Feature request: additional triggercards and adding tags #3

Open gruijter opened 7 years ago

gruijter commented 7 years ago

Great app, thx!

I have a request for additional functionality that would greatly improve usability for me:

jordenc commented 7 years ago

Sadly, the way the current app works (by polling the bridge), there is no information available about who opened the lock, or what way it was opened. I can only see the current status (locked, unlocked, locking, unlocking).

However, it seems there has been an update to the API where I can improve this app in 2 ways:

  1. Remove the polling, add a callback instead (The Nuki Lock will access an URL when it gets locked or unlocked)
  2. Read the logs, I might be able to retrieve the username from that.

I will have a look soon, bit busy but it should be do'able in january :)

jordenc commented 7 years ago

Just read the documentation and tried the new functions; there is no way to retrieve a username from the logs.

However, I can create the callback that posts every lockstate update to Homey. That is going to work, as long as you have a "hardware bridge". It does not yet work on the software bridge (the app that you can install on an old phone).

gruijter commented 7 years ago

Thanx for investigating. I have a hardware bridge, so #2 would work for me (and I guess most nuki users).

Concerning the username: could this be something you can take up with Nuki? It seems to be a very valid request to get the user information via the api. It is also available in their own app. I will back you up on this!

jpansy commented 7 years ago

Instead of polling directly the smartlock you should use /list und "the last known state" you get back from it. This does only poll the bridge and not the smartlock itself, therefore does not block the smartlock nor drain its battery.

Obviously webhooks would be even better, quicker and more efficient. Meanwhile they are also supported by the software bridge (like all other v1.5 API commands).

If you want to access log informations you need to go through the Nuki Web API (https://api.nuki.io/).

jordenc commented 7 years ago

I just noticed the update on the Nuki API (1.5) with the callbacks (webhooks) which makes it way more awesome, speedy and battery-efficient. A new version of the Homey app is coming up real soon!

gruijter commented 7 years ago

great news! Any estimated time of arrival for the new version?

jordenc commented 7 years ago

I have started progress on this, I think it will be available for testing in a few days.

gruijter commented 7 years ago

Anything I can test for you already?

chrisboer commented 7 years ago

Hi Jorden please let me know I can assist you also in testing.

jordenc commented 7 years ago

I just need to find some time to finish the "API" side of the Nuki app. I already made some progress, meaning it is already working to check if the "Homey" IP URL is already set in Nuki as a webhook and if not, it will be added.

I am also able to "receive" the webhook call and now I just need to "get" the right device to be able to trigger on the unlock. I think I already have the right code for that lying around somewhere but will have to implement it. So it really is a matter of finding the code (I think I have it in my Synology app), adding it, and then I only have to test it.

By the way, I had to "directly" call Homey from Nuki, because Nuki does not allow https calls. I talked to Athom about a possibility to use a non https webhook but they said it's best to just use the "direct" call to Homey instead of the Athom webhook. So this means you should make sure that Homey has a fixed IP. At least until Nuki enables https webhook calls :)

I will double check if it really doesn't work, but the manual says it doesn't :)

gruijter commented 7 years ago

Ok, keep up the good work. I have Homey on a fixed ip by the way, so for me this would work fine :)

jordenc commented 7 years ago

Just uploaded a new version that uses the new webhook function to directly call Homey after a lockstate changes. However, with that function I can only retrieve the Nuki ID / state / batterycritical / IP address of the bridge.

Still have to investigate if it is a lot of work to look up the user that did this with the new webApi of Nuki.

gruijter commented 7 years ago

Ive been using v0.1.5 for more than a week now and it seems to work just fine. At least it does the same thing the polling version did, but hopefully with a lot less battery usage. Are you going to publish in the appstore soon?

Any news on the user lookup?

jordenc commented 7 years ago

Bas has sent me some improvement guidance for the app, which I need to add before he will approve it. Just need to find some time for that, perhaps this weekend.

About the user lookup; I have to ask Nuki for a developer key on their Slack channel. So first have to find out how to join that ;) Will do that soon

gruijter commented 7 years ago

happy easter ^o^

any news on the user lookup?

jordenc commented 7 years ago

No news yet, been too busy with other stuff. I have, however, asked Nuki to get an invite. No reaction yet.

jpansy commented 7 years ago

Invites for the slack channel are sent out automatically as soon as you sign up. If you haven't received it, it might have ended up in a spam folder. Please retry. If it fails again, we can add you manually if you mail us at developer@nuki.io

However you can manage API keys&tokens inside https://web.nuki.io at any time.