Closed HappySl0th closed 3 years ago
Thanks for the log. For the sensor, you want it to show when the door is unlocked or locked?
That would be good!
If you can, please lock and unlock and see if you capture any additional logs.
2021-06-23 17:33:04 DEBUG (Thread-110) [custom_components.dahua] Data received: {'id': 8, 'method': 'client.notifyEventStream', 'params': {'SID': 513, 'eventList': [{'Action': 'Pulse', 'Code': 'BackKeyLight', 'Data': {'LocaleTime': '2021-06-23 17:33:04', 'State': 8, 'UTC': 1624433584.0}, 'Index': -1}]}, 'session': 540894615}
Was that for a lock or unlock event? Can you do the opposite and post that lot too? I'm curious if the "state" changes.
This is for the unlock event. This doorbell doesnt have a lock function. I found the backlight codes
State | Description 0 | OK, No Call/Ring 1, 2 | Call/Ring 4 | Voice message 5 | Call answered from VTH 6 | Call not answered 7 | VTH calling VTO 8 | Unlock 9 | Unlock failed 11 | Device rebooted
Amazing! This is good. I should have something worked up to use this tonight.
Sorry, things got busy. I'll get to this soon :)
I have a pull request which I believe will add sensors for the unlocking event (along with others). https://github.com/rroller/dahua/pull/31
Note that you can currently capture these events on the HA event bus. The PR just makes a sensor out of the events. I'm debating if I should ship the code or not, it'll add a lot of additional sensors which could be confusing but also makes things easier for automations.
I've updated the readme on how to create automations from the event bus - https://github.com/rroller/dahua/blob/main/README.md#events
I tested out event listening and it was able to ping back a code: accesscontrol and action: pulse. I am not sure how to get a binary sensor to trigger remote unlocking, as your readme is more for automation creation and not sensor creation.
Note that you can currently capture these events on the HA event bus. The PR just makes a sensor out of the events. I'm debating if I should ship the code or not, it'll add a lot of additional sensors which could be confusing but also makes things easier for automations.
I think better to stay almost with events instead of additional sensors. For VTO it's will be useful to have door bell ring binary sensor (BTW will be great if you will found the way to stop ring like VTH can do if you press hangup button, in this case it's will be door bell ring switch) and maybe lock/unlock sensor but it's should have timer inside for unlock period.
You can copy useful VTO automation's (or give a link) from here Here you can also get idea how to make lock/unlock binary sensor, take a look for timer.door_lock
Thanks for great job!
PS: BTW Dahua VTH's also support DHIP protocol but I doesn't found any useful functionality which can be implemented, maybe clear call logs and use VTH security menu to control Home Assistant alarm control panel. I think it's also possible to stop door bell ring using VTH command but in this case the configuration will looks strange for users. 😊
PS2: Lock/unlock can be also a switch, which will allow to remotely unlock door and show current lock/unlock status if it's unlocked by VTH or application.
@myhomeiot Thanks, I used your code and it works great.
I'm debating if I should ship the code or not, it'll add a lot of additional sensors which could be confusing but also makes things easier for automations.
@rroller what if you disable some less popular entities by default, like Home Assistant advices in their gold quality scale.
From dev docs:
Supports entities being disabled and leverages Entity.entity_registry_enabled_default to disable less popular entities
Then people can opt in and use those sensors if they are looking for them. Solves both problems in my view.
I personally don't need any of those sensors, and people could use the events, but I thought this would be a nice solution to your problem.
I have a VTO2202F doorbell which have remote unlocking, can you add this as a binary sensor? The following is what I can find with the work "lock", I am not sure if this is the debug line you are looking for. If you need more debugging, let me know. Cheers
2021-06-22 03:11:07 DEBUG (Thread-43) [custom_components.dahua] Data received: {'id': 4, 'params': {'table': [{'AccessProtocol': 'Local', 'CloseAlwaysTime': 1, 'EntranceLockChannel': 0, 'OpenAlwaysTime': 0, 'State': 'Normal', 'TimeSchedule': [{'TimeSection': '00:00-23:59'}], 'UnlockHoldInterval': 2, 'UnlockReloadInterval': 15}, {'AccessProtocol': 'Dahua', 'CloseAlwaysTime': 1, 'EntranceLockChannel': 0, 'OpenAlwaysTime': 0, 'ProtocolType': 0, 'State': 'Normal', 'TimeSchedule': [{'TimeSection': '00:00-23:59'}], 'UnlockHoldInterval': 2, 'UnlockReloadInterval': 15}, {'AccessProtocol': 'Remote', 'Address': '0.0.0.0', 'CloseAlwaysTime': 1, 'EntranceLockChannel': 0, 'OpenAlwaysTime': 0, 'Port': 10001, 'State': 'Normal', 'TimeSchedule': [{'TimeSection': '00:00-23:59'}], 'UnlockHoldInterval': 2, 'UnlockReloadInterval': 15}]}, 'result': True, 'session': 1687891641}