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

2 Way Audio not working in Frigate Card #184

Open
Daz42 opened this issue Feb 5, 2024 · 78 comments
Open

2 Way Audio not working in Frigate Card #184

Daz42 opened this issue Feb 5, 2024 · 78 comments
Labels
bug Something isn't working

Comments

@Daz42
Copy link

Daz42 commented Feb 5, 2024

What happened?

Not an issue with the Hikvision Camera Integration - however I was unable to consistently get 2 way audio from the Frigate card for the Hikvision Camera Integration. This is an issue being dealt with but in the meantime we are using the web-rtc card which works but slightly clunky.

Add-on

Hikvision Doorbell

What version of the add-on are you running?

3.0.14

Installation type

Home Assistant add-on

Relevant log output

No response

Relevant configuration

No response

Anything else?

No response

@Daz42 Daz42 added the bug Something isn't working label Feb 5, 2024
@Daz42
Copy link
Author

Daz42 commented Feb 5, 2024

I would like to add a guide for those wanting to get their Hikvision doorbell working with the web-rtc card complete with mp3 playback. Eventually it will be updated for the Frigate card when 2 way audio is resolved with it.
Home Assistant Hikvision Doorbell (for web) As-Built v1.0.docx

@pergolafabio
Copy link
Owner

Great guide , not sure if I need to combine it or not... Gonna wait for the frigate updates first, because that card is nicer indeed... Also next update doesn't require frigate add-on/integration...

Just question, why do you have the camera defined 2 times in go2rtc , why not use the first one for the mp3 also?

@Daz42
Copy link
Author

Daz42 commented Feb 5, 2024

I tried using the first one but could not get the mp3 to play for the life of me. When I defined it again but with channel 102 it works reliably every time. Also another weirdness, when I update webrtc-camera to version 3.5.1 then I start having issues with mp3 playback and intermittent 2 way audio. I'm on master which is working but obviously should move on once I find out why it's playing up!

@TokarevSergey
Copy link

You managed to solve the problem. I have a Hikvision camera and doorbell. The problem was this. At first there was sometimes intermittent two-way communication. And now when I press the microphone, the sound disappears.

@pergolafabio
Copy link
Owner

ok, found the issue!!

dermotduffy/frigate-hass-card#1356
fixed in this:
AlexxIT/go2rtc#967
AlexxIT/go2rtc#962

The issue that two way audio isnt working the second time, is that the "close" command is not being used in the go2rtc addon, it will be implemlented later!!

for now i send the command below, right after you do the answer/hangup and before pressing the mic button, this makes the previous twoway audio close first...

"curl -i --digest -u admin:XXXX-X PUT http://192.168.0.70/ISAPI/System/TwoWayAudio/channels/1/close"

I keep this one open, untill a new go2rtc addon is released!!

@TokarevSergey
Copy link

Thank you

@pergolafabio
Copy link
Owner

update 1.9.0 is released, but seems the issue is still present, i still send the curl , before i start two way audio

@TokarevSergey
Copy link

Thank you. I'm really looking forward to the fix.

@pergolafabio
Copy link
Owner

Same, but the curl is working great!!

@TokarevSergey
Copy link

ок, нашел проблему!!

dermotduffy/frigate-hass-card#1356 исправлено здесь: AlexxIT/go2rtc#967 AlexxIT/go2rtc#962

Проблема, из-за которой двусторонняя аудиосвязь не работает во второй раз, заключается в том, что команда «закрыть» не используется в аддоне go2rtc, она будет реализована позже!

на данный момент я отправляю команду ниже, сразу после того, как вы ответите/повесите трубку и перед нажатием кнопки микрофона, это сначала закроет предыдущую двустороннюю аудиосвязь...

"curl -i --digest -u admin:XXXX-X PUT http://192.168.0.70/ISAPI/System/TwoWayAudio/channels/1/close"

Я оставляю этот вопрос открытым, пока не выйдет новый аддон go2rtc!!

Добрый вечер не могу заставить это работать.
У вас получилось.
Я делаю в файле configuration.yaml запись
shell_command:
doorbelltvaoff: curl -i --digest -u admin:ST008855h PUT http://10.0.0.11/ISAPI/System/TwoWayAudio/channels/1/close
и запускаю ее с помошью скрипта звук вске равно прерывистый. Подскажите может я чтото не так понял.

