feat(unifi): implement comprehensive UniFi API client with controllers, protect, access, account, managers, resources, HTTP client, interfaces, logging, plugins, and tests
This commit is contained in:
564
ts/interfaces/protect.ts
Normal file
564
ts/interfaces/protect.ts
Normal file
@@ -0,0 +1,564 @@
|
||||
/**
|
||||
* Protect API interfaces
|
||||
* Base URL: https://{host}/proxy/protect/api
|
||||
*/
|
||||
|
||||
/**
|
||||
* Protect bootstrap response containing system configuration
|
||||
*/
|
||||
export interface IProtectBootstrap {
|
||||
/** Auth user info */
|
||||
authUser?: IProtectUser;
|
||||
/** Access key */
|
||||
accessKey?: string;
|
||||
/** Cameras list */
|
||||
cameras: IProtectCamera[];
|
||||
/** Users list */
|
||||
users?: IProtectUser[];
|
||||
/** Groups list */
|
||||
groups?: IProtectGroup[];
|
||||
/** Liveviews */
|
||||
liveviews?: IProtectLiveview[];
|
||||
/** Viewers */
|
||||
viewers?: IProtectViewer[];
|
||||
/** Lights */
|
||||
lights?: IProtectLight[];
|
||||
/** Bridges */
|
||||
bridges?: IProtectBridge[];
|
||||
/** Sensors */
|
||||
sensors?: IProtectSensor[];
|
||||
/** Doorbells */
|
||||
doorbells?: IProtectDoorbell[];
|
||||
/** Chimes */
|
||||
chimes?: IProtectChime[];
|
||||
/** NVR info */
|
||||
nvr: IProtectNvr;
|
||||
/** Last update ID */
|
||||
lastUpdateId?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect camera
|
||||
*/
|
||||
export interface IProtectCamera {
|
||||
/** Camera ID */
|
||||
id: string;
|
||||
/** MAC address */
|
||||
mac: string;
|
||||
/** Host address */
|
||||
host: string;
|
||||
/** Camera name */
|
||||
name: string;
|
||||
/** Camera type/model */
|
||||
type: string;
|
||||
/** Model key */
|
||||
modelKey?: string;
|
||||
/** Camera state */
|
||||
state: 'CONNECTED' | 'DISCONNECTED' | 'CONNECTING' | 'ADOPTING' | 'MANAGED';
|
||||
/** Hardware revision */
|
||||
hardwareRevision?: string;
|
||||
/** Firmware version */
|
||||
firmwareVersion?: string;
|
||||
/** Firmware build */
|
||||
firmwareBuild?: string;
|
||||
/** Whether camera is updating */
|
||||
isUpdating?: boolean;
|
||||
/** Whether camera is adopting */
|
||||
isAdopting?: boolean;
|
||||
/** Whether camera is managed */
|
||||
isManaged?: boolean;
|
||||
/** Whether camera is connected */
|
||||
isConnected?: boolean;
|
||||
/** Whether recording is enabled */
|
||||
isRecording?: boolean;
|
||||
/** Whether motion detection is enabled */
|
||||
isMotionDetected?: boolean;
|
||||
/** Whether camera is dark (IR mode) */
|
||||
isDark?: boolean;
|
||||
/** Recording settings */
|
||||
recordingSettings?: IProtectRecordingSettings;
|
||||
/** Smart detect settings */
|
||||
smartDetectSettings?: IProtectSmartDetectSettings;
|
||||
/** ISP settings (image settings) */
|
||||
ispSettings?: IProtectIspSettings;
|
||||
/** Microphone settings */
|
||||
micVolume?: number;
|
||||
/** Speaker settings */
|
||||
speakerVolume?: number;
|
||||
/** Last motion timestamp */
|
||||
lastMotion?: number;
|
||||
/** Last ring timestamp (for doorbells) */
|
||||
lastRing?: number;
|
||||
/** Uptime */
|
||||
uptime?: number;
|
||||
/** Connected since */
|
||||
connectedSince?: number;
|
||||
/** Up since */
|
||||
upSince?: number;
|
||||
/** Last seen */
|
||||
lastSeen?: number;
|
||||
/** Channels info */
|
||||
channels?: IProtectCameraChannel[];
|
||||
/** Feature flags */
|
||||
featureFlags?: IProtectFeatureFlags;
|
||||
/** Stats */
|
||||
stats?: IProtectCameraStats;
|
||||
}
|
||||
|
||||
/**
|
||||
* Camera channel configuration
|
||||
*/
|
||||
export interface IProtectCameraChannel {
|
||||
/** Channel ID */
|
||||
id: number;
|
||||
/** Video mode */
|
||||
videoMode?: string;
|
||||
/** Enabled */
|
||||
enabled: boolean;
|
||||
/** FPS mode */
|
||||
fpsValues?: number[];
|
||||
/** Is RTSP enabled */
|
||||
isRtspEnabled?: boolean;
|
||||
/** RTSP alias */
|
||||
rtspAlias?: string;
|
||||
/** Width */
|
||||
width?: number;
|
||||
/** Height */
|
||||
height?: number;
|
||||
/** FPS */
|
||||
fps?: number;
|
||||
/** Bitrate */
|
||||
bitrate?: number;
|
||||
/** Min bitrate */
|
||||
minBitrate?: number;
|
||||
/** Max bitrate */
|
||||
maxBitrate?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Recording settings
|
||||
*/
|
||||
export interface IProtectRecordingSettings {
|
||||
/** Pre-padding seconds */
|
||||
prePaddingSecs?: number;
|
||||
/** Post-padding seconds */
|
||||
postPaddingSecs?: number;
|
||||
/** Min motion event trigger */
|
||||
minMotionEventTrigger?: number;
|
||||
/** End motion event delay */
|
||||
endMotionEventDelay?: number;
|
||||
/** Suppress illumination surge */
|
||||
suppressIlluminationSurge?: boolean;
|
||||
/** Mode */
|
||||
mode?: 'always' | 'detections' | 'never' | 'schedule';
|
||||
/** Enable PIR timelapse */
|
||||
enablePirTimelapse?: boolean;
|
||||
/** Use new motion algorithm */
|
||||
useNewMotionAlgorithm?: boolean;
|
||||
/** In schedule mode */
|
||||
inScheduleMode?: string;
|
||||
/** Out schedule mode */
|
||||
outScheduleMode?: string;
|
||||
/** Geofencing */
|
||||
geofencing?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Smart detect settings
|
||||
*/
|
||||
export interface IProtectSmartDetectSettings {
|
||||
/** Object types to detect */
|
||||
objectTypes?: string[];
|
||||
/** Audio types to detect */
|
||||
audioTypes?: string[];
|
||||
/** Auto tracking object types */
|
||||
autoTrackingObjectTypes?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* ISP (Image Signal Processor) settings
|
||||
*/
|
||||
export interface IProtectIspSettings {
|
||||
/** AE mode */
|
||||
aeMode?: string;
|
||||
/** IR LED mode */
|
||||
irLedMode?: string;
|
||||
/** IR LED level */
|
||||
irLedLevel?: number;
|
||||
/** WDR */
|
||||
wdr?: number;
|
||||
/** ICR sensitivity */
|
||||
icrSensitivity?: number;
|
||||
/** Brightness */
|
||||
brightness?: number;
|
||||
/** Contrast */
|
||||
contrast?: number;
|
||||
/** Hue */
|
||||
hue?: number;
|
||||
/** Saturation */
|
||||
saturation?: number;
|
||||
/** Sharpness */
|
||||
sharpness?: number;
|
||||
/** Denoise */
|
||||
denoise?: number;
|
||||
/** Is flip enabled */
|
||||
isFlippedVertical?: boolean;
|
||||
/** Is mirror enabled */
|
||||
isFlippedHorizontal?: boolean;
|
||||
/** Is auto rotate enabled */
|
||||
isAutoRotateEnabled?: boolean;
|
||||
/** HDR mode */
|
||||
hdrMode?: string;
|
||||
/** Is color night vision enabled */
|
||||
isColorNightVisionEnabled?: boolean;
|
||||
/** Spotlight duration */
|
||||
spotlightDuration?: number;
|
||||
/** Focus mode */
|
||||
focusMode?: string;
|
||||
/** Focus position */
|
||||
focusPosition?: number;
|
||||
/** Zoom position */
|
||||
zoomPosition?: number;
|
||||
/** Touch focus X */
|
||||
touchFocusX?: number;
|
||||
/** Touch focus Y */
|
||||
touchFocusY?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Camera feature flags
|
||||
*/
|
||||
export interface IProtectFeatureFlags {
|
||||
/** Can adjust IR LED level */
|
||||
canAdjustIrLedLevel?: boolean;
|
||||
/** Has chime */
|
||||
hasChime?: boolean;
|
||||
/** Has flash */
|
||||
hasFlash?: boolean;
|
||||
/** Has HDR */
|
||||
hasHdr?: boolean;
|
||||
/** Has IR LED */
|
||||
hasIrLed?: boolean;
|
||||
/** Has LCD screen */
|
||||
hasLcdScreen?: boolean;
|
||||
/** Has LED status */
|
||||
hasLedStatus?: boolean;
|
||||
/** Has line in */
|
||||
hasLineIn?: boolean;
|
||||
/** Has mic */
|
||||
hasMic?: boolean;
|
||||
/** Has privacy mask */
|
||||
hasPrivacyMask?: boolean;
|
||||
/** Has RTSP */
|
||||
hasRtsp?: boolean;
|
||||
/** Has SD card */
|
||||
hasSdCard?: boolean;
|
||||
/** Has smart detect */
|
||||
hasSmartDetect?: boolean;
|
||||
/** Has speaker */
|
||||
hasSpeaker?: boolean;
|
||||
/** Has WiFi */
|
||||
hasWifi?: boolean;
|
||||
/** Video modes */
|
||||
videoModes?: string[];
|
||||
/** Privacy mask capability */
|
||||
privacyMaskCapability?: {
|
||||
maxMasks?: number;
|
||||
rectangleOnly?: boolean;
|
||||
};
|
||||
/** Smart detect types */
|
||||
smartDetectTypes?: string[];
|
||||
/** Smart detect audio types */
|
||||
smartDetectAudioTypes?: string[];
|
||||
/** Motion algorithms */
|
||||
motionAlgorithms?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Camera stats
|
||||
*/
|
||||
export interface IProtectCameraStats {
|
||||
/** RX bytes */
|
||||
rxBytes?: number;
|
||||
/** TX bytes */
|
||||
txBytes?: number;
|
||||
/** WiFi quality */
|
||||
wifiQuality?: number;
|
||||
/** WiFi strength */
|
||||
wifiStrength?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect user
|
||||
*/
|
||||
export interface IProtectUser {
|
||||
/** User ID */
|
||||
id: string;
|
||||
/** Is owner */
|
||||
isOwner?: boolean;
|
||||
/** Name */
|
||||
name?: string;
|
||||
/** Email */
|
||||
email?: string;
|
||||
/** Local username */
|
||||
localUsername?: string;
|
||||
/** Has accepted invite */
|
||||
hasAcceptedInvite?: boolean;
|
||||
/** All permissions */
|
||||
allPermissions?: string[];
|
||||
/** Model key */
|
||||
modelKey?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect group
|
||||
*/
|
||||
export interface IProtectGroup {
|
||||
/** Group ID */
|
||||
id: string;
|
||||
/** Group name */
|
||||
name: string;
|
||||
/** Group type */
|
||||
type?: string;
|
||||
/** Model key */
|
||||
modelKey?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect liveview
|
||||
*/
|
||||
export interface IProtectLiveview {
|
||||
/** Liveview ID */
|
||||
id: string;
|
||||
/** Name */
|
||||
name: string;
|
||||
/** Is default */
|
||||
isDefault?: boolean;
|
||||
/** Layout */
|
||||
layout?: number;
|
||||
/** Model key */
|
||||
modelKey?: string;
|
||||
/** Slots */
|
||||
slots?: IProtectLiveviewSlot[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect liveview slot
|
||||
*/
|
||||
export interface IProtectLiveviewSlot {
|
||||
/** Camera IDs */
|
||||
cameras?: string[];
|
||||
/** Cycle mode */
|
||||
cycleMode?: string;
|
||||
/** Cycle interval */
|
||||
cycleInterval?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect viewer
|
||||
*/
|
||||
export interface IProtectViewer {
|
||||
/** Viewer ID */
|
||||
id: string;
|
||||
/** Name */
|
||||
name?: string;
|
||||
/** Model key */
|
||||
modelKey?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect light
|
||||
*/
|
||||
export interface IProtectLight {
|
||||
/** Light ID */
|
||||
id: string;
|
||||
/** MAC */
|
||||
mac: string;
|
||||
/** Name */
|
||||
name: string;
|
||||
/** Type */
|
||||
type: string;
|
||||
/** State */
|
||||
state: string;
|
||||
/** Is light on */
|
||||
isLightOn?: boolean;
|
||||
/** Light device settings */
|
||||
lightDeviceSettings?: {
|
||||
ledLevel?: number;
|
||||
luxSensitivity?: string;
|
||||
pirDuration?: number;
|
||||
pirSensitivity?: number;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect bridge
|
||||
*/
|
||||
export interface IProtectBridge {
|
||||
/** Bridge ID */
|
||||
id: string;
|
||||
/** MAC */
|
||||
mac: string;
|
||||
/** Name */
|
||||
name: string;
|
||||
/** Type */
|
||||
type: string;
|
||||
/** State */
|
||||
state: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect sensor
|
||||
*/
|
||||
export interface IProtectSensor {
|
||||
/** Sensor ID */
|
||||
id: string;
|
||||
/** MAC */
|
||||
mac: string;
|
||||
/** Name */
|
||||
name: string;
|
||||
/** Type */
|
||||
type: string;
|
||||
/** State */
|
||||
state: string;
|
||||
/** Battery status */
|
||||
batteryStatus?: {
|
||||
percentage?: number;
|
||||
isLow?: boolean;
|
||||
};
|
||||
/** Mount type */
|
||||
mountType?: string;
|
||||
/** Is motion detected */
|
||||
isMotionDetected?: boolean;
|
||||
/** Is opened */
|
||||
isOpened?: boolean;
|
||||
/** Humidity */
|
||||
humidity?: number;
|
||||
/** Temperature */
|
||||
temperature?: number;
|
||||
/** Light */
|
||||
light?: number;
|
||||
/** Alarm triggered type */
|
||||
alarmTriggeredType?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect doorbell (extends camera)
|
||||
*/
|
||||
export interface IProtectDoorbell extends IProtectCamera {
|
||||
/** LCD message */
|
||||
lcdMessage?: {
|
||||
text?: string;
|
||||
resetAt?: number;
|
||||
type?: string;
|
||||
};
|
||||
/** Chime duration */
|
||||
chimeDuration?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect chime
|
||||
*/
|
||||
export interface IProtectChime {
|
||||
/** Chime ID */
|
||||
id: string;
|
||||
/** MAC */
|
||||
mac: string;
|
||||
/** Name */
|
||||
name: string;
|
||||
/** Type */
|
||||
type: string;
|
||||
/** State */
|
||||
state: string;
|
||||
/** Is paired with doorbell */
|
||||
isPaired?: boolean;
|
||||
/** Volume */
|
||||
volume?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Protect NVR info
|
||||
*/
|
||||
export interface IProtectNvr {
|
||||
/** NVR ID */
|
||||
id: string;
|
||||
/** MAC */
|
||||
mac: string;
|
||||
/** Host */
|
||||
host: string;
|
||||
/** Name */
|
||||
name: string;
|
||||
/** Type */
|
||||
type: string;
|
||||
/** Is connected to cloud */
|
||||
isConnectedToCloud?: boolean;
|
||||
/** Firmware version */
|
||||
firmwareVersion?: string;
|
||||
/** Hardware */
|
||||
hardware?: {
|
||||
shortname?: string;
|
||||
name?: string;
|
||||
};
|
||||
/** Uptime */
|
||||
uptime?: number;
|
||||
/** Last seen */
|
||||
lastSeen?: number;
|
||||
/** Is recording disabled */
|
||||
isRecordingDisabled?: boolean;
|
||||
/** Is recording motion only */
|
||||
isRecordingMotionOnly?: boolean;
|
||||
/** Storage info */
|
||||
storageInfo?: {
|
||||
totalSize?: number;
|
||||
totalSpaceUsed?: number;
|
||||
devices?: Array<{
|
||||
model?: string;
|
||||
size?: number;
|
||||
healthy?: boolean;
|
||||
}>;
|
||||
};
|
||||
/** Timezone */
|
||||
timezone?: string;
|
||||
/** Version */
|
||||
version?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Auth response from Protect
|
||||
*/
|
||||
export interface IProtectAuthResponse {
|
||||
/** CSRF token in response */
|
||||
csrfToken?: string;
|
||||
/** User info */
|
||||
user?: IProtectUser;
|
||||
}
|
||||
|
||||
/**
|
||||
* Motion event from Protect
|
||||
*/
|
||||
export interface IProtectMotionEvent {
|
||||
/** Event ID */
|
||||
id: string;
|
||||
/** Event type */
|
||||
type: 'motion' | 'ring' | 'smartDetectZone' | 'smartAudioDetect';
|
||||
/** Start timestamp */
|
||||
start: number;
|
||||
/** End timestamp */
|
||||
end?: number;
|
||||
/** Score (confidence) */
|
||||
score?: number;
|
||||
/** Smart detect types */
|
||||
smartDetectTypes?: string[];
|
||||
/** Smart detect events */
|
||||
smartDetectEvents?: string[];
|
||||
/** Camera ID */
|
||||
camera?: string;
|
||||
/** Partition (for storage) */
|
||||
partition?: string;
|
||||
/** Model key */
|
||||
modelKey?: string;
|
||||
/** Thumbnail ID */
|
||||
thumbnail?: string;
|
||||
/** Has heatmap */
|
||||
heatmap?: string;
|
||||
}
|
||||
Reference in New Issue
Block a user