rroller / dahua

Dahua Camera and Doorbell Home Assistant Integration
MIT License
404 stars 82 forks source link

Door unlock entity #133

Open AndyLuz opened 2 years ago

AndyLuz commented 2 years ago

Hello First thank you for this great integration. I am trying to catch the door unlock signal from VTH so I can unlock my motorized Wifi lock. And one more question. What does Invite entity do?

Thank you Andy

Lepelot commented 2 years ago

Similar question here: I am trying to catch the door unlock buttons 1 & 2 from the Dahua iPhone App. I can see the events on the Home Assistant events bus, but I don't know how to use this information to trigger an automation. Thanks in advance for the help ... and for all the hard work on this integration.

Lepelot commented 2 years ago

Just for information, I have made some progress on this. Using information from the event bus, I was finally able to trigger my automation with this trigger:

platform: event event_type: dahua_event_received event_data: Code: AccessControl

I still need to find a way to differenciate the two buttons as for now, this trigger respond to both buttons on the App.

AndyLuz commented 2 years ago

Great. I have to try this. I only use one so it makes no difference for me. It would be great if it was included in integration thou.

AndyLuz commented 2 years ago

Too bad. Not working for me.

Lepelot commented 2 years ago

The code might be different for you if you have a different camera. To find the code, you need to go to " Developer Tools -> Events -> and under "Listen to events" enter dahua_event_received and then click "Start Listening" and wait for events to fire " You should get something like this with the code in the middle.

{ "event_type": "dahua_event_received", "data": { "Action": "Pulse", "Code": "AccessControl", "Data": { "CardNo": "", "CardType": null, "LocaleTime": "2022-01-29 18:41:54", "Method": 4, "Name": "OpenDoor", "Password": "", "ReaderID": "1", "RecNo": 43, "SnapURL": "", "Status": 1, "Type": "Entry", "UTC": 1643478114, "UserID": "" }, "Index": 0, "deviceType": "DHI-VTO2202F-P-S2", "serialNumber": "7G06A4DPAJAF45F", "DeviceName": "7G06A4DPAJAF45F" }, "origin": "LOCAL", "time_fired": "2022-01-29T17:41:38.793877+00:00", "context": { "id": "61247e167c11817b10609e8b7f6c78de", "parent_id": null, "user_id": null } }

AndyLuz commented 2 years ago

Wow. It works. Thank you very much for this. I didn't know you can listen to events. Just one question. How do you find out what event_type (dahua_event_received) you have to listen to?

Lepelot commented 2 years ago

Excellent. I got this procedure and the type from the Dahua github discussion, but I wasn't sure which "data" to use from the event. It turns out that using "Code": "AccessControl", is enough. I still need to find out how to deferentiate the two buttons.

AndyLuz commented 2 years ago

Haha. I must be blind. In the event listener there is a column on the right "Active listeners" with every event you can listen to.