arnonym / ha-plugins

Home-Assistant SIP Gateway
Apache License 2.0
182 stars 23 forks source link

help to understand if this is possible #124

Open userMak opened 1 week ago

userMak commented 1 week ago

Hi unfortunately I have almost zero knowledge of sip devices. In my apartment we have a sip doorbell. After 2 weeks (!) of trial and error I managed to add it in HA! (THANK YOU for this beautiful work!)

Right now I can open the door (and see who is ringing the bell) through the android app VDPconnect.

and in my phone I can get a notification with the following automation

- id: Doorbell with ID
  alias: Doorbell with ID
  trigger:
    platform: webhook
    webhook_id: sip_call_webhook_id
  condition:
  - condition: template
    value_template: '{{ trigger.json.event == ''incoming_call'' }}'
  action:
  - action: notify.mobile_app_makis_smartphone
    data:
      message: 'Incoming call from {{ trigger.json.caller }} (parsed: {{ trigger.json.parsed_caller
        }})'

So now I am wondering if it would be possible to be able to open the door through HA. But I can not find any examples of how I could do that.

Can this be done with an actionable notification for example? If yes how I could open the door?

Can someone tell me if this is possible and if it is to give me an example of how can I achieve that?

arnonym commented 1 week ago

That is a bit out of scope of ha-sip. If there is a vcp (first time I hear about that actually) for home-assistant you can try this. If your doorbell can open the door when pressing buttons on your phone you might get lucky with the send_dtmf command.

userMak commented 1 week ago

Hi, my phone can open the door. I have no idea where or how I can sent the commands from HA. I am looking everywhere to find an example I can follow but I can't. How do you sent the commands through HA? Can you describe at least what I have to do / install please. Or is there a document I could read?

** this is the app https://play.google.com/store/apps/details?id=com.vdpconnect.vdp&pli=1

arnonym commented 1 week ago

I cannot find any info on the protocols used by vdpconnect. Can you specify which sip doorbell you're using?

userMak commented 1 week ago

The doorbell ( I think) it is a generic china model which each company who sell it add their logo. Here in Greece they name it Sambo but their support is minimum. Mostly just installation, https://sambo.gr/b2b/DX_439

I have found this UK based company who sell it as CDVI Although they didn't sold their product to me they helped me to update the firmware to the latest version

https://www.cdvi.co.uk/our-products/cdv-43/

here the same doorbell from another company https://dorani.com.au/wp-content/uploads/2022/11/VDP-Support.pdf

here from another company https://doorentrydirect.com/cdvi-2easy-2-wire-1-way-video-kit-with-white-wi-fi-monitor

just found this also https://nywint.com/wp-content/uploads/2020/10/SIP-Divert-Troubl-Sshooting-1.pdf#page=8&zoom=100,68,668

image

I have to add that in the begging in the phone we used an app called 2easy and then they changed it to vdpconnnect.

** Also this is from HA forum another user was with vdpconnect and was trying to open the door also. I have sent a message but I haven't got a respond yet

for example in my case I don't even understand how to perform the dialup or hangup his referring. what do I have to do to perform this dialup? where and how do I dial?

image

arnonym commented 1 week ago

Looks like only the manufacturer of this device knows what is going on, I had no luck to find information about this either.

In your case I would try the 3 different standards to send DTMF tones through SIP ("in_band", "rfc2833" or "sip_info") with all the available keys, maybe it's one of them or it's not DTMF after all. Good luck!

userMak commented 1 week ago

I am trying.. :)

So, I am not sure if what I am doing is right, but I ser the mode to "accept" and I made 3 scripts.

doorbell_hangup:
  alias: 'doorbell hangup'
  sequence:
    service: hassio.addon_stdin
    data:
        addon: c7744bff_ha-sip
        input:
            command: hangup
            number: sip:xxxxx@vdpconnect.com

doorbell_dial:
  alias: 'doorbell dial'
  sequence:
    service: hassio.addon_stdin
    data:
        addon: c7744bff_ha-sip
        input:
            command: dial
            number: sip:xxxxx@vdpconnect.com

doorbell_opendoor:
  alias: 'open door'
  sequence:
    data:
      addon: c7744bff_ha-sip
      input:
        command: send_dtmf
        number: sip:xxxx@vdpconnect.com
        digits: "#1"
        method: in_band # method can be "in_band" (default), "rfc2833" or "sip_info"
    action: hassio.addon_stdin

I don't know if the what is the minimum code I should keep

