/** * Eufy WebSocket API Device Events * * Contains TypeScript interfaces for device-level event payloads in the Eufy Security WebSocket API. * Uses official types from the upstream eufy-security-client repository where possible. * * See: eufy-security-ws/docs/api_events.md for event schema details. */ /** * Eufy WebSocket API Device Events * Schema 13+ Compatible Events * * This file contains TypeScript interfaces for * device-level event payloads in the Eufy Security WebSocket API. * * Based on eufy-security-ws/docs/api_events.md * Only includes events that are compatible with schema version 13+. * Note: timestamp fields were removed in schema version 10+. * * IMPORTANT: This file now uses official type definitions from the upstream * eufy-security-client repository (https://github.com/bropat/eufy-security-client) * instead of custom JSONValue placeholders where possible: * * - Schedule interface: Official Schedule type for user schedule events * - StreamMetadata: Official metadata type for video/audio stream events * - VideoMetadata/AudioMetadata: Type aliases derived from StreamMetadata * * These types provide better type safety and align with the canonical * eufy-security-client implementation. */ import { DEVICE_EVENTS, DeviceEventType } from "./constants"; import { EVENT_SOURCES } from "../common/constants"; import { JSONValue } from "../types/shared"; import { DevicePropertyName } from "./properties"; export interface Schedule { startDateTime?: Date; endDateTime?: Date; week?: { monday: boolean; tuesday: boolean; wednesday: boolean; thursday: boolean; friday: boolean; saturday: boolean; sunday: boolean; }; } export interface JSONBuffer { type: "Buffer"; data: number[]; } export interface VideoMetadata { videoCodec: string; videoFPS: number; videoWidth: number; videoHeight: number; } export interface AudioMetadata { audioCodec: string; } export type DeviceEventSource = typeof EVENT_SOURCES.DEVICE; export interface BaseDeviceEventPayload { source: DeviceEventSource; event: TEventName; } export interface BaseDeviceEventPayloadWithSerial extends BaseDeviceEventPayload { serialNumber: string; } export interface DeviceAddedEventPayload extends BaseDeviceEventPayload { device: string; } export interface DeviceRemovedEventPayload extends BaseDeviceEventPayload { device: string; } export interface DevicePropertyChangedEventPayload extends BaseDeviceEventPayloadWithSerial { name: DevicePropertyName; value: JSONValue; } export interface DeviceMotionDetectedEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DevicePersonDetectedEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; person: string; } export interface DevicePetDetectedEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceSoundDetectedEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceCryingDetectedEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceRingsEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceStrangerPersonDetectedEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceVehicleDetectedEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceDogDetectedEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceDogLickDetectedEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceDogPoopDetectedEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceRadarMotionDetectedEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceSensorOpenEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DevicePackageDeliveredEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DevicePackageStrandedEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DevicePackageTakenEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceSomeoneLoiteringEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceLockedEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceWrongTryProtectAlarmEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceLongTimeNotCloseEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceLowBatteryEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceJammedEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceAlarm911EventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceShakeAlarmEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceTamperingEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceLowTemperatureEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceHighTemperatureEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DevicePinIncorrectEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceLidStuckEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceBatteryFullyChargedEventPayload extends BaseDeviceEventPayloadWithSerial { state: boolean; } export interface DeviceUserAddedEventPayload extends BaseDeviceEventPayloadWithSerial { username: string; schedule?: Schedule; } export interface DeviceUserDeletedEventPayload extends BaseDeviceEventPayloadWithSerial { username: string; } export interface DeviceUserErrorEventPayload extends BaseDeviceEventPayloadWithSerial { username: string; error: string; } export interface DeviceUserUsernameUpdatedEventPayload extends BaseDeviceEventPayloadWithSerial { username: string; } export interface DeviceUserScheduleUpdatedEventPayload extends BaseDeviceEventPayloadWithSerial { username: string; schedule: Schedule; } export interface DeviceUserPasscodeUpdatedEventPayload extends BaseDeviceEventPayloadWithSerial { username: string; } export interface DevicePinVerifiedEventPayload extends BaseDeviceEventPayloadWithSerial { username: string; } export interface DeviceLivestreamStartedEventPayload extends BaseDeviceEventPayloadWithSerial { } export interface DeviceLivestreamStoppedEventPayload extends BaseDeviceEventPayloadWithSerial { } export interface DeviceLivestreamVideoDataEventPayload extends BaseDeviceEventPayloadWithSerial { buffer: JSONBuffer; metadata: VideoMetadata; } export interface DeviceLivestreamAudioDataEventPayload extends BaseDeviceEventPayloadWithSerial { buffer: JSONBuffer; metadata: AudioMetadata; } export interface DeviceGotRtspUrlEventPayload extends BaseDeviceEventPayloadWithSerial { rtspUrl: string; } export interface DeviceDownloadStartedEventPayload extends BaseDeviceEventPayloadWithSerial { } export interface DeviceDownloadFinishedEventPayload extends BaseDeviceEventPayloadWithSerial { } export interface DeviceDownloadVideoDataEventPayload extends BaseDeviceEventPayloadWithSerial { buffer: JSONValue; metadata: VideoMetadata; } export interface DeviceDownloadAudioDataEventPayload extends BaseDeviceEventPayloadWithSerial { buffer: JSONValue; metadata: AudioMetadata; } export interface DeviceCommandResultEventPayload extends BaseDeviceEventPayloadWithSerial { command: string; returnCode: number; returnCodeName: string; customData?: JSONValue; } export interface DeviceTalkbackStartedEventPayload extends BaseDeviceEventPayloadWithSerial { } export interface DeviceTalkbackStoppedEventPayload extends BaseDeviceEventPayloadWithSerial { } export type DeviceEventPayload = DeviceAddedEventPayload | DeviceRemovedEventPayload | DevicePropertyChangedEventPayload | DeviceMotionDetectedEventPayload | DevicePersonDetectedEventPayload | DeviceStrangerPersonDetectedEventPayload | DevicePetDetectedEventPayload | DeviceSoundDetectedEventPayload | DeviceCryingDetectedEventPayload | DeviceVehicleDetectedEventPayload | DeviceDogDetectedEventPayload | DeviceDogLickDetectedEventPayload | DeviceDogPoopDetectedEventPayload | DeviceRadarMotionDetectedEventPayload | DeviceRingsEventPayload | DeviceSensorOpenEventPayload | DevicePackageDeliveredEventPayload | DevicePackageStrandedEventPayload | DevicePackageTakenEventPayload | DeviceSomeoneLoiteringEventPayload | DeviceLockedEventPayload | DeviceWrongTryProtectAlarmEventPayload | DeviceLongTimeNotCloseEventPayload | DeviceLowBatteryEventPayload | DeviceJammedEventPayload | DeviceAlarm911EventPayload | DeviceShakeAlarmEventPayload | DeviceTamperingEventPayload | DeviceLowTemperatureEventPayload | DeviceHighTemperatureEventPayload | DevicePinIncorrectEventPayload | DeviceLidStuckEventPayload | DeviceBatteryFullyChargedEventPayload | DeviceUserAddedEventPayload | DeviceUserDeletedEventPayload | DeviceUserErrorEventPayload | DeviceUserUsernameUpdatedEventPayload | DeviceUserScheduleUpdatedEventPayload | DeviceUserPasscodeUpdatedEventPayload | DevicePinVerifiedEventPayload | DeviceLivestreamStartedEventPayload | DeviceLivestreamStoppedEventPayload | DeviceLivestreamVideoDataEventPayload | DeviceLivestreamAudioDataEventPayload | DeviceGotRtspUrlEventPayload | DeviceDownloadStartedEventPayload | DeviceDownloadFinishedEventPayload | DeviceDownloadVideoDataEventPayload | DeviceDownloadAudioDataEventPayload | DeviceCommandResultEventPayload | DeviceTalkbackStartedEventPayload | DeviceTalkbackStoppedEventPayload; export type DeviceEventPayloadByType = Extract; export type DeviceEventListener = (event: DeviceEventPayloadByType) => void; export type AnyDeviceEventListener = (event: DeviceEventPayload) => void; //# sourceMappingURL=events.d.ts.map