Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get doorbell button press state change #235

Closed
1 task done
sesardelaisla opened this issue Nov 21, 2024 · 19 comments
Closed
1 task done

Get doorbell button press state change #235

sesardelaisla opened this issue Nov 21, 2024 · 19 comments
Labels
enhancement New feature or request

Comments

@sesardelaisla
Copy link

Is there an existing feature request for this?

  • I have searched the existing issues

Add-on

Doorbell

Your feature request

Hello,

Would it be possible to get some sort of status/entity change when the doorbell BUTTON is pushed, regardless of the calling state? What I would like to achieve is to have some sort of "silent" notification or partial DnD mode. The idea is to enable a "disabled" schedule/template in the doorbell so no calls are executed according to #231. Caller will hear the "not available" message upon button press. However, selected doorbell users could get a push notification through an automation, so they can call the doorbell back if they really want to respond. A SIP dashboard card would work great for this, because the notification could actionable and have an URI to call the doorbell on the fly.

@sesardelaisla sesardelaisla added the enhancement New feature or request label Nov 21, 2024
@pergolafabio
Copy link
Owner

hmm, not sure if that will work, if you hear a "not avaible" message, it means the outdoor unit isnt able to call something, and i dont think there is any event then logged ... you could maybe setup the sip script at scheduled times , so you dont have the "calling failed/unaavaible" message, that way the sensor / event is fired and you can start your automation

this script below, was intented to fake/simulate an indoor extensions, that register on your primary indoor station, but you can change it , so it can register on your outdoor station at the time intervals you need... but remember, if the script is activated, it wont be able to call your real indoor station/hikconnect ...

https://github.com/pergolafabio/Hikvision-Addons/blob/main/asterisk/hikvision_register.py

@pergolafabio
Copy link
Owner

use this sip nr 10010110001 as username instead of the 10000000005 as in the script
10010110001 is the sip number from your indoor extension (faked)
also change line 69 , change 5061 to 5060 ... the hikvision devices are hardcoded to send the invite back to port 5060 , so then your script intercepts the incoming call too , you can then trigger an sensor ...

@pergolafabio
Copy link
Owner

in example 0.17 is the IP from your OS, where you run the script on, 0.71 should be your outdoor station

@sesardelaisla
Copy link
Author

Interesting workaround... Will check that fake indoor panel approach to see whether I can achieve what I want. Will share feedback if I move forward. Thanks!

@pergolafabio
Copy link
Owner

How did it go?

@sesardelaisla
Copy link
Author

Honestly, I’ve had no time to test it. Will probably find some time by Xmas holidays. Will give an update when able. Thanks for following up!

@pergolafabio
Copy link
Owner

hey, did you try the approach? i get more and more questions about users that dont have an indoor panel or hikconnect.... if the script works to get the doorbell event... we can usee frigate to start the two way audio

@pergolafabio
Copy link
Owner

maybe i can add an extra guide for it ..

@pergolafabio
Copy link
Owner

pergolafabio commented Dec 31, 2024

maybe usefull , with this addon you can do a register on the outdoor, it will probabbly receive the incoming call event...
https://github.com/arnonym/ha-plugins

no need to run s script then

didnt test it yet

PS: when using the script/plugin, make sure to register on port 5065! the sip server on the hikvision device runs on 5065

@pergolafabio
Copy link
Owner

pergolafabio commented Dec 31, 2024

i quicly tried the addon, it works, i added a fake second indoor to my outdoor, with using config below
I used : 10010110002 ... so i need to press 2# on my doorstation , in your case , if you dont have an indoor, use 10010110001 instead....

enabled: true
registrar_uri: sip:192.168.0.70:5065
id_uri: sip:[email protected]:5065
realm: "*"
user_name: "10010110002"
password: XXX
answer_mode: listen
settle_time: 1
incoming_call_file: ""