@pergolafabio
Copy link
Owner

I do this in the frigate card for my "phone/answer" button:

            - type: custom:frigate-card-menu-icon
              icon: mdi:phone
              tap_action:
                - action: call-service
                  service: script.answer_call
                - action: custom:frigate-card-action
                  frigate_card_action: unmute
                - action: custom:frigate-card-action
                  frigate_card_action: microphone_unmute

First i do the script, to make my answer+hangup+close audio
Then i do the frigate unmute functions for mic/audio

This is my script:

answer_call:
  alias: Deur open answer call
  sequence:
  - service: button.press
    entity_id: button.ds_kh9510_answer_call
  - delay: 
      milliseconds: 500
  - service: button.press
    entity_id: button.ds_kh9510_hangup_call
  - service: shell_command.hikvision_close_audio

and my shell command is:

hikvision_close_audio: "curl -i --digest -u admin:XXXXX-X PUT http://192.168.0.70/ISAPI/System/TwoWayAudio/channels/1/close"

@TokarevSergey
Copy link

TokarevSergey commented May 21, 2024

hikvision_close_audio: "curl -i --digest -u admin:XXXXX-X PUT http://192.168.0.70/ISAPI/System/TwoWayAudio/channels/1/close"

hikvision_close_audio: "curl -i --digest -u admin:XXXXX -X PUT http://192.168.0.70/ISAPI/System/TwoWayAudio/channels/1/close"
A space was missing before -X, is this correct?

@pergolafabio
Copy link
Owner

correct

@TokarevSergey
Copy link

TokarevSergey commented May 21, 2024

правильный

Damn, nothing works. All the same, the sound gets quieter and then starts to break up if I log in several times and go to the card with a microphone.

type: custom:webrtc-camera
url: DoorBellCh2
mode: webrtc
media: video, audio, microphone
muted: false
style: 'video {aspect-ratio: 16/9; object-fit: fill;}'

Only reloading the Go2rtc configuration helps

@TokarevSergey
Copy link

TokarevSergey commented May 21, 2024

I do this in the frigate card for my "phone/answer" button:

            - type: custom:frigate-card-menu-icon
              icon: mdi:phone
              tap_action:
                - action: call-service
                  service: script.answer_call
                - action: custom:frigate-card-action
                  frigate_card_action: unmute
                - action: custom:frigate-card-action
                  frigate_card_action: microphone_unmute

First i do the script, to make my answer+hangup+close audio Then i do the frigate unmute functions for mic/audio

This is my script:

answer_call:
  alias: Deur open answer call
  sequence:
  - service: button.press
    entity_id: button.ds_kh9510_answer_call
  - delay: 
      milliseconds: 500
  - service: button.press
    entity_id: button.ds_kh9510_hangup_call
  - service: shell_command.hikvision_close_audio

and my shell command is:

hikvision_close_audio: "curl -i --digest -u admin:XXXXX-X PUT http://192.168.0.70/ISAPI/System/TwoWayAudio/channels/1/close"

So how is everything right?
hikvision_close_audio: "curl -i --digest -u admin:XXXXX-X PUT http://192.168.0.70/ISAPI/System/TwoWayAudio/channels/1/close"

hikvision_close_audio: "curl -i --digest -u admin:XXXXX -X PUT http://192.168.0.70/ISAPI/System/TwoWayAudio/channels/1/close"

@pergolafabio
Copy link
Owner

yeah thats why i do

@TokarevSergey
Copy link

TokarevSergey commented May 21, 2024

admin:XXXXX-X PUT

admin:XXXXX-X PUT
admin:XXXXX -X PUT

@michalwu
Copy link

Hi
Anything new in this case? Can anyone share working config?

@pergolafabio
Copy link
Owner

it works, but if you answer the doorbell 2 times when not refreshing the card, i dont have audio, you can send the close command i posted earlier

i saw new updates on the card, didnt try yet, maybe its better now

@michalwu
Copy link

Thanks for letting me know.
Then my DS-KV8113-WME1 B is special. Microphone is not working from PC/phone HASS (i.e. I do not hear anything on doorbell).
Can you suggest what to check?

