feat: Add new option to always error on entity unavailable (#1770)

This commit is contained in:
Dermot Duffy
2024-12-16 21:05:17 -08:00
committed by GitHub
parent 86439af90e
commit 0b681402db
4 changed files with 30 additions and 17 deletions
+2 -1
View File
@@ -17,7 +17,8 @@ cameras_global:
```
| Option | Default | Description |
| --------------- | ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| ------------------------------------ | ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `always_error_if_entity_unavailable` | `false` | When `true` and when `camera_entity` is specified, attempting to live stream this camera will always error out if the entity state is `unavailable`, even if the `live_provider` does not actually need the `camera_entity`. |
| `camera_entity` | | The Home Assistant camera entity to use with the `frigate` live provider view. Also used to automatically detect the name of the underlying Frigate camera, and the title/icon of the camera. |
| `capabilities` | | Allows selective disabling of camera capabilities. See below. |
| `cast` | | Configuration that controls how this camera is "casted" / sent to media players. See below. |
+6 -1
View File
@@ -271,7 +271,12 @@ export class FrigateCardLiveProvider
hidden: showImageDuringLoading,
};
if (provider === 'ha' || provider === 'image') {
if (
provider === 'ha' ||
provider === 'image' ||
(this.cameraConfig?.camera_entity &&
this.cameraConfig.always_error_if_entity_unavailable)
) {
if (!this.cameraConfig?.camera_entity) {
dispatchLiveErrorEvent(this);
return renderMessage({
+6
View File
@@ -1359,6 +1359,7 @@ const cameraConfigDefault = {
ssl_verification: 'auto' as const,
ssl_ciphers: 'auto' as const,
},
always_error_if_entity_unavailable: false,
};
const SSL_CIPHERS = ['default', 'insecure', 'intermediate', 'modern'] as const;
@@ -1485,6 +1486,11 @@ export const cameraConfigSchema = z
.optional(),
proxy: proxyConfigSchema.default(cameraConfigDefault.proxy),
// See: https://github.com/dermotduffy/frigate-hass-card/issues/1650
always_error_if_entity_unavailable: z
.boolean()
.default(cameraConfigDefault.always_error_if_entity_unavailable),
})
.default(cameraConfigDefault);
export type CameraConfig = z.infer<typeof cameraConfigSchema>;
+1
View File
@@ -15,6 +15,7 @@ describe('config defaults', () => {
expect(createConfig()).toEqual({
cameras: [{}],
cameras_global: {
always_error_if_entity_unavailable: false,
dependencies: {
all_cameras: false,
cameras: [],