after starting addon, it registered, and i was able to make a call! to the addon ...
you can then send an answer command and start two way audio, using my frigate guide...

here is log:

it registered:

REGISTER sip:192.168.0.70:5065 SIP/2.0
Via: SIP/2.0/UDP 192.168.0.17:5060;rport;branch=z9hG4bKPjnHG6Pyxr2WaPI7ZY0vUgMTkbMpMF1yto
Max-Forwards: 70
From: <sip:[email protected]>;tag=55DC8CmP0sqPrXDlJfbaa5CNWPtQDbNI
To: <sip:[email protected]>
Call-ID: 9q7jLGQKJET59PYzmCJlhSY36lX1nVqJ
CSeq: 59256 REGISTER
Contact: <sip:[email protected]:5060;ob>;+sip.ice
Expires: 300
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length:  0

incoming call:

INVITE sip:[email protected]:5060 SIP/2.0
Max-Forwards: 19
Via: SIP/2.0/UDP 192.168.0.70:5065;rport;branch=z9hG4bK1920677032
From: "DS-KD8003" <sip:[email protected]>;tag=2707097293
To: <sip:[email protected]:5060>
Call-ID: [email protected]
CSeq: 145 INVITE
User-Agent: HKVS/2.0.0
Contact: <sip:[email protected]:5065>
Allow: ACK, INVITE, BYE, CANCEL, MESSAGE, REGISTER, REFER, OPTIONS, INFO
Content-Type: application/sdp
Content-Length: 387

v=0
o=E40684196 0 0 IN IP4 192.168.0.70
s=Talk session
c=IN IP4 192.168.0.70
t=0 0
a=doorFloor:1
a=responseType:0
a=doorType:0
a=isSpecialType:0
a=isConfirm:0
a=version:V2.0.0
a=lockNum:1
a=isCall:1
m=audio 9654 RTP/AVP 0
a=rtpmap:0 PCMU/8000
a=sendrecv
m=video 9856 RTP/AVP 96
a=rtpmap:96 H264/90000
a=fmtp:96 profile-level-id=42801F;packetization-mode=1
a=sendrecv

--end msg--
09:48:39.506           pjsua_call.c  .Incoming Request msg INVITE/cseq=145 (rdata0x7faafbb90048)
09:48:39.507          pjsua_media.c  ..Call 0: initializing media..
09:48:39.507                icetp00  ...Creating ICE stream transport with 2 component(s)
09:48:39.509                icetp00  ....Comp 1/0: host candidate 192.168.0.17:4011 (tpid=64) added
09:48:39.509                icetp00  ....Comp 1/1: host candidate 172.30.232.1:4011 (tpid=64) added
09:48:39.509                icetp00  ....Comp 1/2: host candidate 172.30.32.1:4011 (tpid=64) added
09:48:39.511                icetp00  ....Comp 2/0: host candidate 192.168.0.17:4036 (tpid=64) added
09:48:39.511                icetp00  ....Comp 2/1: host candidate 172.30.232.1:4036 (tpid=64) added
09:48:39.511                icetp00  ....Comp 2/2: host candidate 172.30.32.1:4036 (tpid=64) added
09:48:39.511                icetp00  ....ICE stream transport 0x7faafbb966a8 created
09:48:39.511          pjsua_media.c  ...Media index 0 selected for audio call 0
09:48:39.512           pjsua_core.c  .....TX 289 bytes Response msg 100/INVITE/cseq=145 (tdta0x7faafbb97998) to UDP 192.168.0.70:5065:
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.0.70:5065;rport=5065;received=192.168.0.70;branch=z9hG4bK1920677032
Call-ID: [email protected]
From: "DS-KD8003" <sip:[email protected]>;tag=2707097293
To: <sip:[email protected]>
CSeq: 145 INVITE
Content-Length:  0