frigate.yml:

`
mqtt:
enabled: true
host: 10.0.1.5
user: usermqtt
password: xxx

cameras:
Doorbell:
ffmpeg:
inputs:
- path: rtsp://admin:[email protected]:554/Streaming/Channels/101

detect:
enabled: False
width: 1920
height: 1080
motion:
enabled: False
record:
enabled: False

go2rtc:
streams:
Doorbell:
- rtsp://admin:[email protected]:554/Streaming/Channels/101
- isapi://admin:[email protected]:80/
api:
username: user
password: xxx
version: 0.14
`

and streams info from go2rtc:

{
"producers": [
{
"type": "RTSP active producer",
"url": "rtsp://10.0.2.15:554/Streaming/Channels/101/",
"remote_addr": "10.0.2.15:554",
"user_agent": "go2rtc/1.9.2",
"sdp": "v=0\r\no=- 1734100537950584 1734100537950584 IN IP4 10.0.2.15\r\ns=Media Presentation\r\ne=NONE\r\nb=AS:5100\r\nt=0 0\r\na=control:rtsp://10.0.2.15:554/Streaming/Channels/101/\r\nm=video 0 RTP/AVP 96\r\nb=AS:5000\r\na=control:rtsp://10.0.2.15:554/Streaming/Channels/101/trackID=1\r\na=rtpmap:96 H264/90000\r\na=fmtp:96 profile-level-id=420029; packetization-mode=1; sprop-parameter-sets=\r\nm=audio 0 RTP/AVP 0\r\nb=AS:50\r\na=control:rtsp://10.0.2.15:554/Streaming/Channels/101/trackID=2\r\na=rtpmap:0 PCMU/8000\r\na=Media_header:MEDIAINFO=494D4B48010100000400010010710110401F0000000;\r\na=appversion:1.0\r\n",
"medias": [
"video, recvonly, H264",
"audio, recvonly, PCMU/8000"
],
"receivers": [
"96 H264, bytes=30521854, senders=1",
"0 PCMU/8000, bytes=526720, senders=1"
],
"recv": 31350944
},
{
"type": "ISAPI active consumer",
"medias": [
"audio, sendonly, PCMU/8000"
],
"senders": [
"0 PCMU/8000, bytes=0, receivers=1"
]
}
],
"consumers": [
{
"type": "WebRTC/WebSocket async passive consumer",
"remote_addr": "tcp4 prflx 10.0.1.52:54684 related :0",
"user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:128.0) Gecko/20100101 Firefox/128.0",
"medias": [
"video, sendonly, VP8, VP9, H264",
"audio, recvonly, OPUS/48000/2, G722/8000, PCMU/8000, PCMA/8000",
"audio, sendonly, OPUS/48000/2, G722/8000, PCMU/8000, PCMA/8000, L16, PCML"
],
"receivers": [
"0 PCMU/8000, bytes=0, senders=53"
],
"senders": [
"126 H264, bytes=30521854, receivers=1",
"0 PCMU/8000, bytes=526720, receivers=1"
],
"send": 31317100
}
]
}

@pergolafabio
Copy link
Owner

sorry, no idea, for mic to work, you need https with valid ssl, mauybe thats the issue?

@spn91
Copy link

spn91 commented Dec 29, 2024

Hi, I have the same problem with two-way-audio when browsing away from the frigate-card after first use of the microphone. The first time it works, but if I browse away to another lovelace section and then back to the section with the frigate-card, two-way-audio isn't working anymore. The browser doesn't show the microphone status icon again, so for me it seems that no new microphone connection is made to the browser?

Below is the relevant part of the frigate-card config, I thought using the ISAPI channel close command would solve my problem, but it isn't. I have to reload the whole page, or wait a few minutes. Then the mic connections starts again if I click the phone icon.

- type: custom:frigate-card-menu-icon
    icon: mdi:phone
    tap_action:
      - action: custom:frigate-card-action
        frigate_card_action: unmute
      - action: custom:frigate-card-action
        frigate_card_action: microphone_unmute
      - action: perform-action
        data:
          entity_id: button.eingang_hangup_call
        perform_action: button.press
      - action: call-service
        service: text.set_value
        data:
          entity_id: text.eingang_isapi_request
          value: PUT /ISAPI/System/TwoWayAudio/channels/1/close