allowed_numbers: # list of numbers which will be answered. If removed all numbers will be accepted
#    - "5551234456"
#    - "5559876543"
#    - "555{*}" # matches every number starting with 555
#    - "555{?}" # matches every number starting with 555 which is 4 digits long
# blocked_numbers: # alternatively you can specify the numbers not to be answered. You can't have both.
#    - "5551234456"
#    - "5559876543"
answer_after: 0 # time in seconds after the call is answered (optional, defaults to 0)
webhook_to_call: # web-hook IDs which you can listen on in your actions (additional to the global web-hook)
    call_established: call_estblished_webhook_id # can be all the same, or different
    entered_menu: entered_menu_webhook_id
    dtmf_digit: another_webhook_id
    call_disconnected: call_disconnect
menu:
    message: Please enter your access code
    choices_are_pin: true
    choices:
        '1234':
            id: owner
            message: Welcome beautiful.
            post_action: hangup
        '5432':
            id: maintenance
            message: Your entrance has been logged.
            post_action: hangup
        'default':
            id: wrong_code
            message: Wrong code, please try again
            post_action: return

and I can dial, hangup, and probably send dtmf code? see below a part of the logs

20:17:20.897            pjsua_aud.c !Creating file player: /tmp/tmpt1x79rn8.wav..
20:17:20.897           wav_player.c  .File player '/tmp/tmpt1x79rn8.wav' created: samp.rate=24000, ch=1, bufsize=4KB, filesize=115KB
20:17:20.897            pjsua_aud.c  .Player created, id=0, slot=3
20:17:20.897            pjsua_aud.c  Conf connect: 3 --> 1
20:17:20.897           conference.c  .Port 3 (/tmp/tmpt1x79rn8.wav) transmitting to port 1 (sip:0e001a2fea54@vdpconnect.com)
| 20:17:20.897931 [1] No action supplied
| 20:17:20.898161 [1] Scheduled post action: noop
| 20:17:23.317876 [1] Playback done.
| 20:17:23.318079 [ ] Calling webhook sip_call_webhook_id with data {'event': 'playback_done', 'sip_account': 1, 'caller': '<sip:0e001a2fea54@vdpconnect.com>', 'parsed_caller': '0e001a2fea54', 'type': 'message', 'message': 'Please enter your access code'}
| 20:17:23.331484 [ ] Webhook response 200 b''
20:17:23.331            pjsua_aud.c !Destroying player 0..
| 20:17:23.342826 [1] Scheduled post action: noop
| 20:17:31.049137 [ ] Got "send_dtmf" command for sip:0e001a2fea54@vdpconnect.com
| 20:17:31.049282 [1] Sending DTMF #1
20:17:31.049            pjsua_aud.c !Conf connect: 3 --> 2
20:17:31.049           conference.c  .Port 3 (tonegen) transmitting to port 2 (sip:0e001a2fea54@vdpconnect.com)
| 20:17:42.028760 [ ] Got "send_dtmf" command for sip:xxxxxx@vdpconnect.com
| 20:17:42.028887 [1] Sending DTMF #1
| 20:17:44.978820 [ ] Got "hangup" command for sip:0e001a2fea54@vdpconnect.com
| 20:17:44.979044 [1] Hang-up.

So now what do you think? Is it matter to find the correct dtmf? How should I change the sip-1-incoming.yaml file? Do I need it? or can I leave it blank " " in the configuration? The mode is correct? Should I have "accept" or "listen"

Any hints?

arnonym commented 1 week ago

You don't need the incoming file if you accept connections through the webhook or only dial into your device.

Looks good to me without going too much into the details. Only thing is you're sending two DTMF tones currently, so # and 1. You probably only want to send one.

userMak commented 1 week ago

the mode should be listen or accept?

arnonym commented 1 week ago

If you use the websocket hooks it is "listen", if you want to use the incoming file it's "accept".

userMak commented 1 week ago

Sorry, but this is a new world for me. So please confirm that I can open the door with the above scripts in listen mode.

thanks for your time

arnonym commented 1 week ago

The log looks fine. How did you produce it?

userMak commented 1 week ago

with the scripts above. dial - open door - hangup.

I think I am doing something wrong with the dial. I am dialing from the same sip server (IF i have understand correct) and I can not open the open the door even with the vdp application. Since now everyone is sleeping I can not ring the actual bell to make the tests.

Also when I use the dial script although I get notification from home assistant the screen of the doorbell is not turning on and I am not sure if this is right or not.

There are so many parameters I have to debug/test since my knowledge is so limited. :(