Feature Request: NFC/PIN Authorized Event as Trigger
dirkgiessamer opened this issue · 22 comments
First of all, great work, much appreciated!
My use case would be that if the G2 Reader Pro „grants“ access to a user (via NFC or PIN, does not matter) this could be used as a trigger to do other stuff in HA (like unarming the alarm system). Quite similar to the „doorbell_pressed“ trigger a kind of „user_authorized“ trigger would be great. And even better to get the userID passed on to i.e. start a different scene on entry to the house for a certain person (play different welcome music etc).
I like this idea! Would it be like a "last_authorized_user" text entity? I'd have to check whether we get user info events on unlocks but if we do, it should be pretty straightforward.
Yes, as long as we get this info right away kind of „onUnlock“ and start an action, that would be perfect!
This would be extraordinary to be able to do that.
https://github.com/imhotep/hass-unifi-access/releases/tag/v1.1.3-beta
If you could help test it and report issues, I'd really appreciate it!
Have you tried opening the door or pressing the doorbell? Can you share some logs?
Have you tried opening the door or pressing the doorbell? Can you share some logs?
Yes, I did, doorbell as well as NFC opening the door - just checked again and now it works!
I like this idea! Would it be like a "last_authorized_user" text entity? I'd have to check whether we get user info events on unlocks but if we do, it should be pretty straightforward.
Did you check on this idea? To get the authorized user?
Yes! It's in this release. Go to Developer Tools > Events > Listen to events and type one of these events then click on Start listening.
unifi_access_entry
unifi_access_exit
unifi_access_doorbell_press_start
unifi_access_doorbell_press_stop
You should get some metadata when the event fires that gives you info on who entered or exited a door. It will be in the actor
field.
hi, just trying this integration and it looks pretty good.
Wondering if it would be possible to get the NFC friendly name or id as well as the actor in the event notificartion in the case where an actor has many NFC cards.
Yes! It's in this release. Go to Developer Tools > Events > Listen to events and type one of these events then click on Start listening.
unifi_access_entry
unifi_access_exit
unifi_access_doorbell_press_start
unifi_access_doorbell_press_stop
You should get some metadata when the event fires that gives you info on who entered or exited a door. It will be in the
actor
field.
Hi Imothep, I'm quite new into this part of the HA. (for now I always created the automations with "standard" building blocks ;-)
When I go into the listen mode I do see the actor filled out as supposed, but do you have a link with examples on how to use this when e.g. the actor is user x then do action y
Hi,
THANK YOU for this integration!
Does this feature mean that I can have automation based on the card that entered the door?
I run a small nursery and preschool, and I want to log pickups and dropoffs using the data from Access. I'd like to be able to display avatars of the kids on the Classroom Dashboard, the number of children in the building for emergencies, and log the children's attendance. Having a trigger to work with from the Access API telling me who has entered and exited would be phenomenal.
This is fantastic. I have just successfully triggered an automation with the event.
I have managed to trigger a notification when the user enters the building.
Superb work.
Edit: unfortunately, the event fires on all readers, whether exit or entry, but I can work with that for now.
I assume I can use the id field to determine which reader it was on.
Do you have any advice on how I can use the context fields as a prerequisite for firing the automation?
Thanks DaleJP!!!
It works...
for your "problem"
if you include the door_id or the door_name it should do the trick.
I only have one Acces Reader, so I can't be 100% sure, but think that should do the trick
You have no idea how happy this integration has made me. I had an esp32 hooked up to the door to get doorbell notifications before.
I mean the "id" field under contexts. They are all different readers on the same door.
The inside reader is registered as "Exit" in Access and the outdoor ones are "Enter" but they both fire the event as entry.
I think that's, because you "enter" the door/gate when leaving in the opposite direction as you "enter" the door when "entering" (if you understand me ;-))
All of the readers show up as entry in the integration, whether inside or outside. It could be the API that's messing up. I know it's pretty new.
Well, I have two readers outside and one reader inside. In Unifi, the inside is marked "Exit" in the settings, the outdoor ones are both "Entry".
Whichever reader I use, it shows up in unifi_access_entry, but with different ids in Context.
To be fair, I haven't listened to unifi_access_exit, yet......
Tried it out on my access unit and got the following using one on the NFC assigned to me:
event_type: unifi_access_entry data: door_name: Cellar door_id: d7e39f94-7fdb-4dab-8852-191fc58b0deb actor: Thorr Tjorvi Einarsson type: unifi_access_entry origin: LOCAL time_fired: "2024-02-06T16:45:09.858770+00:00" context: id: 01HNZMY9B2V08XVW5QR55A2CTZ parent_id: null user_id: null
Then with another NFC chip:
event_type: unifi_access_entry data: door_name: Cellar door_id: d7e39f94-7fdb-4dab-8852-191fc58b0deb actor: Thorr Tjorvi Einarsson type: unifi_access_entry origin: LOCAL time_fired: "2024-02-06T16:50:44.989503+00:00" context: id: 01HNZN8GKXE76RKE9QZH5BB2RH parent_id: null user_id: null
It would be good to know which NFC chip was used
Unfortunately, I think you would need to create a new id for the other card (Like it used to be with multiple cards for one user).
They have encryption etc with the cards so I doubt they will ever expose the raw NFC data. Unifi might expose Card 01, Card 02 or something but I doubt they'll expose the card details over the API.
Sorry for delay, been very busy. I released a new version and updated documentation on how to use the event feature. Looks like you guys have figured it out.
@ttjorvi There is no NFC data accessible through the API as far as I can tell. I didn't dig in too much. Closing this for now but feel free to re-open if you have any questions or suggestions.