Any idea? Also in the addon log I can see that the channel close command works successfully

2024-12-29 18:57:27.743 | DEBUG    | sdk.utils:call_ISAPI:165 - Response output: {
	"statusCode":	1,
	"statusString":	"OK",
	"subStatusCode":	"ok"
}

@pergolafabio
Copy link
Owner

When I tested it a long time ago, I saw the phone button always, I was able to toggle it...
Maybe something changed in the frigate card? I saw a lot of updates on it,... Didn't test it anymore...

@spn91
Copy link

spn91 commented Dec 29, 2024

Hmm I always see the phone button? Do you mean the microphone button? I always see the microphone button in the frigate-card. I have the same problem as you had, until you were able to fix it with the channel close command.

What I meant with

The browser doesn't show the microphone status icon again

is, that my browser shows the red microphone icon on the tab which is using the microphone. This icon is missing and the microphone doesn't work.

@pergolafabio
Copy link
Owner

Hmm, not sure, I didn't test it anymore for a year :-(

@spn91
Copy link

spn91 commented Dec 29, 2024

Hmm, than I don't understand your comment you made here, only a few months ago 😅 -> dermotduffy/frigate-hass-card#1356 (comment)

@pergolafabio
Copy link
Owner

Well, if I do the hangup, I send the close command also, so the twowayaudio is really closed..
Next time a on a new ring, if I answer and start two way audio I can hear audio again... With this approach I didn't need to hard refresh the Lovelace card

@spn91
Copy link

spn91 commented Dec 29, 2024

I also send to close command now when pressing the phone-hangup button. Still not working when

would you be so kind as to share your current config of the card?

@pergolafabio
Copy link
Owner

I don't use it anymore, the last update is on the GitHub page :-)
I stopped using it before the frigate card 6.x came out...

@pergolafabio
Copy link
Owner

yes, that works, but ONLY if i also send the command below when i click on the hangup button (or send if before you you do do the answer) ... thats why the "original" mic button on the card doesnt work, it doesnt send the isapi command
if i dont send that command, then indeed the second time the twoway audio doesnt work, because i believe its still in use on the first session... so browssing to another page and back gives issues indeed!! Only a hard refresh or close/open companion app does the trick!

maybe the command below on your doorbell station doesnt work? whay happens if you do it in putty? gives it back an 200 state?

shell:
curl -i --digest -u admin:XXX-X PUT http://192.168.0.70/ISAPI/System/TwoWayAudio/channels/1/close

                - action: call-service
                  service: text.set_value
                  data:
                    entity_id: text.ds_kd8003_isapi_request
                    value: PUT /ISAPI/System/TwoWayAudio/channels/1/close

@pergolafabio
Copy link
Owner

It would be nice to have an option to reset the stream back to 1-way-audio (which could be used during the hangup action).

isnt the action below forcing it back to oneway audio?

              tap_action:
                - action: custom:frigate-card-action
                  frigate_card_action: microphone_mute

@spn91
Copy link

spn91 commented Dec 30, 2024

I do send the close command. In your addon I can see the reply, which contains "ok". So the command seems to work. I'm not able to try with curl, as I have a "!" in my password and I wasn't able to get it working, though trying different methods of escaping it..

The frigate_card_action: microphone_mute just mutes the mic, but doesn't revert back the stream. I can easily see this, because the browser still shows the mic indicator after pressing the button.

My frigate-card config

type: custom:frigate-card
cameras:
  - camera_entity: camera.doorbell
    live_provider: go2rtc
    go2rtc:
      modes:
        - webrtc
menu:
  style: outside
  position: bottom
  buttons:
    microphone:
      enabled: true
      type: toggle
    screenshot:
      enabled: false
    download:
      enabled: false
    fullscreen:
      enabled: false
    snapshots:
      enabled: false
    timeline:
      enabled: false
    media_player:
      enabled: false
    clips:
      enabled: false
    live:
      enabled: false
    cameras:
      enabled: false
    frigate:
      enabled: false
    camera_ui:
      enabled: false