--end msg--
| &id001
| id: null
| message: null
| audio_file: null
| language: en
| action: null
| choices_are_pin: false
| choices: {}
| default_choice:
|   id: null
|   message: Unknown option
|   audio_file: null
|   language: en
|   action: null
|   choices_are_pin: false
|   choices: null
|   default_choice: null
|   timeout_choice: null
|   post_action:
|     action: return
|     level: 1
|   timeout: 300.0
|   parent_menu: *id001
|   cache_audio: false
|   wait_for_audio_to_finish: false
| timeout_choice:
|   id: null
|   message: null
|   audio_file: null
|   language: en
|   action: null
|   choices_are_pin: false
|   choices: null
|   default_choice: null
|   timeout_choice: null
|   post_action:
|     action: hangup
|   timeout: 300.0
|   parent_menu: *id001
|   cache_audio: false
|   wait_for_audio_to_finish: false
| post_action:
|   action: noop
| timeout: 300.0
| parent_menu: null
| cache_audio: false
| wait_for_audio_to_finish: false
| 
| 09:48:39.517846 [1] Registering call with id 10010100000
| 09:48:39.517945 [ ] Add to state: 10010100000
| 09:48:39.518102 [1] Incoming call  from  '"DS-KD8003" <sip:[email protected]>' to '<sip:[email protected]>' (parsed: '10010100000')
| 09:48:39.518147 [1] Answer mode: LISTEN
09:48:39.518           pjsua_call.c  ..Answering call 0: code=180
09:48:39.518           pjsua_call.c  ...Pending answering call 0 upon completion of media transport
| 09:48:39.518273 [ ] Calling webhook sip_call_webhook_id with data {'event': 'incoming_call', 'caller': '"DS-KD8003" <sip:[email protected]>', 'parsed_caller': '10010100000', 'sip_account': 1}
| 09:48:39.535491 [ ] Webhook response 200 b''
09:48:39.537     srtp0x7faafbbc4140  SRTP transport created
09:48:39.537                icetp00  ICE session created, comp_cnt=2, role is Controlled agent
09:48:39.537                icetp00  ICE nomination type set to aggressive
09:48:39.537                icetp00  Candidate 0 added: comp_id=1, type=host, foundation=Hc0a80011, addr=192.168.0.17:4011, base=192.168.0.17:4011, prio=0x7effffff (2130706431)
09:48:39.537                icetp00  Candidate 1 added: comp_id=1, type=host, foundation=Hac1ee801, addr=172.30.232.1:4011, base=172.30.232.1:4011, prio=0x7efffeff (2130706175)
09:48:39.537                icetp00  Candidate 2 added: comp_id=1, type=host, foundation=Hac1e2001, addr=172.30.32.1:4011, base=172.30.32.1:4011, prio=0x7efffdff (2130705919)
09:48:39.537                icetp00  Candidate 3 added: comp_id=2, type=host, foundation=Hc0a80011, addr=192.168.0.17:4036, base=192.168.0.17:4036, prio=0x7efffffe (2130706430)
09:48:39.537                icetp00  Candidate 4 added: comp_id=2, type=host, foundation=Hac1ee801, addr=172.30.232.1:4036, base=172.30.232.1:4036, prio=0x7efffefe (2130706174)
09:48:39.537                icetp00  Candidate 5 added: comp_id=2, type=host, foundation=Hac1e2001, addr=172.30.32.1:4036, base=172.30.32.1:4036, prio=0x7efffdfe (2130705918)
09:48:39.537                icetp00  Stopping ICE, reason=No ICE found in SDP offer
09:48:39.537                icetp00  Destroying ICE session 0x7faafbf36578
09:48:39.537           pjsua_call.c  Answering call 0: code=180
09:48:39.537           pjsua_core.c  ....TX 483 bytes Response msg 180/INVITE/cseq=145 (tdta0x7faafbf6eb88) to UDP 192.168.0.70:5065:
SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 192.168.0.70:5065;rport=5065;received=192.168.0.70;branch=z9hG4bK1920677032
Call-ID: [email protected]
From: "DS-KD8003" <sip:[email protected]>;tag=2707097293
To: <sip:[email protected]>;tag=OBp.ON8-7mwM4Vc9XMag8swX8JvXodD2
CSeq: 145 INVITE
Contact: <sip:[email protected]:5060;ob>;+sip.ice
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS
Content-Length:  0

