feat: Add microphone_disconnect action (#1536)
This commit is contained in:
@@ -248,6 +248,15 @@ action: custom:frigate-card-action
|
|||||||
frigate_card_action: menu_toggle
|
frigate_card_action: menu_toggle
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## `microphone_disconnect`
|
||||||
|
|
||||||
|
Disconnect the microphone during [2-way audio](../../../usage/2-way-audio.md).
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
action: custom:frigate-card-action
|
||||||
|
frigate_card_action: microphone_disconnect
|
||||||
|
```
|
||||||
|
|
||||||
## `microphone_mute`
|
## `microphone_mute`
|
||||||
|
|
||||||
Mute the microphone during [2-way audio](../../../usage/2-way-audio.md).
|
Mute the microphone during [2-way audio](../../../usage/2-way-audio.md).
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ unless the action is targeted with a `CARD_ID` as shown above.
|
|||||||
Only a subset of all [actions](../configuration/actions/README.md) are supported in URL form.
|
Only a subset of all [actions](../configuration/actions/README.md) are supported in URL form.
|
||||||
|
|
||||||
| Action | Supported in URL | Explanation |
|
| Action | Supported in URL | Explanation |
|
||||||
| -------------------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------- |
|
| --------------------------------------------------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `camera_select` | :white_check_mark: | |
|
| `camera_select` | :white_check_mark: | |
|
||||||
| `camera_ui` | :white_check_mark: | |
|
| `camera_ui` | :white_check_mark: | |
|
||||||
| `clip` | :white_check_mark: | |
|
| `clip` | :white_check_mark: | |
|
||||||
@@ -61,7 +61,7 @@ Only a subset of all [actions](../configuration/actions/README.md) are supported
|
|||||||
| `live` | :white_check_mark: | |
|
| `live` | :white_check_mark: | |
|
||||||
| `media_player` | :heavy_multiplication_x: | Please [request](https://github.com/dermotduffy/frigate-hass-card/issues) if you need this. |
|
| `media_player` | :heavy_multiplication_x: | Please [request](https://github.com/dermotduffy/frigate-hass-card/issues) if you need this. |
|
||||||
| `menu_toggle` | :white_check_mark: | |
|
| `menu_toggle` | :white_check_mark: | |
|
||||||
| `microphone_mute`, `microphone_unmute` | :heavy_multiplication_x: | |
|
| `microphone_disconnect`, `microphone_mute`, `microphone_unmute` | :heavy_multiplication_x: | |
|
||||||
| `mute`, `unmute` | :heavy_multiplication_x: | |
|
| `mute`, `unmute` | :heavy_multiplication_x: | |
|
||||||
| `play`, `pause` | :heavy_multiplication_x: | |
|
| `play`, `pause` | :heavy_multiplication_x: | |
|
||||||
| `ptz` | :heavy_multiplication_x: | Please [request](https://github.com/dermotduffy/frigate-hass-card/issues) if you need this. |
|
| `ptz` | :heavy_multiplication_x: | Please [request](https://github.com/dermotduffy/frigate-hass-card/issues) if you need this. |
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { GeneralActionConfig } from '../../../config/types';
|
||||||
|
import { CardActionsAPI } from '../../types';
|
||||||
|
import { FrigateCardAction } from './base';
|
||||||
|
|
||||||
|
export class MicrophoneDisconnectAction extends FrigateCardAction<GeneralActionConfig> {
|
||||||
|
public async execute(api: CardActionsAPI): Promise<void> {
|
||||||
|
api.getMicrophoneManager().disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ import { GenericAction } from './actions/generic';
|
|||||||
import { LogAction } from './actions/log';
|
import { LogAction } from './actions/log';
|
||||||
import { MediaPlayerAction } from './actions/media-player';
|
import { MediaPlayerAction } from './actions/media-player';
|
||||||
import { MenuToggleAction } from './actions/menu-toggle';
|
import { MenuToggleAction } from './actions/menu-toggle';
|
||||||
|
import { MicrophoneDisconnectAction } from './actions/microphone-disconnect';
|
||||||
import { MicrophoneMuteAction } from './actions/microphone-mute';
|
import { MicrophoneMuteAction } from './actions/microphone-mute';
|
||||||
import { MicrophoneUnmuteAction } from './actions/microphone-unmute';
|
import { MicrophoneUnmuteAction } from './actions/microphone-unmute';
|
||||||
import { MuteAction } from './actions/mute';
|
import { MuteAction } from './actions/mute';
|
||||||
@@ -96,6 +97,12 @@ export class ActionFactory {
|
|||||||
return new SubstreamOnAction(context, frigateCardAction, options?.config);
|
return new SubstreamOnAction(context, frigateCardAction, options?.config);
|
||||||
case 'media_player':
|
case 'media_player':
|
||||||
return new MediaPlayerAction(context, frigateCardAction, options?.config);
|
return new MediaPlayerAction(context, frigateCardAction, options?.config);
|
||||||
|
case 'microphone_disconnect':
|
||||||
|
return new MicrophoneDisconnectAction(
|
||||||
|
context,
|
||||||
|
frigateCardAction,
|
||||||
|
options?.config,
|
||||||
|
);
|
||||||
case 'microphone_mute':
|
case 'microphone_mute':
|
||||||
return new MicrophoneMuteAction(context, frigateCardAction, options?.config);
|
return new MicrophoneMuteAction(context, frigateCardAction, options?.config);
|
||||||
case 'microphone_unmute':
|
case 'microphone_unmute':
|
||||||
|
|||||||
@@ -270,6 +270,7 @@ const FRIGATE_CARD_GENERAL_ACTIONS = [
|
|||||||
'live_substream_off',
|
'live_substream_off',
|
||||||
'live_substream_on',
|
'live_substream_on',
|
||||||
'menu_toggle',
|
'menu_toggle',
|
||||||
|
'microphone_disconnect',
|
||||||
'microphone_mute',
|
'microphone_mute',
|
||||||
'microphone_unmute',
|
'microphone_unmute',
|
||||||
'mute',
|
'mute',
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
import { expect, it } from 'vitest';
|
||||||
|
import { MicrophoneDisconnectAction } from '../../../../src/card-controller/actions/actions/microphone-disconnect';
|
||||||
|
import { createCardAPI } from '../../../test-utils';
|
||||||
|
|
||||||
|
it('should handle microphone_disconnect action', async () => {
|
||||||
|
const api = createCardAPI();
|
||||||
|
const action = new MicrophoneDisconnectAction(
|
||||||
|
{},
|
||||||
|
{
|
||||||
|
action: 'fire-dom-event',
|
||||||
|
frigate_card_action: 'microphone_disconnect',
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
|
await action.execute(api);
|
||||||
|
|
||||||
|
expect(api.getMicrophoneManager().disconnect).toBeCalled();
|
||||||
|
});
|
||||||
@@ -10,6 +10,7 @@ import { GenericAction } from '../../../src/card-controller/actions/actions/gene
|
|||||||
import { LogAction } from '../../../src/card-controller/actions/actions/log';
|
import { LogAction } from '../../../src/card-controller/actions/actions/log';
|
||||||
import { MediaPlayerAction } from '../../../src/card-controller/actions/actions/media-player';
|
import { MediaPlayerAction } from '../../../src/card-controller/actions/actions/media-player';
|
||||||
import { MenuToggleAction } from '../../../src/card-controller/actions/actions/menu-toggle';
|
import { MenuToggleAction } from '../../../src/card-controller/actions/actions/menu-toggle';
|
||||||
|
import { MicrophoneDisconnectAction } from '../../../src/card-controller/actions/actions/microphone-disconnect';
|
||||||
import { MicrophoneMuteAction } from '../../../src/card-controller/actions/actions/microphone-mute';
|
import { MicrophoneMuteAction } from '../../../src/card-controller/actions/actions/microphone-mute';
|
||||||
import { MicrophoneUnmuteAction } from '../../../src/card-controller/actions/actions/microphone-unmute';
|
import { MicrophoneUnmuteAction } from '../../../src/card-controller/actions/actions/microphone-unmute';
|
||||||
import { MuteAction } from '../../../src/card-controller/actions/actions/mute';
|
import { MuteAction } from '../../../src/card-controller/actions/actions/mute';
|
||||||
@@ -103,6 +104,10 @@ describe('ActionFactory', () => {
|
|||||||
MediaPlayerAction,
|
MediaPlayerAction,
|
||||||
],
|
],
|
||||||
[{ frigate_card_action: 'menu_toggle' as const }, MenuToggleAction],
|
[{ frigate_card_action: 'menu_toggle' as const }, MenuToggleAction],
|
||||||
|
[
|
||||||
|
{ frigate_card_action: 'microphone_disconnect' as const },
|
||||||
|
MicrophoneDisconnectAction,
|
||||||
|
],
|
||||||
[{ frigate_card_action: 'microphone_mute' as const }, MicrophoneMuteAction],
|
[{ frigate_card_action: 'microphone_mute' as const }, MicrophoneMuteAction],
|
||||||
[{ frigate_card_action: 'microphone_unmute' as const }, MicrophoneUnmuteAction],
|
[{ frigate_card_action: 'microphone_unmute' as const }, MicrophoneUnmuteAction],
|
||||||
[{ frigate_card_action: 'mute' as const }, MuteAction],
|
[{ frigate_card_action: 'mute' as const }, MuteAction],
|
||||||
|
|||||||
Reference in New Issue
Block a user