live:
  controls:
    builtin: true
  auto_mute: []
  lazy_unload: []
  microphone:
    always_connected: false
    disconnect_seconds: 20
elements:
  - type: custom:frigate-card-menu-icon
    icon: mdi:volume-high
    tap_action:
      - action: custom:frigate-card-action
        frigate_card_action: unmute
  - type: custom:frigate-card-menu-icon
    icon: mdi:volume-off
    tap_action:
      - action: custom:frigate-card-action
        frigate_card_action: mute
  - type: custom:frigate-card-menu-icon
    icon: mdi:phone
    tap_action:
      - action: custom:frigate-card-action
        frigate_card_action: unmute
      - action: custom:frigate-card-action
        frigate_card_action: microphone_unmute
      - action: perform-action
        data:
          entity_id: button.eingang_hangup_call
        perform_action: button.press
      - action: call-service
        service: text.set_value
        data:
          entity_id: text.eingang_isapi_request
          value: PUT /ISAPI/System/TwoWayAudio/channels/1/close
  - type: custom:frigate-card-menu-icon
    icon: mdi:phone-hangup
    tap_action:
      - action: custom:frigate-card-action
        frigate_card_action: microphone_mute
      - action: call-service
        service: text.set_value
        data:
          entity_id: text.eingang_isapi_request
          value: PUT /ISAPI/System/TwoWayAudio/channels/1/close
  - type: custom:frigate-card-menu-icon
    icon: mdi:door-open
    hold_action:
      - action: perform-action
        data:
          entity_id: switch.eingang_door_relay_0
        perform_action: switch.turn_on
dimensions:
  aspect_ratio_mode: static
  aspect_ratio: "16:9"
cameras_global:
  dimensions:
    layout:
      fit: fill
status_bar:
  style: none

@pergolafabio
Copy link
Owner

But you are using the core go2rtc config? Maybe that's conflicting? I had that too , I removed the camera. ...
Forcing using the go2rtc addon instead of the core...

Have a look at my code again, I updated it, I use an URL instead...

@pergolafabio
Copy link
Owner

The core integration doesn't support two way audio

@spn91
Copy link

spn91 commented Dec 30, 2024

No, the frigate-card example was using go2rtc via the frigate addon.

@pergolafabio
Copy link
Owner

Ah ok, I don't use that frigate addon

@spn91
Copy link

spn91 commented Dec 30, 2024

At the moment I'm trying to get rid of the frigate addon. go2rtc addon already works, but I want to use the core go2rtc integration which has the option to specify an go2rtc server -> https://www.home-assistant.io/integrations/go2rtc/#examples

But nothing happens, I thought the core go2rtc integration will create the camera entities in this case?

@pergolafabio
Copy link
Owner

Are you running the latest go2rtc binary,? They added some changes to it, maybe the frigate addon isn't using the latest go2rtc

@pergolafabio
Copy link
Owner

There was an audio close channel command added to the go2rtc addon, maybe since you are using the frigate addon, you are missing that one, I look up later

@pergolafabio
Copy link
Owner

AlexxIT/go2rtc#967

@pergolafabio
Copy link
Owner

Btw, I don't think you need to send the Isapi close command at all... It's only needed when you send first the answer command, in my setup, the doorbell has actually the audio open ... If you send just hangup, there is no need to close audio

@spn91
Copy link

spn91 commented Dec 30, 2024

Frigate is using a version > 1.9.0, so the fixed version should be already included.
But forget Frigate.

I have the go2rtc addon running. I don't want to expose go2rtc on my proxy. I tried to use the go2rtc stream url which I get when visiting the go2rtc UI via HA Ingress, but this is not working in the frigate-card (stream is not starting, no request seen in the go2rtc log).

Now there is the core go2rtc integration (https://www.home-assistant.io/integrations/go2rtc/#examples) where I have specified my go2rtc addon address, but nothing happens (no error, no new entity, just nothing). Do you know what additional steps I have to take to get the camera into HA?

@pergolafabio
Copy link
Owner

ingress indeed doesnt work i think, but i use nginx, i didnt expose 1984 or 1985 ; i just use 8123 to access go2rtc , but offcourse its open to outside word, so used a strong user/pass combo
i believe thats the only way to make it work... i saw some new updates on the frigate card, that it can also use an builtin proxy, like the webrtc card, but didnt test that yet

@spn91
Copy link

spn91 commented Dec 30, 2024

I think we could get it work with the core go2rtc integration, then no exposing would be needed.

@pergolafabio
Copy link
Owner

not sure, you still need to point to the go2rtc addon, but i didnt test that yet

will do it in a few moments :)

