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:
Dermot Duffy
2026-06-30 17:45:13 -07:00
committed by dermotduffy
parent 15e335a647
commit f18e4cd4b8
32 changed files with 878 additions and 386 deletions
+56 -9
View File
@@ -20,6 +20,8 @@ import {
createPTZMultiAction,
createSelectOptionAction,
createSetReviewAction,
createSubstreamOffAction,
createSubstreamOnAction,
createViewAction,
getActionConfigGivenAction,
hasAction,
@@ -70,14 +72,12 @@ describe('createViewAction', () => {
describe('createCameraAction', () => {
it('should create camera_select action', () => {
expect(createCameraAction('camera_select', 'camera', { cardID: 'card_id' })).toEqual(
{
action: 'fire-dom-event',
camera: 'camera',
advanced_camera_card_action: 'camera_select',
card_id: 'card_id',
},
);
expect(createCameraAction('camera', { cardID: 'card_id' })).toEqual({
action: 'fire-dom-event',
camera: 'camera',
advanced_camera_card_action: 'camera_select',
card_id: 'card_id',
});
});
});
@@ -370,7 +370,9 @@ describe('createCallStartAction', () => {
it('should create call start action with a camera, stream and cardID', () => {
expect(
createCallStartAction('camera.front', 'camera.front_doorbell', {
createCallStartAction({
camera: 'camera.front',
stream: 'camera.front_doorbell',
cardID: 'card_id',
}),
).toEqual({
@@ -383,6 +385,51 @@ describe('createCallStartAction', () => {
});
});
describe('createSubstreamOnAction', () => {
it('should create substream_on action without options', () => {
expect(createSubstreamOnAction()).toEqual({
action: 'fire-dom-event',
advanced_camera_card_action: 'substream_on',
});
});
it('should create substream_on action with camera, stream, and cardID', () => {
expect(
createSubstreamOnAction({
camera: 'camera.front',
stream: 'camera.front_hd',
cardID: 'card_id',
}),
).toEqual({
action: 'fire-dom-event',
advanced_camera_card_action: 'substream_on',
camera: 'camera.front',
stream: 'camera.front_hd',
card_id: 'card_id',
});
});
});
describe('createSubstreamOffAction', () => {
it('should create substream_off action without options', () => {
expect(createSubstreamOffAction()).toEqual({
action: 'fire-dom-event',
advanced_camera_card_action: 'substream_off',
});
});
it('should create substream_off action with camera and cardID', () => {
expect(
createSubstreamOffAction({ camera: 'camera.front', cardID: 'card_id' }),
).toEqual({
action: 'fire-dom-event',
advanced_camera_card_action: 'substream_off',
camera: 'camera.front',
card_id: 'card_id',
});
});
});
describe('createCallEndAction', () => {
it('should create call end action', () => {
expect(createCallEndAction()).toEqual({