feat: Add out of the box support for Reolink PTZ (#1982)

- Closes: #1964
This commit is contained in:
Dermot Duffy
2025-03-26 21:26:02 -07:00
committed by GitHub
parent f6bb8001e3
commit b5eee5878a
50 changed files with 953 additions and 679 deletions
+8 -2
View File
@@ -2,7 +2,13 @@ import { HomeAssistant } from '../../../../ha/types.js';
import { errorToConsole } from '../../../basic.js';
import { homeAssistantWSRequest } from '../../ws-request.js';
import { RegistryCache } from '../cache.js';
import { Entity, EntityList, entityListSchema, entitySchema } from './types.js';
import {
Entity,
EntityList,
entityListSchema,
EntityRegistryManager,
entitySchema,
} from './types.js';
export const createEntityRegistryCache = (): RegistryCache<Entity> => {
return new RegistryCache<Entity>((entity) => entity.entity_id);
@@ -12,7 +18,7 @@ export const createEntityRegistryCache = (): RegistryCache<Entity> => {
// as necessary. Some calls require every entity to be fetched, which may be
// non-trivial in size (after which they are cached forever).
export class EntityRegistryManager {
export class EntityRegistryManagerLive implements EntityRegistryManager {
protected _cache: RegistryCache<Entity>;
protected _fetchedEntityList = false;
+11
View File
@@ -1,4 +1,5 @@
import { z } from 'zod';
import { HomeAssistant } from '../../../../ha/types';
export const entitySchema = z.object({
config_entry_id: z.string().nullable(),
@@ -17,3 +18,13 @@ export type Entity = z.infer<typeof entitySchema>;
export const entityListSchema = entitySchema.array();
export type EntityList = z.infer<typeof entityListSchema>;
export interface EntityRegistryManager {
getEntity(hass: HomeAssistant, entityID: string): Promise<Entity | null>;
getEntities(hass: HomeAssistant, entityIDs: string[]): Promise<Map<string, Entity>>;
getMatchingEntities(
hass: HomeAssistant,
func: (arg: Entity) => boolean,
): Promise<Entity[]>;
fetchEntityList(hass: HomeAssistant): Promise<void>;
}