frigate-hass-card icon indicating copy to clipboard operation
frigate-hass-card copied to clipboard

Add some mechanism to automatically unmute inbound audio when using the microphone

Open felipecrs opened this issue 1 year ago • 12 comments

I keep the audio of my cameras muted by default in the card. However, it would be nice to have an option like:

Automatically unmute when microphone connects

So that I don't need to press 2 buttons in order to have a proper conversation.

felipecrs avatar Apr 30 '23 16:04 felipecrs

Maybe a new microphone_connected card condition?

felipecrs avatar Apr 30 '23 18:04 felipecrs

I have even another use case for such a condition:

  • When microphone_connected is off, I'd like to set the microphone icon to something else like:

image

felipecrs avatar Apr 30 '23 18:04 felipecrs

Automatically unmute when microphone connects

I think you mean unmute the inbound audio, not unmute the microphone?

Maybe a new microphone_connected card condition?

Does "connected" here mean the microphone is attached the stream (regardless of whether the microphone is muted/unmuted) or does it mean when the microphone is unmuted? I think the former...

dermotduffy avatar Apr 30 '23 22:04 dermotduffy

I've been thinking about adding a new automations section that would run card commands when card conditions are met. If we added a new microphone_connected condition, and we had this, you could:

  • Use overrides to change the menu icon.
  • User automations to automatically send an unmute command to the feed.

Something like this:

overrides:
  condition:
    microphone_connected: true // <----------- Does not exist
  menu:
    buttons:
      microphone:
        icon: mdi:phone-in-talk-outline
automations: // <------------ Does not exist
  condition:
    microphone_connected: true // <----------- Does not exist
  actions:
      - action: custom:frigate-card-action
        frigate_card_action: unmute // <------------ Does not exist
  condition:
    microphone_connected: false // <----------- Does not exist
  actions:
      - action: custom:frigate-card-action
        frigate_card_action: mute // <------------ Does not exist

Is this the kind of thing you mean? The other approach would be to add a new value for live.auto_unmute which is microphone and perhaps something similar for live.auto_mute to do the opposite.

dermotduffy avatar Apr 30 '23 22:04 dermotduffy

Is this the kind of thing you mean? The other approach would be to add a new value for live.auto_unmute which is microphone and perhaps something similar for live.auto_mute to do the opposite.

Maybe something like this is more sensible in this case, unmuting your inbound audio stream when you use a microphone seems obvious, and it'd be weird to have to add 11 lines of config (as extensible as it is) just to get that to happen.

dermotduffy avatar Apr 30 '23 22:04 dermotduffy

Automatically unmute when microphone connects

I think you mean unmute the inbound audio, not unmute the microphone?

Maybe a new microphone_connected card condition?

Does "connected" here mean the microphone is attached the stream (regardless of whether the microphone is muted/unmuted) or does it mean when the microphone is unmuted? I think the former...

Correct for your two assumptions

felipecrs avatar May 01 '23 00:05 felipecrs

Use overrides to change the menu icon.

But I thought I could also use overrides to change the unmute too:

overrides:
  condition:
    microphone_connected: true // <----------- Does not exist
  menu:
    buttons:
      microphone:
        icon: mdi:phone-in-talk-outline
  live:
    auto_unmute: all // <--------------------- Unmutes incoming audio

No?

felipecrs avatar May 01 '23 01:05 felipecrs

No?

I'd need to test it, but I think if you did that it would work in all "future" situations as you want -- but for the camera that is already selected it won't do anything (since when the camera was first selected, the auto_unmute was 'never').

dermotduffy avatar May 01 '23 02:05 dermotduffy

I'd need to test it, but I think if you did that it would work in all "future" situations as you want -- but for the camera that is already selected it won't do anything (since when the camera was first selected, the auto_unmute was 'never').

Got it.

felipecrs avatar May 01 '23 02:05 felipecrs

Exactly what I need, following.

CV8R avatar Jul 05 '23 08:07 CV8R

+1 🙏

mutasim avatar Jul 12 '23 08:07 mutasim

Quick update: This feature is 2nd in line, I just have very limited development cycles. I don't think this will be difficult. Whilst I could do it via automations (as suggested in my comment above) I think it's better that the card just support this natively, i.e. this should really just work out of the box.

Current plan:

  • Extend the existing live.auto_unmute and live.auto_mute options for the live player to support a "microphone" option. When the microphone is unmuted, the audio would be unmuted also. The audio would automatically re-mute 60s after the last microphone unmute.
  • [Optionally] Extend the live.microphone section to have a auto_mute_seconds option that would allow the 60s above to be configurable.

Nit: This does split microphone relevant config options across two config sections, but I think combining with the existing auto_mute and auto_unmute options is the least surprising.

I haven't tried implementing any of this, so the plan may change, but that's what I'm thinking for now. If anyone has a reason the above wouldn't suit their usecase, please let me know!

dermotduffy avatar Jul 29 '23 15:07 dermotduffy

Will be in the next release.

dermotduffy avatar Jan 29 '24 04:01 dermotduffy