refactor: Unify substream actions into substream_{on,off} (#2497)
## Summary
- Collapse `live_substream_{on,off,select}` into a unified
`substream_{on,off}` pair, symmetric with `call_{start,end}`.
- Rename the `camera` field on the former `live_substream_select` to
`stream` (it always was a stream ID).
- Add optional `camera` field to both new actions for targeting a
non-selected base camera.
- YAML configs are migrated automatically; URL bookmarks must be updated
by hand.
## Migration
### Cycling between camera and substream (toggle button)
Before:
```yaml
tap_action:
action: custom:advanced-camera-card-action
advanced_camera_card_action: live_substream_on
```
After:
```yaml
tap_action:
action: custom:advanced-camera-card-action
advanced_camera_card_action: substream_on
```
### Selecting a specific substream
Before:
```yaml
tap_action:
action: custom:advanced-camera-card-action
advanced_camera_card_action: live_substream_select
camera: camera.front_door_hd
```
After:
```yaml
tap_action:
action: custom:advanced-camera-card-action
advanced_camera_card_action: substream_on
stream: camera.front_door_hd
```
### Turning the substream off
Before:
```yaml
tap_action:
action: custom:advanced-camera-card-action
advanced_camera_card_action: live_substream_off
```
After:
```yaml
tap_action:
action: custom:advanced-camera-card-action
advanced_camera_card_action: substream_off
```
### URL querystrings (manual update required)
| Before | After |
| --- | --- |
|
`?advanced-camera-card-action.live_substream_select=camera.front_door_hd`
| `?advanced-camera-card-action.substream_on=camera.front_door_hd` |
This commit is contained in:
committed by
dermotduffy
parent
15e335a647
commit
f18e4cd4b8
+37
-13
@@ -27,7 +27,8 @@ import {
|
||||
PTZActionPhase,
|
||||
} from '../config/schema/actions/custom/ptz.js';
|
||||
import { SetReviewActionConfig } from '../config/schema/actions/custom/set-review.js';
|
||||
import { SubstreamSelectActionConfig } from '../config/schema/actions/custom/substream-select.js';
|
||||
import { SubstreamOffActionConfig } from '../config/schema/actions/custom/substream-off.js';
|
||||
import { SubstreamOnActionConfig } from '../config/schema/actions/custom/substream-on.js';
|
||||
import { ViewActionConfig } from '../config/schema/actions/custom/view.js';
|
||||
import { PerformActionActionConfig } from '../config/schema/actions/stock/perform-action.js';
|
||||
import type { Notification } from '../config/schema/actions/types.js';
|
||||
@@ -72,20 +73,45 @@ export function createViewAction(
|
||||
}
|
||||
|
||||
export function createCameraAction(
|
||||
action: 'camera_select' | 'live_substream_select',
|
||||
camera: string,
|
||||
options?: {
|
||||
cardID?: string;
|
||||
},
|
||||
): CameraSelectActionConfig | SubstreamSelectActionConfig {
|
||||
): CameraSelectActionConfig {
|
||||
return {
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: action,
|
||||
advanced_camera_card_action: 'camera_select',
|
||||
camera: camera,
|
||||
...(options?.cardID && { card_id: options.cardID }),
|
||||
};
|
||||
}
|
||||
|
||||
export function createSubstreamOnAction(options?: {
|
||||
stream?: string;
|
||||
camera?: string;
|
||||
cardID?: string;
|
||||
}): SubstreamOnActionConfig {
|
||||
return {
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'substream_on',
|
||||
...(options?.stream && { stream: options.stream }),
|
||||
...(options?.camera && { camera: options.camera }),
|
||||
...(options?.cardID && { card_id: options.cardID }),
|
||||
};
|
||||
}
|
||||
|
||||
export function createSubstreamOffAction(options?: {
|
||||
camera?: string;
|
||||
cardID?: string;
|
||||
}): SubstreamOffActionConfig {
|
||||
return {
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'substream_off',
|
||||
...(options?.camera && { camera: options.camera }),
|
||||
...(options?.cardID && { card_id: options.cardID }),
|
||||
};
|
||||
}
|
||||
|
||||
export function createMediaPlayerAction(
|
||||
mediaPlayer: string,
|
||||
mediaPlayerAction: 'play' | 'stop',
|
||||
@@ -274,18 +300,16 @@ export function createSetReviewAction(reviewed?: boolean): SetReviewActionConfig
|
||||
};
|
||||
}
|
||||
|
||||
export function createCallStartAction(
|
||||
camera?: string,
|
||||
stream?: string,
|
||||
options?: {
|
||||
cardID?: string;
|
||||
},
|
||||
): CallStartActionConfig {
|
||||
export function createCallStartAction(options?: {
|
||||
camera?: string;
|
||||
stream?: string;
|
||||
cardID?: string;
|
||||
}): CallStartActionConfig {
|
||||
return {
|
||||
action: 'fire-dom-event',
|
||||
advanced_camera_card_action: 'call_start',
|
||||
...(camera && { camera }),
|
||||
...(stream && { stream }),
|
||||
...(options?.camera && { camera: options.camera }),
|
||||
...(options?.stream && { stream: options.stream }),
|
||||
...(options?.cardID && { card_id: options.cardID }),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user