UNPKG

eufy-security-client-fork

Version:

Client to comunicate with Eufy-Security devices

312 lines (311 loc) 15.3 kB
/// <reference types="node" /> /// <reference types="node" /> import { TypedEmitter } from "tiny-typed-emitter"; import { Logger } from "ts-log"; import { HTTPApi } from "./api"; import { CommandName, DeviceEvent } from "./types"; import { DeviceListResponse } from "./models"; import { DeviceEvents, PropertyValue, PropertyValues, PropertyMetadataAny, IndexedProperty, RawValues } from "./interfaces"; import { PushMessage } from "../push/models"; import { DeviceSmartLockNotifyData } from "../mqtt/model"; import { Voices } from "."; export declare class Device extends TypedEmitter<DeviceEvents> { protected api: HTTPApi; protected rawDevice: DeviceListResponse; protected log: Logger; protected eventTimeouts: Map<DeviceEvent, NodeJS.Timeout>; protected properties: PropertyValues; private rawProperties; private ready; protected constructor(api: HTTPApi, device: DeviceListResponse); protected initializeState(): void; getRawDevice(): DeviceListResponse; update(device: DeviceListResponse, cloudOnlyProperties?: boolean): void; updateProperty(name: string, value: PropertyValue): boolean; updateRawProperties(values: RawValues): void; protected handlePropertyChange(metadata: PropertyMetadataAny, oldValue: PropertyValue, newValue: PropertyValue): void; updateRawProperty(type: number, value: string): boolean; protected convertRawPropertyValue(property: PropertyMetadataAny, value: string): PropertyValue; getPropertyMetadata(name: string): PropertyMetadataAny; getPropertyValue(name: string): PropertyValue; hasPropertyValue(name: string): boolean; getRawProperty(type: number): string; getRawProperties(): RawValues; getProperties(): PropertyValues; getPropertiesMetadata(): IndexedProperty; hasProperty(name: string): boolean; getCommands(): Array<CommandName>; hasCommand(name: CommandName): boolean; processPushNotification(_message: PushMessage, _eventDurationSeconds: number): void; setCustomPropertyValue(name: string, value: PropertyValue): void; destroy(): void; protected clearEventTimeout(eventType: DeviceEvent): void; static isCamera(type: number): boolean; static hasBattery(type: number): boolean; static isStation(type: number): boolean; static isSensor(type: number): boolean; static isKeyPad(type: number): boolean; static isDoorbell(type: number): boolean; static isWiredDoorbell(type: number): boolean; static isWiredDoorbellDual(type: number): boolean; static isIndoorCamera(type: number): boolean; static isPanAndTiltCamera(type: number): boolean; static isFloodLight(type: number): boolean; static isLock(type: number): boolean; static isLockBle(type: number): boolean; static isLockBleNoFinger(type: number): boolean; static isLockWifi(type: number): boolean; static isLockWifiNoFinger(type: number): boolean; static isBatteryDoorbell1(type: number): boolean; static isBatteryDoorbell2(type: number): boolean; static isBatteryDoorbellDual(type: number): boolean; static isDoorbellDual(type: number): boolean; static isBatteryDoorbell(type: number): boolean; static isSoloCamera(type: number): boolean; static isSoloCameraPro(type: number): boolean; static isSoloCameraSpotlight1080(type: number): boolean; static isSoloCameraSpotlight2k(type: number): boolean; static isSoloCameraSpotlightSolar(type: number): boolean; static isSoloCameras(type: number): boolean; static isIndoorOutdoorCamera1080p(type: number): boolean; static isIndoorOutdoorCamera1080pNoLight(type: number): boolean; static isIndoorOutdoorCamera2k(type: number): boolean; static isIndoorCamMini(type: number): boolean; static isCamera2(type: number): boolean; static isCamera2C(type: number): boolean; static isCamera2Pro(type: number): boolean; static isCamera2CPro(type: number): boolean; static isCamera2Product(type: number): boolean; static isEntrySensor(type: number): boolean; static isMotionSensor(type: number): boolean; static isSmartDrop(type: number): boolean; static isSmartSafe(type: number): boolean; static isIntegratedDeviceBySn(sn: string): boolean; static isSoloCameraBySn(sn: string): boolean; isCamera(): boolean; isFloodLight(): boolean; isDoorbell(): boolean; isWiredDoorbell(): boolean; isWiredDoorbellDual(): boolean; isLock(): boolean; isLockBle(): boolean; isLockBleNoFinger(): boolean; isLockWifi(): boolean; isLockWifiNoFinger(): boolean; isBatteryDoorbell1(): boolean; isBatteryDoorbell2(): boolean; isBatteryDoorbellDual(): boolean; isDoorbellDual(): boolean; isBatteryDoorbell(): boolean; isSoloCamera(): boolean; isSoloCameraPro(): boolean; isSoloCameraSpotlight1080(): boolean; isSoloCameraSpotlight2k(): boolean; isSoloCameraSpotlightSolar(): boolean; isIndoorOutdoorCamera1080p(): boolean; isIndoorOutdoorCamera1080pNoLight(): boolean; isIndoorOutdoorCamera2k(): boolean; isIndoorCamMini(): boolean; isSoloCameras(): boolean; isCamera2(): boolean; isCamera2C(): boolean; isCamera2Pro(): boolean; isCamera2CPro(): boolean; isCamera2Product(): boolean; isEntrySensor(): boolean; isKeyPad(): boolean; isMotionSensor(): boolean; isIndoorCamera(): boolean; isPanAndTiltCamera(): boolean; isSmartDrop(): boolean; isSmartSafe(): boolean; isIntegratedDevice(): boolean; hasBattery(): boolean; getDeviceKey(): string; getDeviceType(): number; getHardwareVersion(): string; getSoftwareVersion(): string; getModel(): string; getName(): string; getSerial(): string; getStationSerial(): string; setParameters(params: { paramType: number; paramValue: any; }[]): Promise<boolean>; getChannel(): number; getStateID(state: string, level?: number): string; getStateChannel(): string; getWifiRssi(): PropertyValue; getStoragePath(filename: string): string; isEnabled(): PropertyValue; } export declare class Camera extends Device { private _isStreaming; protected constructor(api: HTTPApi, device: DeviceListResponse); static initialize(api: HTTPApi, device: DeviceListResponse): Promise<Camera>; getStateChannel(): string; protected convertRawPropertyValue(property: PropertyMetadataAny, value: string): PropertyValue; getLastCameraImageURL(): PropertyValue; getMACAddress(): string; startDetection(): Promise<void>; startStream(): Promise<string>; stopDetection(): Promise<void>; stopStream(): Promise<void>; getState(): PropertyValue; isStreaming(): boolean; close(): Promise<void>; getLastChargingDays(): number; getLastChargingFalseEvents(): number; getLastChargingRecordedEvents(): number; getLastChargingTotalEvents(): number; getBatteryValue(): PropertyValue; getBatteryTemperature(): PropertyValue; isMotionDetectionEnabled(): PropertyValue; isLedEnabled(): PropertyValue; isAutoNightVisionEnabled(): PropertyValue; isRTSPStreamEnabled(): PropertyValue; isAntiTheftDetectionEnabled(): PropertyValue; getWatermark(): PropertyValue; isMotionDetected(): boolean; isPersonDetected(): boolean; getDetectedPerson(): string; protected handlePropertyChange(metadata: PropertyMetadataAny, oldValue: PropertyValue, newValue: PropertyValue): void; processPushNotification(message: PushMessage, eventDurationSeconds: number): void; } export declare class SoloCamera extends Camera { static initialize(api: HTTPApi, device: DeviceListResponse): Promise<SoloCamera>; isLedEnabled(): PropertyValue; isMotionDetectionEnabled(): PropertyValue; processPushNotification(message: PushMessage, eventDurationSeconds: number): void; } export declare class IndoorCamera extends Camera { protected constructor(api: HTTPApi, device: DeviceListResponse); static initialize(api: HTTPApi, device: DeviceListResponse): Promise<IndoorCamera>; isLedEnabled(): PropertyValue; isMotionDetectionEnabled(): PropertyValue; isPetDetectionEnabled(): PropertyValue; isSoundDetectionEnabled(): PropertyValue; isPetDetected(): boolean; isSoundDetected(): boolean; isCryingDetected(): boolean; protected handlePropertyChange(metadata: PropertyMetadataAny, oldValue: PropertyValue, newValue: PropertyValue): void; processPushNotification(message: PushMessage, eventDurationSeconds: number): void; destroy(): void; } export declare class DoorbellCamera extends Camera { protected voices: Voices; protected constructor(api: HTTPApi, device: DeviceListResponse, voices: Voices); static initialize(api: HTTPApi, device: DeviceListResponse): Promise<DoorbellCamera>; private loadMetadataVoiceStates; getVoiceName(id: number): string; getVoices(): Voices; getPropertiesMetadata(): IndexedProperty; isRinging(): boolean; protected handlePropertyChange(metadata: PropertyMetadataAny, oldValue: PropertyValue, newValue: PropertyValue): void; processPushNotification(message: PushMessage, eventDurationSeconds: number): void; } export declare class WiredDoorbellCamera extends DoorbellCamera { static initialize(api: HTTPApi, device: DeviceListResponse): Promise<WiredDoorbellCamera>; isLedEnabled(): PropertyValue; isAutoNightVisionEnabled(): PropertyValue; isMotionDetectionEnabled(): PropertyValue; } export declare class BatteryDoorbellCamera extends DoorbellCamera { static initialize(api: HTTPApi, device: DeviceListResponse): Promise<BatteryDoorbellCamera>; isLedEnabled(): PropertyValue; } export declare class FloodlightCamera extends Camera { static initialize(api: HTTPApi, device: DeviceListResponse): Promise<FloodlightCamera>; isLedEnabled(): PropertyValue; isMotionDetectionEnabled(): PropertyValue; protected convertRawPropertyValue(property: PropertyMetadataAny, value: string): PropertyValue; } export declare class Sensor extends Device { static initialize(api: HTTPApi, device: DeviceListResponse): Promise<Sensor>; getStateChannel(): string; getState(): PropertyValue; } export declare class EntrySensor extends Sensor { static initialize(api: HTTPApi, device: DeviceListResponse): Promise<EntrySensor>; isSensorOpen(): PropertyValue; getSensorChangeTime(): PropertyValue; isBatteryLow(): PropertyValue; processPushNotification(message: PushMessage, eventDurationSeconds: number): void; protected handlePropertyChange(metadata: PropertyMetadataAny, oldValue: PropertyValue, newValue: PropertyValue): void; } export declare class MotionSensor extends Sensor { static readonly MOTION_COOLDOWN_MS = 120000; protected constructor(api: HTTPApi, device: DeviceListResponse); static initialize(api: HTTPApi, device: DeviceListResponse): Promise<MotionSensor>; isMotionDetected(): boolean; getMotionSensorPIREvent(): PropertyValue; isBatteryLow(): PropertyValue; protected handlePropertyChange(metadata: PropertyMetadataAny, oldValue: PropertyValue, newValue: PropertyValue): void; processPushNotification(message: PushMessage, eventDurationSeconds: number): void; } export declare class Lock extends Device { static initialize(api: HTTPApi, device: DeviceListResponse): Promise<Lock>; getStateChannel(): string; protected handlePropertyChange(metadata: PropertyMetadataAny, oldValue: PropertyValue, newValue: PropertyValue): void; getState(): PropertyValue; getBatteryValue(): PropertyValue; getWifiRssi(): PropertyValue; isLocked(): PropertyValue; getLockStatus(): PropertyValue; static encodeESLCmdOnOff(short_user_id: number, nickname: string, lock: boolean): Buffer; static encodeESLCmdQueryStatus(admin_user_id: string): Buffer; processPushNotification(message: PushMessage, eventDurationSeconds: number): void; processMQTTNotification(message: DeviceSmartLockNotifyData, eventDurationSeconds: number): void; private processNotification; } export declare class Keypad extends Device { static initialize(api: HTTPApi, device: DeviceListResponse): Promise<Keypad>; getStateChannel(): string; getState(): PropertyValue; isBatteryLow(): PropertyValue; isBatteryCharging(): PropertyValue; protected convertRawPropertyValue(property: PropertyMetadataAny, value: string): PropertyValue; } export declare class SmartSafe extends Device { static readonly IV = "052E19EB3F880512E99EBB684D4DC1FE"; static readonly DATA_HEADER: number[]; static readonly VERSION_CODE = 1; static readonly PUSH_NOTIFICATION_POSITION: { [index: string]: number; }; static initialize(api: HTTPApi, device: DeviceListResponse): Promise<SmartSafe>; getStateChannel(): string; private static getCurrentTimeInSeconds; private static getUInt8Buffer; private static getUint16LEBuffer; private static encodeCmdSingleUInt8; static encodeCmdWrongTryProtect(user_id: string, enabled: boolean, attempts: number, lockdownTime: number): Buffer; static encodeCmdLeftOpenAlarm(user_id: string, enabled: boolean, duration: number): Buffer; static encodeCmdDualUnlock(user_id: string, enabled: boolean): Buffer; static encodeCmdScramblePIN(user_id: string, enabled: boolean): Buffer; static encodeCmdPowerSave(user_id: string, enabled: boolean): Buffer; static encodeCmdInteriorBrightness(user_id: string, interiorBrightness: number, duration: number): Buffer; static encodeCmdTamperAlarm(user_id: string, option: number): Buffer; static encodeCmdRemoteUnlock(user_id: string, option: number): Buffer; static encodeCmdAlertVolume(user_id: string, volume: number): Buffer; static encodeCmdPromptVolume(user_id: string, volume: number): Buffer; static encodeCmdPushNotification(user_id: string, modes: number): Buffer; static encodeCmdUnlock(user_id: string): Buffer; protected convertRawPropertyValue(property: PropertyMetadataAny, value: string): PropertyValue; shakeEvent(event: number, eventDurationSeconds: number): void; alarm911Event(event: number, eventDurationSeconds: number): void; jammedEvent(eventDurationSeconds: number): void; lowBatteryEvent(eventDurationSeconds: number): void; wrongTryProtectAlarmEvent(eventDurationSeconds: number): void; processPushNotification(message: PushMessage, eventDurationSeconds: number): void; protected handlePropertyChange(metadata: PropertyMetadataAny, oldValue: PropertyValue, newValue: PropertyValue): void; getState(): PropertyValue; getBatteryValue(): PropertyValue; getWifiRssi(): PropertyValue; isLocked(): boolean; } export declare class UnknownDevice extends Device { static initialize(api: HTTPApi, device: DeviceListResponse): Promise<UnknownDevice>; getStateChannel(): string; }