feat: Add support for Frigate reviews / detections [initial PR] (#2315)

- Add support for Frigate reviews / detections.
 - Add support for GenAI metadata.
- Significant internal refactor to more flexible "UnifiedQuery" to allow
mixing cameras with simple metadata and review metadata (e.g. a timeline
view of a Frigate camera with reviews, and a Reolink camera with simple
metadata).
 - Add support for folder media as camera media.

There are a few more PRs to commit prior to this going live, but
commiting this for now due to the scale of the change.

BREAKING CHANGE: `media_type` and `events_type` are retired under
`live`, `viewer` and `timeline` configuration sections, instead media
type is associated (once) with the camera under `media`.
This commit is contained in:
Dermot Duffy
2026-01-19 13:32:50 -08:00
committed by GitHub
parent 6eb0a87ca8
commit fc32727860
215 changed files with 14491 additions and 6160 deletions
@@ -0,0 +1,94 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
import { mock } from 'vitest-mock-extended';
import { supports2WayAudio } from '../../../src/camera-manager/utils/go2rtc/audio';
import { homeAssistantSignAndFetch } from '../../../src/ha/fetch';
import { HomeAssistant } from '../../../src/ha/types';
import { createProxiedEndpointIfNecessary } from '../../../src/ha/web-proxy';
import { Endpoint } from '../../../src/types';
vi.mock('../../../src/ha/fetch');
vi.mock('../../../src/ha/web-proxy');
describe('supports2WayAudio', () => {
const hass = mock<HomeAssistant>();
const endpoint: Endpoint = { endpoint: 'http://go2rtc', sign: true };
beforeEach(() => {
vi.clearAllMocks();
});
it('should return false if no endpoint provided', async () => {
expect(await supports2WayAudio(hass, null)).toBe(false);
});
it('should return false if fetch fails', async () => {
vi.mocked(createProxiedEndpointIfNecessary).mockResolvedValue(endpoint);
vi.mocked(homeAssistantSignAndFetch).mockRejectedValue(new Error('fetch error'));
const spy = vi.spyOn(console, 'warn').mockImplementation(() => {});
const result = await supports2WayAudio(hass, endpoint);
expect(result).toBe(false);
expect(spy).toHaveBeenCalledWith('fetch error');
spy.mockRestore();
});
it('should return false if stream info has no producers', async () => {
vi.mocked(createProxiedEndpointIfNecessary).mockResolvedValue(endpoint);
vi.mocked(homeAssistantSignAndFetch).mockResolvedValue({ producers: undefined });
expect(await supports2WayAudio(hass, endpoint)).toBe(false);
});
it('should return false if no producer supports audio', async () => {
vi.mocked(createProxiedEndpointIfNecessary).mockResolvedValue(endpoint);
vi.mocked(homeAssistantSignAndFetch).mockResolvedValue({
producers: [
{
medias: ['video,sendonly,h264'],
},
],
});
expect(await supports2WayAudio(hass, endpoint)).toBe(false);
});
it('should return true if producer supports audio and sendonly', async () => {
vi.mocked(createProxiedEndpointIfNecessary).mockResolvedValue(endpoint);
vi.mocked(homeAssistantSignAndFetch).mockResolvedValue({
producers: [
{
medias: ['audio,sendonly,opus'],
},
],
});
expect(await supports2WayAudio(hass, endpoint)).toBe(true);
});
it('should return true if producer supports audio and sendrecv', async () => {
vi.mocked(createProxiedEndpointIfNecessary).mockResolvedValue(endpoint);
vi.mocked(homeAssistantSignAndFetch).mockResolvedValue({
producers: [
{
medias: ['audio,sendrecv,pcmu'],
},
],
});
expect(await supports2WayAudio(hass, endpoint)).toBe(true);
});
it('should handle missing medias in producer', async () => {
vi.mocked(createProxiedEndpointIfNecessary).mockResolvedValue(endpoint);
vi.mocked(homeAssistantSignAndFetch).mockResolvedValue({
producers: [
{
medias: undefined,
},
],
});
expect(await supports2WayAudio(hass, endpoint)).toBe(false);
});
});
+1 -1
View File
@@ -4,7 +4,7 @@ import {
getConfiguredPTZMovementType,
getPTZCapabilitiesFromCameraConfig,
} from '../../../src/camera-manager/utils/ptz';
import { PTZAction } from '../../../src/config/ptz';
import { PTZAction } from '../../../src/config/schema/actions/custom/ptz';
import { createCameraConfig } from '../../test-utils';
const action = {