Sorry, I just meant you have the doorbell… which is, according to the developer, the only Reolink product that supports sending audio to it. That means that your workflow likely won’t work for me. I didn’t see any relevant firmware updates for my devices (I don’t have the doorbell one).
Ok, i thought you also have one that you tested with, my bad
But when using https stream then is it possible senda audio to cam?
Depends which camera specifically? Works on the doorbell.
Reolink 823A
This is how i’ve done it on the Reolink Doorbell which supports 2-way audio. Not sure about the 823A but I can see it has a speaker and I believe it is profile T. Results will depend on the camera actually supporting 2-way. I believe the only one that does currently is the door bell but not 100% sure.
go2rtc
frontdoor_main:
- rtsp://admin:[email protected]/h264Preview_01_main
- ffmpeg:frontdoor_main#audio=opus
.
shell script with post:
$FILE=/some/file
curl -v \
-X POST \
"http://localhost:1984/api/streams?dst=frontdoor_main&src=ffmpeg:$FILE%23audio=pcma%23input=file"
Thanks.
How to execute this shell script?
It’s just a post command. You can run it directly from ha with the ha shell command service or on any os directly. Really anywhere. Depends on what you’re trying to accomplish. I feed a tts mp3 into it from Google cloud service so it speaks.
My goal is too send tts to camera. But can you give a hint or tutorial how to get this post command work.
I don’t have any idea where to start.
I looked some youtube videos but wont found anything about how to post shell command in HA.
Is there any tutorial or something?
I’m not sure how you intend on initiating the tts to the bell but you could do this. You’ll need long lived token for the api.
a shell script in /config directory called ttsplay
This shell script will take an input of some text and pass it to the home assistant google_cloud integration to generate a mp3 file speaking that text. It stores in in HA and can be played with ‘URL’.
Then it takes that URL and with some ffmpeg/go2rtc magic it pads the beginning and end a few seconds and plays that mp3 to GO2RTC camera.
#!/bin/bash
TEXT="$1"
LOG=/config/ttslog
echo "TEXT: $TEXT" > $LOG
TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxx
GO2RTC=frontdoor_camera
URL=`curl -v -X POST \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d "{\"message\": \"$TEXT\", \"platform\": \"google_cloud\"}" \
https://ha.someurl.org/api/tts_get_url | jq -r .url` >> $LOG 2>&1
echo CURLRC=$? >> $LOG
curl -v \
-X POST \
"http://localhost:1984/api/streams?dst=$GO2RTC&src=exec:ffmpeg+-hide_banner+-v+error+-re+-i+$URL+-af+\"adelay=1s,apad=pad_dur=5\"+-c:a+pcm_alaw+-ar:a+8000+-ac:a+1+-vn+-user_agent+ffmpeg/go2rtc+-rtsp_transport+tcp+-f+rtsp+%7Boutput%7D" >> $LOG 2>&1
echo DOORRC=$? >> $LOG
exit 0
You can test it but dropping into the homeassistant container and executing it:
# docker exec -ti homeassistant /config/ttsplay "Hello there. Please leave the package by the door"
If/when it works, you can then execute this via home assistant by adding the shell_command to configuration.yaml and restarting HA. It will take the input of a input_text when it is called. See my automation after.
shell_command:
doorbelltts: >-
/config/ttsplay "{{ states('input_text.tts_door_text') }}"
and create a helper called ‘input_text.tts_door_text’ to hold whatever text you wanted to send.
and then create a simple automation so when you add text to it, it speaks to the doorbell and clears the input for the next time… You could also use a input_select and store canned responses and push those into the text field.
alias: Door Bell TTS
description: ""
trigger:
- platform: state
entity_id: input_text.tts_door_text
not_to:
- ""
- unknown
id: textset
for: "00:00:02"
condition: []
action:
- service: shell_command.doorbelltts
data: {}
- service: input_text.set_value
data:
value: ""
target:
entity_id: input_text.tts_door_text
mode: queued
An expanded example automation using a input_text and some locks and stuff.
alias: Door Bell TTS
description: ""
trigger:
- platform: state
entity_id: input_select.tts_door_text_selection
not_to: Select
id: selection
- platform: state
entity_id: input_text.tts_door_text
not_to:
- ""
- unknown
id: textset
for: "00:00:02"
condition: []
action:
- if:
- condition: trigger
id: selection
then:
- choose:
- conditions:
- condition: state
state: Leave Package
entity_id: input_select.tts_door_text_selection
sequence:
- service: input_text.set_value
data:
value: Hi. Please leave the package at the door. Have a great day.
target:
entity_id: input_text.tts_door_text
- conditions:
- condition: state
state: Visitor Unlock
entity_id: input_select.tts_door_text_selection
sequence:
- service: input_text.set_value
data:
value: Hi. I unlocked the door. Please come in.
target:
entity_id: input_text.tts_door_text
- service: lock.unlock
data: {}
target:
entity_id: lock.front_door
- conditions:
- condition: state
state: Solicitor
entity_id: input_select.tts_door_text_selection
sequence:
- service: input_text.set_value
data:
value: >-
Hi. Im sorry but we arent able to come to the door and we
are not interested. But thanks.
target:
entity_id: input_text.tts_door_text
- service: lock.lock
data: {}
target:
entity_id: lock.front_door
default:
- service: input_text.set_value
data:
value: "{{ states('input_select.tts_door_text_selection') }}"
target:
entity_id: input_text.tts_door_text
- if:
- condition: trigger
id: textset
then:
- service: shell_command.doorbelltts
data: {}
- service: input_text.set_value
data:
value: ""
target:
entity_id: input_text.tts_door_text
- service: input_select.select_option
target:
entity_id: input_select.tts_door_text_selection
data:
option: Select
mode: queued
This works too. Much easier.
configuration.yaml
media_player:
- platform: webrtc
name: Frontdoor
stream: frontdoor_send
audio: '-af "volume=10dB,adelay=2s,apad=pad_dur=6" -c:a pcm_alaw -ar:a 8000 -ac:a 1'
service call:
service: tts.google_cloud_say
data:
entity_id: media_player.frontdoor
message: One two buckle your shoe. three four close the door.
service: media_player.play_media
data:
media_content_type: music
media_content_id: http://10.100.1.183:8123/local/halloween-doorbell-ringtone.mp3
target:
entity_id: media_player.frontdoor
In your last example media_player configuration, what is the frontdoor_send stream?
Nothing fancy.
frontdoor_send:
- rtsp://xxxxxx:[email protected]/h264Preview_01_main
- ffmpeg:{input}#audio=opus
Ah, I see. Are you using the Frigate integration in Home Assistant or stand alone Frigate? I have the stand alone Frigate and can’t seem to send tts to my doorbell. But reading through the doc’s, it looks like the steam setting needs to be configured in the go2rtc.yaml file which I don’t have. Do you know if I create one manually if this would work or does this only apply to Frigate integrated?
I don’t use frigate as a backend. I only use the frigate card and a regular go2rtc installation. I would guess that if you created a go2rtc config in frigate, it work work similarly.
Okay thanks. I’ll give it a try.
Did you figure this out? I just can’t figure out what to put in the stream object.
I’m running frigate in docker so I can’t think of what makes sense to go here!
Where did you define your frontdoor_send? Is this part also in your yaml.config?
can you elaborate how you did this? all i want to achieve is for my doorbell to play a ding dong sound whenever the doorbell button is press… the ding_dong audio file is locally available in my HA upload folder.
I just got the reolink wifi doorbell working as a media player entity.
Latest firmware, go2rtc 1.9.4 installed from HACS - not the default you get with the webrtc integration.
I’d been struggling with it for a while, found this post:
https://www.reddit.com/r/homeassistant/comments/1f8jyzo/reolink_poe_doorbell_with_2_way_audio_tts/ so credit to that poster
I don’t use Frigate so I skipped that
configuration.yaml
media_player:
platform: webrtc
name: mediaplayername
stream: camera_name
audio: pcmu/8000
That ^^ is supposed to be pcmu/8000 , at first assumed it was a typo for pcma - it isn’t, don’t change it. I’ve seen people posting pcma other places, and this was the thing that fixed my issues.
go2rtc.yaml:
camera_name:
- rtsp://admin:[email protected]:554/Preview_01_main
- ffmpeg:camera_name#audio=opus#audio=copy
And now I can play mp3s or use TTS on media_player.mediaplayername
Incidentally for people doing this with a Tapo:
add to go2rtc.yaml
taportc: tapo://[email protected]
and then add as a media player in configuration.yaml
- platform: webrtc
name: tapocamname
stream: taportc
audio: pcma
Remember to restart the go2rtc addon and reboot when necessary.