I’m looking into creating an automation that can trigger specific scenes based on who has unlocked the door.
The use case is: triggering a specific scene when the housekeeper comes in or a different scene for when guests are walking in.
Each guest / housekeeper will have a specific pincode. I can save the IDs of the codes on my database. If I’ve read the docs correctly, I can setup a webhook to notify my system when the door is unlocked.
Question is: how can I determine (quickly) what code has been used? Would latency be a problem? (I don’t want to take several seconds for the scene to trigger; imagine walking in and lights turning on 30-60 seconds later…that’s not a good experience).
The MQTT topic lockActionEvent follows the format lockAction,trigger,authId,codeId
Get the ID of the event: if codeId is 0, use authId, otherwise you can read codeId (authId is used by all events but keypad events where codeId is used instead)
To get the auth details, you have to query https://api.nuki.io/smartlock/{smartLockId}/auth; the API response will contain the authId == id from MQTT event