feat: Add out of the box support for Reolink PTZ (#1982)
- Closes: #1964
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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>;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user