rroller / dahua

Dahua Camera and Doorbell Home Assistant Integration
MIT License
369 stars 71 forks source link

AV-VTA05-22AV2 - Get Button Press #329

Open Marcwa19197 opened 6 months ago

Marcwa19197 commented 6 months ago

Hello,

thanks for the integration! Im using a AV-VTA05-22AV2 with 2 Bell-Buttons. (2-family House).

How can i get the press of one of the buttons to trigger an automation in Home-Assistant?

Thank you very much.

mooton85 commented 6 months ago

In developer tools go to events and subscribe to dahua_event_received, the press the button and see if an event comes through specific to those buttons

Marcwa19197 commented 6 months ago

I can see those events:

event_type: dahua_event_received
data:
  Code: InterVideoAccess
  action: Pulse
  index: "0"
  data:
    Type: WebAllLogout
  name: sprechanlage
  DeviceName: sprechanlage
origin: LOCAL
time_fired: "2024-01-04T16:09:51.269515+00:00"
context:
  id: 01HKAKSXD5YAPQEBJQW8M82XT5
  parent_id: null
  user_id: null

  event_type: dahua_event_received
data:
  Code: InterVideoAccess
  action: Pulse
  index: "0"
  data:
    Type: WebAllLogout
  name: sprechanlage
  DeviceName: sprechanlage
origin: LOCAL
time_fired: "2024-01-04T16:09:21.272477+00:00"
context:
  id: 01HKAKS03RZTDG1JYASE356MK0
  parent_id: null
  user_id: null

event_type: dahua_event_received
data:
  Code: InterVideoAccess
  action: Pulse
  index: "0"
  data:
    Type: WebAllLogout
  name: sprechanlage
  DeviceName: sprechanlage
origin: LOCAL
time_fired: "2024-01-04T16:09:13.999935+00:00"
context:
  id: 01HKAKRS0FAY5DT61696DASQDE
  parent_id: null
  user_id: null

  event_type: dahua_event_received
data:
  Code: VideoMotion
  action: Stop
  index: "0"
  name: sprechanlage
  DeviceName: sprechanlage
origin: LOCAL
time_fired: "2024-01-04T16:08:27.929443+00:00"
context:
  id: 01HKAKQC0SXP7ASFN5WBTPH3WZ
  parent_id: null
  user_id: null

  event_type: dahua_event_received
data:
  Code: VideoMotion
  action: Start
  index: "0"
  name: sprechanlage
  DeviceName: sprechanlage
origin: LOCAL
time_fired: "2024-01-04T16:08:02.037914+00:00"
context:
  id: 01HKAKPJQNE1DJZMEWZKFY4VF3
  parent_id: null
  user_id: null

  event_type: dahua_event_received
data:
  Code: VideoMotion
  action: Stop
  index: "0"
  name: sprechanlage
  DeviceName: sprechanlage
origin: LOCAL
time_fired: "2024-01-04T16:07:46.938922+00:00"
context:
  id: 01HKAKP3ZTPW8FNZ60Q1WRA7AP
  parent_id: null
  user_id: null

event_type: dahua_event_received
data:
  Code: VideoMotion
  action: Start
  index: "0"
  name: sprechanlage
  DeviceName: sprechanlage
origin: LOCAL
time_fired: "2024-01-04T16:07:37.029873+00:00"
context:
  id: 01HKAKNTA5C0PYQ0SAZA5YM0YB
  parent_id: null
  user_id: null

I assume Index = 0 first button, index 1 = second button?

Marcwa19197 commented 6 months ago

i tested with:

event_type: dahua_event_received
data:
  Code: InterVideoAccess
  action: Pulse
  index: "0"
  data:
    Type: WebAllLogout
  name: sprechanlage
  DeviceName: sprechanlage
origin: LOCAL
time_fired: "2024-01-04T16:09:51.269515+00:00"
context:
  id: 01HKAKSXD5YAPQEBJQW8M82XT5
  parent_id: null
  user_id: null

and with

event_type: dahua_event_received
data:
  Code: VideoMotion
  action: Start
  index: "0"
  name: sprechanlage
  DeviceName: sprechanlage
origin: LOCAL
time_fired: "2024-01-04T16:07:37.029873+00:00"
context:
  id: 01HKAKNTA5C0PYQ0SAZA5YM0YB
  parent_id: null
  user_id: null

But with no success - sometimes these events are fired even without pressing the doorbell-button... :-/ someone an idea?

mooton85 commented 6 months ago

I don't think any of those are related to the buttons, the "InterVideoAccess" event seems to be routinely sent on mine too but is unrelated to a button press. The model you have looks the same as the VTO4202 so I'd assume it works the same.

The model I use is the VTO2311R-WP which sends an "Invite" event when the button is pressed, I use this for my doorbell automation.....

platform: event event_type: dahua_event_received event_data: Code: Invite

You have two different buttons so you might get something different.

One thing I have seen before when testing mine was if my VTO was not configured as the SIP server, the events did not come through. How are you using the unit, do you have it registered to a SIP server? If not, I'd make sure you have SIP server ticked in the web browser config of the device.

Marcwa19197 commented 6 months ago

thanks for the reply. I purchased mine on https://www.goliath-shop.de but its just rebranded.

In the webinterface, SIP Server is enabled. IP 192.168.178.110 is the main device. I also have two of the indoor screens.

image

In Webinterface i can see the two klicks as call-type inbound and status of "accepted" or "missed". The missed one was the test click. The accepted one was a test if someone accepted the call on the display. So somewhere there must be the event which i can capture...

(Screenshot in German)

image
Marcwa19197 commented 6 months ago

No one an idea? :-/

mooton85 commented 6 months ago

Since first setting mine up I can see in the documentation that there is an event "BackKeyLight" that relates to VTO events, which should be usable but I guess you don't see these either?

You could try editing the config_flow.py file within the dahua folder in your HA and adding the option for All to the "All Events" section and restart HA (backup your original file first).

Then delete the integration and readd it, this option should then appear in the list of events to subscribe to and will subscribe your HA to all events from that device rather than specific ones. Then test again using developer tools and see which events come through.

Marcwa19197 commented 4 months ago

I was not able to get it working, even with the adjustments to the mentioned config_flow.py file. I added the String "All" to the Array and i was also able to Select it in the UI after readding the integration. Should i select everything or only the newly added "All" Option?

Nevertheless i had some success. But i used VTO2MQTT (https://github.com/intermittech/hassio-addons) seen on https://blog.quindorian.org/2020/08/the-video-doorbell-that-does-home-assistant-nvr.html/ So i was able to fetch the Button-Press via MQTT. I need to do some tests but i assume:

Topic: DahuaVTO > BackKeyLight > Event > Data > State could be: State: 0 <-- Call was canceled by Button press (again) or maybe if Call was rejected (?); Test was succesful while calling, i pressed the button again. So state was "2" for a few seconds and then it (returned) to state "0" and the voice telled me the call was canceled. State: 1 <-- 1. Button pressed (The bottom one), calling; Need to test this State: 2 <-- 2. Button pressed (The Top one), calling; Test was successful with this.

So but there are still some questions / tests open: