AD410 - Option to Disable Bell Chime at Doorbell

Have a Smart Feature idea/Request Post them here.
evets122
Posts: 5
Joined: Thu Aug 18, 2022 7:29 pm

Re: AD410 - Option to Disable Bell Chime at Doorbell

Post by evets122 »

Thank you! To send the custom sound you would need to use this curl request:
curl --request POST --url 'http://<user>:<password>@<doorbell_ip_address>/cgi-bin/audio.cgi?action=postAudio&httptype=singlepart&channel=1' --header 'content-length: 9999999' --header 'content-type: Audio/G.711A' --max-time 3 --data-binary @<output_name.al>

For anyone who is interested, here is my workflow. It's through Home Assistant so YMMV depending on your setup (I pieced a lot of this together from different posts on the forums).
  • Disable the chime completely using the command: http://<doorbell_ip_address>/cgi-bin/configManager.cgi?action=setConfig&VideoTalkPhoneGeneral.RingFile=0
  • Prep the audio file. I used Sox with the following command: sox -v 0.8 <input_name.ext> -r 8k -c1 <output_name.al>
  • On Home Assistant, set up the Dahua Home Assistant integration and add the doorbell.
  • When the doorbell button is pressed, an event is fired on the Home Assistant event bus. I have an automation looking for this event as a trigger:
    - platform: event
    event_type: dahua_event_received
    event_data:
    Action: Start
    Code: CallNoAnswered
  • The Action of the automation is a "Call service" action type for a "Shell Command: doorbell_chime" service I created. Something like this would need to be added to the configuration.yaml file in HA first:
    shell_command:
    doorbell_chime: bash /config/shell/doorbell_chime.sh
  • To send the sound to the doorbell a curl POST request is needed, so the doorbell_chime.sh file contains the following code:

    #!/bin/bash
    curl --request POST --url 'http://<user>:<password>@<doorbell_ip_address>/cgi-bin/audio.cgi?action=postAudio&httptype=singlepart&channel=1' --header 'content-length: 9999999' --header 'content-type: Audio/G.711A' --max-time 3 --data-binary @<output_name.al>

    I found that if you don't add --max-time #, the POST request never actually exits so you can't send another request; the --max-time exits it.
That's it! You don't necessarily need to use Home Assistant since it's just a simple curl command sending the ring file, although I'm not sure how you would pick up the event of the doorbell being pressed. Perhaps the Python Amcrest project. I just finished setting this up last night so I'm sure it can be tweaked more but it certainly works!
GaryOkie
Posts: 418
Joined: Mon Apr 27, 2020 7:23 pm

Re: AD410 - Option to Disable Bell Chime at Doorbell

Post by GaryOkie »

@evets122 - I completely missed your detailed reply that started on a new page and just now discovered it.

Hey - this works great! It took me a bit to understand G.711A audio formats and what exactly this Sox app was doing. Just an FYI - I found a free online tool at G711.org that will convert MP3 or other sound files to a compatible file that is a simpler alternative to installing Sox.

The 3 second max time works just fine to complete the POST operation. There is an alternative way to send a multipart stream where the second part is a boundary that will terminate the POST. That's a bit more complicated to deal with and not really needed for AD410 announcements.

Here's a screenshot of the G711.org File Converter free online app:
g117a.png
g117a.png (135.85 KiB) Viewed 7637 times
GaryOkie
Posts: 418
Joined: Mon Apr 27, 2020 7:23 pm

Re: AD410 - Option to Disable Bell Chime at Doorbell

Post by GaryOkie »

yet another alternative to Sox that would be of particular use in Home Assistant automation. You can use ffmpeg, which is already installed on HASS docker to convert sounds files to G117-compatible format - like so:

ffmpeg -i audio_test.mp3 -c:a pcm_alaw -ac 1 -ar 8000 -sample_fmt s16 audio_test.al
jammin
Posts: 7
Joined: Fri Nov 19, 2021 11:59 pm

Re: AD410 - Option to Disable Bell Chime at Doorbell

Post by jammin »

evets122 wrote: Thu Aug 18, 2022 7:41 pm What ended up working for me on my AD410 was this command:

http://<doorbell_ip_address>/cgi-bin/configManager.cgi?action=setConfig&VideoTalkPhoneGeneral.RingFile=0

Since the ring file "0" doesn't exist, nothing plays! This is particularly helpful for anyone who wants to then send a custom sound to the doorbell when its button is pressed since there's no conflict with an existing sound file playing at the same time (even if the volume was brought to 0).
It's been a long time and I had completely forgotten about this post!

Thanks both of you for your replies. I can confirm that on AD410, this did not work (even though it returned "OK"):
http://<doorbell_ip_address>/cgi-bin/configManager.cgi?action=setConfig&VideoTalkPhoneGeneral.RingVolume=0

I am guessing that setting was not only left out of the UI in the app, but also from the doorbell itself!

However this did work:
http://<doorbell_ip_address>/cgi-bin/configManager.cgi?action=setConfig&VideoTalkPhoneGeneral.RingFile=0

