UNPKG

@viguza/homebridge-ezviz

Version:

A short description about what your plugin does.

82 lines (81 loc) 3.35 kB
import { Logging } from 'homebridge'; import { Credentials } from '../types/login.js'; import { ListDevicesResponse } from '../types/devices.js'; import { EZVIZConfig } from '../types/config.js'; import { DefenceMode } from '../utils/enums.js'; /** * EZVIZ API client for interacting with EZVIZ services */ export declare class EZVIZAPI { private config; sessionId: string | null; private log; constructor(config: EZVIZConfig, log?: Logging); /** * Generates a random string of specified length * @param length - The length of the string to generate * @returns Random string */ randomStr(length: number): string; /** * Authenticates with the EZVIZ API * @returns Promise resolving to credentials or undefined if authentication fails */ authenticate(): Promise<Credentials | undefined>; /** * Refreshes the session using the refresh token, falling back to full re-authentication * if the refresh token is missing or rejected. * @returns Promise resolving to updated credentials or undefined on failure */ refreshSession(): Promise<Credentials | undefined>; /** * Gets the domain URL for the specified region * @param id - The region ID * @returns Promise resolving to the domain URL */ getDomain(id: number): Promise<string>; /** * Returns the MQTT push address from the server info endpoint. * Used to connect the MQTT client for real-time push notifications. */ getServiceUrls(): Promise<string | null>; /** * Lists all devices for the authenticated user * @returns Promise resolving to device list or undefined if failed */ listDevices(): Promise<ListDevicesResponse | undefined>; /** * Returns the timestamp (ms) of the most recent alarm for a device, or null if none. * Fetches up to 10 recent messages and filters client-side — the API ignores the * deviceSerials query param and always returns global results. * The EZVIZ API may return the epoch in seconds or milliseconds; values > 1e10 are ms. */ getLastAlarmTime(serialNumber: string): Promise<number | null>; /** * Sets the state of a switch/plug * @param serialNumber - The device serial number * @param type - The switch type * @param value - The value to set (true/false) */ setSwitchState(serialNumber: string, type: number, value: boolean): Promise<void>; /** * Gets the current state of a switch/plug * @param serialNumber - The device serial number * @param type - The switch type * @returns Promise resolving to the switch state */ getSwitchState(serialNumber: string, type: number): Promise<boolean>; /** * Sets the defence mode (alarm mode) for a group * @param groupId - The group ID (default: 1) * @param mode - The defence mode (DefenceMode enum value) * @returns Promise resolving when defence mode is set */ setDefenceMode(groupId: number | undefined, mode: DefenceMode): Promise<void>; /** * Gets the current defence mode (alarm mode) for a group * @param groupId - The group ID (default: 1) * @returns Promise resolving to the current defence mode (DefenceMode enum value) */ getDefenceMode(groupId?: number): Promise<DefenceMode>; }