feat: Add new casting profile (#1575)

* feat: Add new `casting` profile

* Set some additional flags for casting
This commit is contained in:
Dermot Duffy
2024-09-23 20:24:35 -07:00
committed by GitHub
parent d203f529f8
commit 1e0a990855
12 changed files with 78 additions and 6 deletions
+16 -4
View File
@@ -14,10 +14,21 @@ the user.
?> Profiles are applied top to bottom. If multiple profiles change a configuration default, then the last one "wins"
| Profile name | Purpose |
| ----------------- | -------------------------- |
| `low-performance` | Increase card performance. |
| `scrubbing` | Allow media "scrubbing". |
| Profile name | Purpose |
| ----------------- | ---------------------------------------------- |
| `casting` | Configure the card to be casted. |
| `low-performance` | Configure the card for lower end devices. |
| `scrubbing` | Configure the card to allow "video scrubbing". |
## `casting`
To aid casting the card to Chromecast devices, the `casting` profile will adjust card defaults to better suit casting. You may wish to combine this the `low-performance` profile below, since Chromecast devices tend to lower performance. To combine, list `low-performance` first, to allow `casting` to take precedence:
```yaml
profiles:
- low-performance
- casting
```
## `low-performance`
@@ -42,6 +53,7 @@ See the [source code](https://github.com/dermotduffy/frigate-hass-card/blob/dev/
```yaml
profiles:
- casting
- low-performance
- scrubbing
```
+23
View File
@@ -0,0 +1,23 @@
import {
CONF_CAMERAS_GLOBAL_IMAGE_REFRESH_SECONDS,
CONF_DIMENSIONS_ASPECT_RATIO,
CONF_LIVE_AUTO_UNMUTE,
CONF_LIVE_CONTROLS_BUILTIN,
CONF_LIVE_SHOW_IMAGE_DURING_LOAD,
CONF_MEDIA_VIEWER_CONTROLS_BUILTIN,
CONF_MENU_STYLE,
} from '../../const.js';
export const CASTING_PROFILE = {
[CONF_MENU_STYLE]: 'none' as const,
[CONF_LIVE_AUTO_UNMUTE]: ['selected', 'visible'],
[CONF_DIMENSIONS_ASPECT_RATIO]: '16:9',
[CONF_LIVE_CONTROLS_BUILTIN]: false,
[CONF_MEDIA_VIEWER_CONTROLS_BUILTIN]: false,
// These values are defaults anyway unless another profile (e.g.
// low-performance) is also selected, but at pretty important to a good
// experience so are reset here.
[CONF_CAMERAS_GLOBAL_IMAGE_REFRESH_SECONDS]: 1,
[CONF_LIVE_SHOW_IMAGE_DURING_LOAD]: true,
};
+3 -1
View File
@@ -1,10 +1,12 @@
import { deepRemoveDefaults } from '../../utils/zod.js';
import { getConfigValue, setConfigValue } from '../management.js';
import { ProfileType, RawFrigateCardConfig, frigateCardConfigSchema } from '../types.js';
import { deepRemoveDefaults } from '../../utils/zod.js';
import { CASTING_PROFILE } from './casting.js';
import { LOW_PERFORMANCE_PROFILE } from './low-performance.js';
import { SCRUBBING_PROFILE } from './scrubbing.js';
const PROFILES = {
casting: CASTING_PROFILE,
'low-performance': LOW_PERFORMANCE_PROFILE,
scrubbing: SCRUBBING_PROFILE,
};
+1 -1
View File
@@ -1973,7 +1973,7 @@ export interface CardWideConfig {
// *************************************************************************
// *** Profile Configuration ***
// *************************************************************************
const PROFILES = ['low-performance', 'scrubbing'] as const;
const PROFILES = ['casting', 'low-performance', 'scrubbing'] as const;
export type ProfileType = (typeof PROFILES)[number];
export const profilesSchema = z.enum(PROFILES).array().optional();
+1
View File
@@ -611,6 +611,7 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor
protected _profiles: EditorSelectOption[] = [
{ value: '', label: '' },
{ value: 'casting', label: localize('config.profiles.casting') },
{ value: 'low-performance', label: localize('config.profiles.low-performance') },
{ value: 'scrubbing', label: localize('config.profiles.scrubbing') },
];
+1
View File
@@ -413,6 +413,7 @@
"warning": "Aquesta targeta està en mode de perfil baix, de manera que els valors predeterminats han canviat per optimitzar el rendiment"
},
"profiles": {
"casting": "",
"editor_label": "",
"low-performance": "",
"scrubbing": ""
+1
View File
@@ -413,6 +413,7 @@
"warning": "This card is in low profile mode so defaults have changed to optimize performance"
},
"profiles": {
"casting": "Casting",
"editor_label": "Configuration profiles",
"low-performance": "Low performance",
"scrubbing": "Video scrubbing"
+1
View File
@@ -413,6 +413,7 @@
"warning": "Cette carte est en mode profil bas, les paramètres par défaut ont donc été modifiés pour optimiser les performances."
},
"profiles": {
"casting": "",
"editor_label": "Configuration des profils",
"low-performance": "Basse performance",
"scrubbing": "Balayage vidéo"
+1
View File
@@ -413,6 +413,7 @@
"warning": "Questa scheda è in modalità basso profilo, quindi le impostazioni predefinite sono state modificate per ottimizzare le prestazioni"
},
"profiles": {
"casting": "",
"editor_label": "",
"low-performance": "",
"scrubbing": ""
+1
View File
@@ -413,6 +413,7 @@
"warning": "Este cartão está no modo de baixo desempenho, então os padrões foram alterados para otimizar o desempenho"
},
"profiles": {
"casting": "",
"editor_label": "",
"low-performance": "",
"scrubbing": ""
+1
View File
@@ -413,6 +413,7 @@
"warning": "Avisos"
},
"profiles": {
"casting": "",
"editor_label": "",
"low-performance": "",
"scrubbing": ""
+28
View File
@@ -0,0 +1,28 @@
import { expect, it } from 'vitest';
import { setProfiles } from '../../../src/config/profiles';
import { frigateCardConfigSchema } from '../../../src/config/types';
import { createRawConfig } from '../../test-utils';
import { CASTING_PROFILE } from '../../../src/config/profiles/casting';
it('should contain expected defaults', () => {
expect(CASTING_PROFILE).toEqual({
'cameras_global.image.refresh_seconds': 1,
'dimensions.aspect_ratio': '16:9',
'live.auto_unmute': ['selected', 'visible'],
'live.controls.builtin': false,
'live.show_image_during_load': true,
'media_viewer.controls.builtin': false,
'menu.style': 'none',
});
});
it('should be parseable after application', () => {
const rawInputConfig = createRawConfig();
const parsedConfig = frigateCardConfigSchema.parse(rawInputConfig);
setProfiles(rawInputConfig, parsedConfig, ['casting']);
// Reparse the config to ensure the profile did not introduce errors.
const parseResult = frigateCardConfigSchema.safeParse(parsedConfig);
expect(parseResult.success, parseResult.error?.toString()).toBeTruthy();
});