@sesardelaisla
Copy link
Author

sesardelaisla commented Jan 1, 2025 via email

@spn91
Copy link

spn91 commented Jan 1, 2025

Hi Fabio, happy new year.

You are a real genius with your great ideas. The addon works! Unfortunately the call state is still not changing :(

@pergolafabio
Copy link
Owner

pergolafabio commented Jan 1, 2025

Np!

But you can probably see the event on that addon, and then use the webhook

@spn91
Copy link

spn91 commented Jan 1, 2025

right, that's my plan. At the moment I'm doing it with the asterisk addon and observing the line state of the extension to which the intercom is registered.

Next step is to find a possibility to activate/deactivate the FaceID Feature of the station during 2-way-audio call. Otherwise the intercom throws an authorization error every 5 seconds, while an unregistered person stands in front of the station and speaking via 2-way-audio. Of course this is only a problem because of the unusual way how we are using the intercom.

A lot of workarounds involved to get the cloud free experience :)

@pergolafabio
Copy link
Owner

Good luck! ;-)

@sesardelaisla
Copy link
Author

sesardelaisla commented Jan 2, 2025

Hey! Just checking in to confirm that this workaround works for the purpose I originally open this issue for! After setting up ha-sip as follows, addon registers and webhook reports button press regardless of what schedule is selected, so I can "disable" calls on the doorbell for siesta time or whatever, but I still can get a notification of whatever action upon doorbell call. Strange that I had to enable "Enable Protocol 1.0" under INTERCOM > SESSION SETTINGS for ha-sip to register correctly (200).

sip_global:
  port: 5060
  log_level: 5
  name_server: 192.168.0.1
  cache_dir: /config/ha-sip/audio-cache
sip:
  enabled: true
  registrar_uri: sip:192.168.0.222:5065
  id_uri: sip:[email protected]:5065
  realm: "*"
  user_name: "10010110002"
  password: [INTERCOM > SESSION SETTINGS > REGISTRATION PASSWORD]
  answer_mode: listen
  settle_time: 1
  incoming_call_file: ""

Good to know that it is not necessary to have an indoor station (although I have one) so everything can work straight from the doorbell. I don't like the idea of using two devices if not strictly necessary because if I do so, there will be more points of failures.

I use Asterisk, so just tried with ha-sip because it is simpler to setup and I will have to figure out how to setup a webhook in Asterisk. But now that I know that it works, I hope I can make this work on Asterisk. Thanks!

@pergolafabio
Copy link
Owner

Thnx for the update, can be indeed usefull for others

@sesardelaisla
Copy link
Author

Sad to tell that it doesn't work, or at least it is not consistent. I did some additional tests and webhook is not always delivered if the call button is pressed while Link Time Scheduled setting is set to an empty schedule (calls disabled). Actually, I can't make it work now with the same settings I had a couple of days ago. Will keep doing some additional tests to see whether there is any way to achieve this (just in case I am missing anything/setting I had before), but I guess I won't win. I guess the button press does not do anything that could be captured when an actual call is placed. :(

Hey! Just checking in to confirm that this workaround works for the purpose I originally open this issue for! After setting up ha-sip as follows, addon registers and webhook reports button press regardless of what schedule is selected, so I can "disable" calls on the doorbell for siesta time or whatever, but I still can get a notification of whatever action upon doorbell call.

@pergolafabio
Copy link
Owner

Remember that you can only have 1 active Registation with the same number on the outdoor, for instance,10010110001 can only be registered once, the last registration will replace the previous one... Maybe that's your issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants