feat: Add new option to always error on entity unavailable (#1770)
This commit is contained in:
@@ -16,22 +16,23 @@ cameras_global:
|
|||||||
# [...]
|
# [...]
|
||||||
```
|
```
|
||||||
|
|
||||||
| Option | Default | Description |
|
| Option | Default | Description |
|
||||||
| --------------- | ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
| ------------------------------------ | ------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
||||||
| `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. |
|
| `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`. |
|
||||||
| `capabilities` | | Allows selective disabling of camera capabilities. See below. |
|
| `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. |
|
||||||
| `cast` | | Configuration that controls how this camera is "casted" / sent to media players. See below. |
|
| `capabilities` | | Allows selective disabling of camera capabilities. See below. |
|
||||||
| `dependencies` | | Other cameras that this camera should depend upon. See below. |
|
| `cast` | | Configuration that controls how this camera is "casted" / sent to media players. See below. |
|
||||||
| `dimensions` | | Controls the dimensions and layout for media from this camera. See below. |
|
| `dependencies` | | Other cameras that this camera should depend upon. See below. |
|
||||||
| `engine` | `auto` | The camera engine to use. If `auto` the card will attempt to choose the correct engine from the specified options. See [Engine](engine.md). |
|
| `dimensions` | | Controls the dimensions and layout for media from this camera. See below. |
|
||||||
| `frigate` | | Options for Frigate cameras. See [Frigate camera engine configuration](engine.md?id=frigate). |
|
| `engine` | `auto` | The camera engine to use. If `auto` the card will attempt to choose the correct engine from the specified options. See [Engine](engine.md). |
|
||||||
| `icon` | Autodetected from `camera_entity` if that is specified. | The icon to use for this camera in the camera menu and in the next & previous controls when using the `icon` style. |
|
| `frigate` | | Options for Frigate cameras. See [Frigate camera engine configuration](engine.md?id=frigate). |
|
||||||
| `id` | `camera_entity`, `webrtc_card.entity` or `frigate.camera_name` if set (in that preference order). | An optional identifier to use throughout the card configuration to refer unambiguously to this camera. This `id` may be used in [conditions](../conditions.md), dependencies or custom [actions](../actions/README.md) to refer to a given camera unambiguously. |
|
| `icon` | Autodetected from `camera_entity` if that is specified. | The icon to use for this camera in the camera menu and in the next & previous controls when using the `icon` style. |
|
||||||
| `live_provider` | `auto` | The choice of live stream provider. See [Live Provider](live-provider.md). |
|
| `id` | `camera_entity`, `webrtc_card.entity` or `frigate.camera_name` if set (in that preference order). | An optional identifier to use throughout the card configuration to refer unambiguously to this camera. This `id` may be used in [conditions](../conditions.md), dependencies or custom [actions](../actions/README.md) to refer to a given camera unambiguously. |
|
||||||
| `proxy` | | Controls whether/how content is proxied via [hass-web-proxy-integration](https://github.com/dermotduffy/hass-web-proxy-integration) (must be installed separately). See below. |
|
| `live_provider` | `auto` | The choice of live stream provider. See [Live Provider](live-provider.md). |
|
||||||
| `title` | Autodetected from `camera_entity` if that is specified. | A friendly name for this camera to use in the card. |
|
| `proxy` | | Controls whether/how content is proxied via [hass-web-proxy-integration](https://github.com/dermotduffy/hass-web-proxy-integration) (must be installed separately). See below. |
|
||||||
| `triggers` | | Define what should cause this camera to update/trigger. See below. |
|
| `title` | Autodetected from `camera_entity` if that is specified. | A friendly name for this camera to use in the card. |
|
||||||
| `webrtc_card` | | The WebRTC entity/URL to use for this camera with the `webrtc-card` live provider. See below. |
|
| `triggers` | | Define what should cause this camera to update/trigger. See below. |
|
||||||
|
| `webrtc_card` | | The WebRTC entity/URL to use for this camera with the `webrtc-card` live provider. See below. |
|
||||||
|
|
||||||
## `capabilities`
|
## `capabilities`
|
||||||
|
|
||||||
|
|||||||
@@ -271,7 +271,12 @@ export class FrigateCardLiveProvider
|
|||||||
hidden: showImageDuringLoading,
|
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) {
|
if (!this.cameraConfig?.camera_entity) {
|
||||||
dispatchLiveErrorEvent(this);
|
dispatchLiveErrorEvent(this);
|
||||||
return renderMessage({
|
return renderMessage({
|
||||||
|
|||||||
@@ -1359,6 +1359,7 @@ const cameraConfigDefault = {
|
|||||||
ssl_verification: 'auto' as const,
|
ssl_verification: 'auto' as const,
|
||||||
ssl_ciphers: 'auto' as const,
|
ssl_ciphers: 'auto' as const,
|
||||||
},
|
},
|
||||||
|
always_error_if_entity_unavailable: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
const SSL_CIPHERS = ['default', 'insecure', 'intermediate', 'modern'] as const;
|
const SSL_CIPHERS = ['default', 'insecure', 'intermediate', 'modern'] as const;
|
||||||
@@ -1485,6 +1486,11 @@ export const cameraConfigSchema = z
|
|||||||
.optional(),
|
.optional(),
|
||||||
|
|
||||||
proxy: proxyConfigSchema.default(cameraConfigDefault.proxy),
|
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);
|
.default(cameraConfigDefault);
|
||||||
export type CameraConfig = z.infer<typeof cameraConfigSchema>;
|
export type CameraConfig = z.infer<typeof cameraConfigSchema>;
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ describe('config defaults', () => {
|
|||||||
expect(createConfig()).toEqual({
|
expect(createConfig()).toEqual({
|
||||||
cameras: [{}],
|
cameras: [{}],
|
||||||
cameras_global: {
|
cameras_global: {
|
||||||
|
always_error_if_entity_unavailable: false,
|
||||||
dependencies: {
|
dependencies: {
|
||||||
all_cameras: false,
|
all_cameras: false,
|
||||||
cameras: [],
|
cameras: [],
|
||||||
|
|||||||
Reference in New Issue
Block a user