@pergolafabio
Copy link
Owner

this is what i was talking about also:

dermotduffy/frigate-hass-card#1299

@pergolafabio
Copy link
Owner

if you use this:

go2rtc:
  url: http://my-go2rtc-instance:1984

i dont think it will work, since its not running on https, for the mic support you need https .. that means go2rtc needs to be running with a valid ssl anyway?

@spn91
Copy link

spn91 commented Dec 30, 2024

but what would be the point of specifying the url parameter in the core integration, if we still need to point to the go2rtc addon? This is something I don't understand and is not very well documented on the integration page.

@pergolafabio
Copy link
Owner

its a way of disabling the core integration if you dont need it ...

i use the core integration for normal cameras, and i use the addon only for my tuya cameras, they are quite specific and dont work with the core... maybe some users dont want to use the core at all

@pergolafabio
Copy link
Owner

but let me try, rebooting HA now, specified the addon now with the core integration

@spn91
Copy link

spn91 commented Dec 30, 2024

Do you have any expectation what should happen after specifying the external go2rtc server? I thought it will create a camera entity.

@pergolafabio
Copy link
Owner

hmm, that doesnt work, specified the addon url, then did it like below, but it fails to load, it needs https

        - type: custom:frigate-card
          cameras:
            - live_provider: go2rtc
              go2rtc:
                url: http://user:[email protected]:8123
                stream: deurbel
                modes:
                  - webrtc

@pergolafabio
Copy link
Owner

Do you have any expectation what should happen after specifying the external go2rtc server? I thought it will create a camera entity.

no, it doesnt create an camera entity, its just if you want to make control of your own go2rtc instance, and dont want to make use of the core integration at all, you still need to make the cameras in go2rtc.yaml, but even that doesnt create an camera enitty... i'm not pointing to a camera entity in my frigate card, i actually point to the stream source from go2rtc

@spn91
Copy link

spn91 commented Dec 30, 2024

I think I don't understand the use case of using the external go2rtc server with the core integration.
What would be the next steps after specifying the url for me? At the moment I have no camera entity for the doorbell.

I know that you have specified the url in the frigate-card, but I thought that I can create the entity in HA and then using this entity (just like before using the frigate integration).

@pergolafabio
Copy link
Owner

you dont need to point indeed an external go2rtc, its not needed, and you dont need an camera entity either...
doing below is enough... But you need to make us of nginx (8123) ,f i you dont want to open 1985 in your router...
or dont use nginx and opeen 1985 and specify the ssl certifctates in the go2rtc config

just make sure this url works from outside: https://user:[email protected]:8123 OR https://user:pass@homeassistant:1985

            - live_provider: go2rtc
              go2rtc:
                url: https://user:[email protected]:8123
                stream: deurbel
                modes:
                  - webrtc

@spn91
Copy link

spn91 commented Dec 30, 2024

I think I have found out for what it is used for.. I have created a generic.camera in HA and suddenly this camera also was present in the go2rtc addon, without specifying it in the go2rtc.yml config. So the core go2rtc integration pushes every camera to the go2rtc addon it seems.

EDIT: I don't know how, but somehow the generic.camera also appeared in my go2rtc.yml config 😅

@pergolafabio
Copy link
Owner

yes indeed, thays why i use the core integration, i have 8 cameras, to make them webrtc... but you cant use the core integration for the twowayaudio ... cause you need to customize the yaml for it
so i use core AND addon

@spn91
Copy link

spn91 commented Dec 30, 2024

got it working now with go2rtc addon and frigate-card, but issue still exists. If I browse away on the lovelace card and back to it, somehow the mic session is lost and the microphone won't work.. :(

@pergolafabio
Copy link
Owner

thats annoying :-(
do you use browser_mod ? if believe that integration, you can reload/refresh the page with an action, maybe you can use that service before starting the talk ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants