fix: Prevent microphone auto-disconnect during calls and restore the removed microphone connected condition (#2597)

- Closes: #2590
This commit is contained in:
Dermot Duffy
2026-07-22 16:12:31 -07:00
committed by GitHub
parent 8c36637092
commit 5a549c0326
14 changed files with 520 additions and 346 deletions
+28 -6
View File
@@ -397,24 +397,44 @@ triggers:
## `microphone`
Matches the microphone state. As a **condition**, true while the mute state
matches; as a **trigger**, fires when it becomes a match.
Matches the microphone state. As a **condition**, true while every parameter
given matches; as a **trigger**, fires when it becomes a match.
```yaml
# As a condition:
conditions:
- condition: microphone
connected: true
muted: true
# As a trigger:
triggers:
- trigger: microphone
connected: true
muted: true
```
| Parameter | Description |
| ----------------------- | ----------------------------------------------------------------------------------- |
| `condition` / `trigger` | Must be `microphone`. |
| `muted` | If `true` or `false`, matches when the microphone is muted or unmuted respectively. |
| Parameter | Description |
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------- |
| `condition` / `trigger` | Must be `microphone`. |
| `connected` | If `true` or `false`, matches when the card does or does not hold an open microphone stream from the browser. See the note below. |
| `muted` | If `true` or `false`, matches when the microphone is muted or unmuted respectively. |
> [!NOTE]
> The `connected` parameter is about **browser microphone access**, not about
> calls. It is `true` while the card holds an open microphone stream from the
> browser -- the same state that lights your browser's "microphone in use"
> indicator (e.g. useful for showing privacy indicators).
>
> A [two-way audio](../usage/2-way-audio.md) call opens the microphone, but so do
> several things that involve no call at all: setting
> [`live.microphone.always_connected`](live.md?id=microphone), or a
> [`microphone_connect`](actions/custom/README.md?id=microphone_connect) or
> [`microphone_unmute`](actions/custom/README.md?id=microphone_unmute) action. It
> closes again after
> [`live.microphone.disconnect_seconds`](live.md?id=microphone) of disuse, or on
> a `microphone_disconnect` action.
>
> To match a call in progress, use [`call`](#call) instead.
## `not`
@@ -777,6 +797,7 @@ conditions:
- condition: media_loaded
media_loaded: true
- condition: microphone
connected: true
muted: true
- not:
- condition: fullscreen
@@ -854,6 +875,7 @@ triggers:
- trigger: media_loaded
media_loaded: true
- trigger: microphone
connected: true
muted: true
- trigger: numeric_state
entity_id: sensor.office_temperature
+1 -1
View File
@@ -226,7 +226,7 @@ live:
| `always_connected` | `false` | Whether or not to keep the microphone stream continually connected while the card is running, or only connect it when first needed (default) -- typically when a [two-way audio](../usage/2-way-audio.md) call is started. In the latter case there'll be a connection reset the first time the microphone connects -- using this option can avoid that reset. |
| `auto_mute` | `[call]` | A list of conditions in which the microphone is muted. `unselected` will automatically mute the microphone when a camera is unselected in the carousel or grid. `hidden` will automatically mute the microphone when the card becomes hidden (e.g. browser/tab change). `call` will automatically mute the microphone when an answered [two-way audio](../usage/2-way-audio.md) call ends. Use an empty list (`[]`) to never automatically mute the microphone via these conditions. |
| `auto_unmute` | `[]` | A list of conditions in which the microphone is unmuted. `selected` will automatically unmute the microphone when a camera is selected in the carousel or grid. `visible` will automatically unmute when the card becomes visible. `call` will automatically unmute the microphone when a [two-way audio](../usage/2-way-audio.md) call is started (or answered for inbound calls). By default this list is empty, so the microphone stays muted even after answering (push-to-talk) -- tap the microphone button in the call overlay to talk. The microphone is still connected when the call starts (just left muted), so the browser may prompt for microphone permission at that point. |
| `disconnect_seconds` | `90` | The number of seconds after microphone usage to disconnect the microphone from the stream. `0` implies never. Not relevant if `always_connected` is `true`. |
| `disconnect_seconds` | `90` | The number of seconds after microphone usage to disconnect the microphone from the stream. `0` implies never. Not relevant if `always_connected` is `true`. The countdown is suspended for the duration of a [two-way audio](../usage/2-way-audio.md) call, and restarts in full when the call ends. |
| `mute_after_microphone_mute_seconds` | `60` | The number of seconds after the microphone mutes to automatically mute the inbound audio when `live.auto_mute` includes `microphone`. |
See [Using 2-way audio](../usage/2-way-audio.md) for more information about the very particular requirements that must be followed for 2-way audio to work.