I now get a nice chime inside (since I am using the chime kit) and no sound outside. And I can set the volume for the call as I please.

Thanks again!
evets122
Posts: 5
Joined: Thu Aug 18, 2022 7:29 pm

Re: AD410 - Option to Disable Bell Chime at Doorbell

Post by evets122 »

Just a quick note on this, when I recently upgraded my AD410 from firmware v.20210220 to the latest v.20230221, it appears to have broken the postAudio command I had detailed:
curl --request POST --url 'http://<user>:<password>@<doorbell_ip_address>/cgi-bin/audio.cgi?action=postAudio&httptype=singlepart&channel=1' --header 'content-length: 9999999' --header 'content-type: Audio/G.711A' --max-time 3 --data-binary @<output_name.al>

Downgrading the FW back to v.20210220 fixed it. I contacted customer service about it and they passed it along to the developers, but I was curious if anyone else tried to postAudio previously and now no longer has it working. @GaryOkie if you're on the newer FW, does this command no longer work for you? Thanks!
GaryOkie
Posts: 418
Joined: Mon Apr 27, 2020 7:23 pm

Re: AD410 - Option to Disable Bell Chime at Doorbell

Post by GaryOkie »

Sorry, I have not yet updated my AD410 firmware. Been waiting to see reports of anyone that has! Did you notice any improvements at all, or just this one issue?

I doubt this matters since the curl audio.cgi command specifies the encoding - but you might check if the doorbell mainformat Audio encoding is AAC, and if so, change it to G711A to match. The API or ASP can be safely used for this.
evets122
Posts: 5
Joined: Thu Aug 18, 2022 7:29 pm

Re: AD410 - Option to Disable Bell Chime at Doorbell

Post by evets122 »

I didn't stay on the new FW long enough to notice since not having the custom sounds working would mean having to undo a lot of my automations (plus I like my custom tones)! Hopefully they'll fix it in the next FW, but this is probably not a priority. Config file is good since it all says G711A.

Just curious, in a previous post you mentioned using a multipart stream for termination of the POST. I was curious if a multipart stream would have better success on the newer FW compared to the singlepart stream I'm current using, but I've been struggling to find a way to successfully send that command. I don't quite understand the syntax written in the API documentation or how to even set the boundary. If you have experience with it, any suggestions on how to update my singlepart command to multipart?
GaryOkie
Posts: 418
Joined: Mon Apr 27, 2020 7:23 pm

Re: AD410 - Option to Disable Bell Chime at Doorbell

Post by GaryOkie »

I only referenced multipart as being an option that was documented in the API guide and had not tried using it.

My understanding from RFC documentation is that you can define the boundary to be any arbitrary ASCII text string you want, such as:
Content-Type: multipart/x-mixed-replace; boundary=gobbledegook

Then you specify this boundary with 2 leading hyphens followed by CRLF then followed by the audio data and ending with CRLF and the final boundary with 2 leading and 2 terminating hyphens. (Note that the Amcrest API 11.3.2 example for multipart does not show the final boundary wrapped with double hyphens, just the 2 leading ones)

--gobbbledegook
<G711A Audio Data>
--gobbledegook--

A complete reference to the RFC multipart standard is found here (which is not to say Amcrest follows it exactly) -
https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html

I suppose the main advantage of sending audio this way is that the device knows exactly when to end the stream and not rely on a timeout.
GaryOkie
Posts: 418
Joined: Mon Apr 27, 2020 7:23 pm

Re: AD410 - Option to Disable Bell Chime at Doorbell

Post by GaryOkie »

I wondered how helpful ChatGPT or Bard would be in providing a good multipart audio example. Google's Bard's response wasn't bad, but ChatGPT was more detailed. I asked this:

" provide a curl command using Amcrest HTTP API cgi-bin/audio.cgi httptype=multipart to send a G711A audio file with specific examples of how to specify the boundaries in the audio file"

My original submission that copy/pasted the response was BLOCKED by the web server provider. Apparently the http post example was thought to be some kind of malformed injection attack.

If you have signed up for any of the chat AI providers, give it a try. The answers are a bit generic but follow the RFC guidelines exactly like I had mentioned.
evets122
Posts: 5
Joined: Thu Aug 18, 2022 7:29 pm

Re: AD410 - Option to Disable Bell Chime at Doorbell

Post by evets122 »

The output from ChatGPT was really impressive, between that and the link you provided I think I put together the correct syntax for sending the multipart audio:
curl POST --url "http://admin:<password>@<doorbell_ip_address>/cgi-bin/audio.cgi?action=postAudio&httptype=multipart&channel=1" --header "content-type: multipart/x-mixed-replace; boundary=boundary123" --data-binary $'--boundary123\r\ncontent-type: Audio/G.711A; content-length: 800; @<output_name>.al\r\n--boundary123\r\n'

But no results and I just get an empty reply from the server! I think I'll just stick with the singlepart audio on the older FW and hope that future FW updates fix the broken API.
Post Reply