@ecobridge.xyz/devicemanager 3.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.gitea/workflows/default_nottags.yaml +66 -0
- package/.gitea/workflows/default_tags.yaml +124 -0
- package/.vscode/launch.json +11 -0
- package/.vscode/settings.json +26 -0
- package/changelog.md +91 -0
- package/dist_ts/00_commitinfo_data.d.ts +8 -0
- package/dist_ts/00_commitinfo_data.js +9 -0
- package/dist_ts/device/device.classes.device.d.ts +205 -0
- package/dist_ts/device/device.classes.device.js +344 -0
- package/dist_ts/devicemanager.classes.devicemanager.d.ts +210 -0
- package/dist_ts/devicemanager.classes.devicemanager.js +835 -0
- package/dist_ts/discovery/discovery.classes.homeassistant.d.ts +101 -0
- package/dist_ts/discovery/discovery.classes.homeassistant.js +313 -0
- package/dist_ts/discovery/discovery.classes.mdns.d.ts +90 -0
- package/dist_ts/discovery/discovery.classes.mdns.js +291 -0
- package/dist_ts/discovery/discovery.classes.networkscanner.d.ts +64 -0
- package/dist_ts/discovery/discovery.classes.networkscanner.js +535 -0
- package/dist_ts/discovery/discovery.classes.ssdp.d.ts +112 -0
- package/dist_ts/discovery/discovery.classes.ssdp.js +255 -0
- package/dist_ts/factories/index.d.ts +190 -0
- package/dist_ts/factories/index.js +350 -0
- package/dist_ts/features/feature.abstract.d.ts +118 -0
- package/dist_ts/features/feature.abstract.js +172 -0
- package/dist_ts/features/feature.camera.d.ts +95 -0
- package/dist_ts/features/feature.camera.js +162 -0
- package/dist_ts/features/feature.climate.d.ts +174 -0
- package/dist_ts/features/feature.climate.js +328 -0
- package/dist_ts/features/feature.cover.d.ts +121 -0
- package/dist_ts/features/feature.cover.js +217 -0
- package/dist_ts/features/feature.fan.d.ts +127 -0
- package/dist_ts/features/feature.fan.js +235 -0
- package/dist_ts/features/feature.light.d.ts +156 -0
- package/dist_ts/features/feature.light.js +296 -0
- package/dist_ts/features/feature.lock.d.ts +103 -0
- package/dist_ts/features/feature.lock.js +170 -0
- package/dist_ts/features/feature.playback.d.ts +98 -0
- package/dist_ts/features/feature.playback.js +191 -0
- package/dist_ts/features/feature.power.d.ts +79 -0
- package/dist_ts/features/feature.power.js +173 -0
- package/dist_ts/features/feature.print.d.ts +78 -0
- package/dist_ts/features/feature.print.js +226 -0
- package/dist_ts/features/feature.scan.d.ts +79 -0
- package/dist_ts/features/feature.scan.js +315 -0
- package/dist_ts/features/feature.sensor.d.ts +95 -0
- package/dist_ts/features/feature.sensor.js +147 -0
- package/dist_ts/features/feature.snmp.d.ts +88 -0
- package/dist_ts/features/feature.snmp.js +175 -0
- package/dist_ts/features/feature.switch.d.ts +75 -0
- package/dist_ts/features/feature.switch.js +126 -0
- package/dist_ts/features/feature.volume.d.ts +104 -0
- package/dist_ts/features/feature.volume.js +186 -0
- package/dist_ts/features/index.d.ts +19 -0
- package/dist_ts/features/index.js +23 -0
- package/dist_ts/helpers/helpers.iprange.d.ts +35 -0
- package/dist_ts/helpers/helpers.iprange.js +151 -0
- package/dist_ts/helpers/helpers.retry.d.ts +25 -0
- package/dist_ts/helpers/helpers.retry.js +69 -0
- package/dist_ts/index.d.ts +15 -0
- package/dist_ts/index.js +40 -0
- package/dist_ts/interfaces/feature.interfaces.d.ts +255 -0
- package/dist_ts/interfaces/feature.interfaces.js +6 -0
- package/dist_ts/interfaces/homeassistant.interfaces.d.ts +550 -0
- package/dist_ts/interfaces/homeassistant.interfaces.js +111 -0
- package/dist_ts/interfaces/index.d.ts +330 -0
- package/dist_ts/interfaces/index.js +16 -0
- package/dist_ts/interfaces/smarthome.interfaces.d.ts +282 -0
- package/dist_ts/interfaces/smarthome.interfaces.js +7 -0
- package/dist_ts/paths.d.ts +1 -0
- package/dist_ts/paths.js +3 -0
- package/dist_ts/plugins.d.ts +23 -0
- package/dist_ts/plugins.js +30 -0
- package/dist_ts/protocols/index.d.ts +12 -0
- package/dist_ts/protocols/index.js +21 -0
- package/dist_ts/protocols/protocol.escl.d.ts +58 -0
- package/dist_ts/protocols/protocol.escl.js +364 -0
- package/dist_ts/protocols/protocol.homeassistant.d.ts +248 -0
- package/dist_ts/protocols/protocol.homeassistant.js +611 -0
- package/dist_ts/protocols/protocol.ipp.d.ts +45 -0
- package/dist_ts/protocols/protocol.ipp.js +284 -0
- package/dist_ts/protocols/protocol.nut.d.ts +160 -0
- package/dist_ts/protocols/protocol.nut.js +364 -0
- package/dist_ts/protocols/protocol.sane.d.ts +104 -0
- package/dist_ts/protocols/protocol.sane.js +597 -0
- package/dist_ts/protocols/protocol.snmp.d.ts +133 -0
- package/dist_ts/protocols/protocol.snmp.js +333 -0
- package/dist_ts/protocols/protocol.upnp.d.ts +207 -0
- package/dist_ts/protocols/protocol.upnp.js +442 -0
- package/dist_ts/protocols/protocol.upssnmp.d.ts +160 -0
- package/dist_ts/protocols/protocol.upssnmp.js +263 -0
- package/npmextra.json +24 -0
- package/package.json +39 -0
- package/readme.hints.md +115 -0
- package/readme.md +624 -0
- package/test/test.ts +261 -0
- package/ts/00_commitinfo_data.ts +8 -0
- package/ts/device/device.classes.device.ts +454 -0
- package/ts/devicemanager.classes.devicemanager.ts +1219 -0
- package/ts/discovery/discovery.classes.homeassistant.ts +376 -0
- package/ts/discovery/discovery.classes.mdns.ts +347 -0
- package/ts/discovery/discovery.classes.networkscanner.ts +648 -0
- package/ts/discovery/discovery.classes.ssdp.ts +357 -0
- package/ts/factories/index.ts +696 -0
- package/ts/features/feature.abstract.ts +251 -0
- package/ts/features/feature.camera.ts +214 -0
- package/ts/features/feature.climate.ts +407 -0
- package/ts/features/feature.cover.ts +278 -0
- package/ts/features/feature.fan.ts +296 -0
- package/ts/features/feature.light.ts +369 -0
- package/ts/features/feature.lock.ts +223 -0
- package/ts/features/feature.playback.ts +246 -0
- package/ts/features/feature.power.ts +231 -0
- package/ts/features/feature.print.ts +297 -0
- package/ts/features/feature.scan.ts +370 -0
- package/ts/features/feature.sensor.ts +202 -0
- package/ts/features/feature.snmp.ts +235 -0
- package/ts/features/feature.switch.ts +170 -0
- package/ts/features/feature.volume.ts +256 -0
- package/ts/features/index.ts +25 -0
- package/ts/helpers/helpers.iprange.ts +172 -0
- package/ts/helpers/helpers.retry.ts +100 -0
- package/ts/index.ts +165 -0
- package/ts/interfaces/feature.interfaces.ts +359 -0
- package/ts/interfaces/homeassistant.interfaces.ts +666 -0
- package/ts/interfaces/index.ts +421 -0
- package/ts/interfaces/smarthome.interfaces.ts +421 -0
- package/ts/paths.ts +5 -0
- package/ts/plugins.ts +41 -0
- package/ts/protocols/index.ts +59 -0
- package/ts/protocols/protocol.escl.ts +439 -0
- package/ts/protocols/protocol.homeassistant.ts +737 -0
- package/ts/protocols/protocol.ipp.ts +329 -0
- package/ts/protocols/protocol.nut.ts +471 -0
- package/ts/protocols/protocol.sane.ts +694 -0
- package/ts/protocols/protocol.snmp.ts +439 -0
- package/ts/protocols/protocol.upnp.ts +627 -0
- package/ts/protocols/protocol.upssnmp.ts +377 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device Manager Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
export type TDeviceType = 'scanner' | 'printer' | 'snmp' | 'ups' | 'speaker' | 'dlna-renderer' | 'dlna-server';
|
|
5
|
+
export type TDeviceStatus = 'online' | 'offline' | 'busy' | 'error' | 'unknown';
|
|
6
|
+
export type TConnectionState = 'disconnected' | 'connecting' | 'connected' | 'error';
|
|
7
|
+
export type TScannerProtocol = 'sane' | 'escl';
|
|
8
|
+
export type TScanFormat = 'png' | 'jpeg' | 'pdf' | 'tiff';
|
|
9
|
+
export type TColorMode = 'color' | 'grayscale' | 'blackwhite';
|
|
10
|
+
export type TScanSource = 'flatbed' | 'adf' | 'adf-duplex';
|
|
11
|
+
export interface IDeviceInfo {
|
|
12
|
+
id: string;
|
|
13
|
+
name: string;
|
|
14
|
+
type: TDeviceType;
|
|
15
|
+
address: string;
|
|
16
|
+
port: number;
|
|
17
|
+
status: TDeviceStatus;
|
|
18
|
+
manufacturer?: string;
|
|
19
|
+
model?: string;
|
|
20
|
+
serialNumber?: string;
|
|
21
|
+
firmwareVersion?: string;
|
|
22
|
+
}
|
|
23
|
+
export interface IDeviceManagerOptions {
|
|
24
|
+
/** Enable auto-discovery on startup */
|
|
25
|
+
autoDiscovery?: boolean;
|
|
26
|
+
/** Discovery timeout in milliseconds */
|
|
27
|
+
discoveryTimeout?: number;
|
|
28
|
+
/** Enable retry with exponential backoff */
|
|
29
|
+
enableRetry?: boolean;
|
|
30
|
+
/** Maximum retry attempts */
|
|
31
|
+
maxRetries?: number;
|
|
32
|
+
/** Base delay for retry backoff in milliseconds */
|
|
33
|
+
retryBaseDelay?: number;
|
|
34
|
+
}
|
|
35
|
+
export interface IScannerInfo extends IDeviceInfo {
|
|
36
|
+
type: 'scanner';
|
|
37
|
+
protocol: TScannerProtocol;
|
|
38
|
+
supportedFormats: TScanFormat[];
|
|
39
|
+
supportedResolutions: number[];
|
|
40
|
+
supportedColorModes: TColorMode[];
|
|
41
|
+
supportedSources: TScanSource[];
|
|
42
|
+
hasAdf: boolean;
|
|
43
|
+
hasDuplex: boolean;
|
|
44
|
+
maxWidth?: number;
|
|
45
|
+
maxHeight?: number;
|
|
46
|
+
}
|
|
47
|
+
export interface IScanArea {
|
|
48
|
+
x: number;
|
|
49
|
+
y: number;
|
|
50
|
+
width: number;
|
|
51
|
+
height: number;
|
|
52
|
+
}
|
|
53
|
+
export interface IScanOptions {
|
|
54
|
+
/** Resolution in DPI (default: 300) */
|
|
55
|
+
resolution?: number;
|
|
56
|
+
/** Output format (default: 'png') */
|
|
57
|
+
format?: TScanFormat;
|
|
58
|
+
/** Color mode (default: 'color') */
|
|
59
|
+
colorMode?: TColorMode;
|
|
60
|
+
/** Scan source (default: 'flatbed') */
|
|
61
|
+
source?: TScanSource;
|
|
62
|
+
/** Scan area (default: full page) */
|
|
63
|
+
area?: IScanArea;
|
|
64
|
+
/** Document intent for optimization */
|
|
65
|
+
intent?: 'document' | 'photo' | 'preview';
|
|
66
|
+
/** Compression quality for JPEG (1-100) */
|
|
67
|
+
quality?: number;
|
|
68
|
+
}
|
|
69
|
+
export interface IScanResult {
|
|
70
|
+
/** Scanned image data */
|
|
71
|
+
data: Buffer;
|
|
72
|
+
/** Output format */
|
|
73
|
+
format: TScanFormat;
|
|
74
|
+
/** Image width in pixels */
|
|
75
|
+
width: number;
|
|
76
|
+
/** Image height in pixels */
|
|
77
|
+
height: number;
|
|
78
|
+
/** Scan resolution in DPI */
|
|
79
|
+
resolution: number;
|
|
80
|
+
/** Color mode used */
|
|
81
|
+
colorMode: TColorMode;
|
|
82
|
+
/** MIME type */
|
|
83
|
+
mimeType: string;
|
|
84
|
+
}
|
|
85
|
+
export interface IScannerCapabilities {
|
|
86
|
+
resolutions: number[];
|
|
87
|
+
formats: TScanFormat[];
|
|
88
|
+
colorModes: TColorMode[];
|
|
89
|
+
sources: TScanSource[];
|
|
90
|
+
maxWidth: number;
|
|
91
|
+
maxHeight: number;
|
|
92
|
+
minWidth: number;
|
|
93
|
+
minHeight: number;
|
|
94
|
+
}
|
|
95
|
+
export interface IPrinterInfo extends IDeviceInfo {
|
|
96
|
+
type: 'printer';
|
|
97
|
+
uri: string;
|
|
98
|
+
supportsColor: boolean;
|
|
99
|
+
supportsDuplex: boolean;
|
|
100
|
+
supportedMediaTypes: string[];
|
|
101
|
+
supportedMediaSizes: string[];
|
|
102
|
+
maxCopies: number;
|
|
103
|
+
}
|
|
104
|
+
export interface IPrintOptions {
|
|
105
|
+
/** Number of copies (default: 1) */
|
|
106
|
+
copies?: number;
|
|
107
|
+
/** Media size (e.g., 'iso_a4_210x297mm') */
|
|
108
|
+
mediaSize?: string;
|
|
109
|
+
/** Media type (e.g., 'stationery') */
|
|
110
|
+
mediaType?: string;
|
|
111
|
+
/** Print sides: 'one-sided', 'two-sided-long-edge', 'two-sided-short-edge' */
|
|
112
|
+
sides?: 'one-sided' | 'two-sided-long-edge' | 'two-sided-short-edge';
|
|
113
|
+
/** Print quality */
|
|
114
|
+
quality?: 'draft' | 'normal' | 'high';
|
|
115
|
+
/** Color mode */
|
|
116
|
+
colorMode?: 'color' | 'monochrome';
|
|
117
|
+
/** Job name */
|
|
118
|
+
jobName?: string;
|
|
119
|
+
}
|
|
120
|
+
export interface IPrintJob {
|
|
121
|
+
id: number;
|
|
122
|
+
name: string;
|
|
123
|
+
state: 'pending' | 'processing' | 'completed' | 'canceled' | 'aborted';
|
|
124
|
+
stateReason?: string;
|
|
125
|
+
createdAt: Date;
|
|
126
|
+
completedAt?: Date;
|
|
127
|
+
pagesPrinted?: number;
|
|
128
|
+
pagesTotal?: number;
|
|
129
|
+
}
|
|
130
|
+
export interface IPrinterCapabilities {
|
|
131
|
+
colorSupported: boolean;
|
|
132
|
+
duplexSupported: boolean;
|
|
133
|
+
mediaSizes: string[];
|
|
134
|
+
mediaTypes: string[];
|
|
135
|
+
resolutions: number[];
|
|
136
|
+
maxCopies: number;
|
|
137
|
+
sidesSupported: string[];
|
|
138
|
+
qualitySupported: string[];
|
|
139
|
+
}
|
|
140
|
+
export interface IDiscoveredDevice {
|
|
141
|
+
id: string;
|
|
142
|
+
name: string;
|
|
143
|
+
type: TDeviceType;
|
|
144
|
+
protocol: string;
|
|
145
|
+
address: string;
|
|
146
|
+
port: number;
|
|
147
|
+
txtRecords: Record<string, string>;
|
|
148
|
+
serviceType: string;
|
|
149
|
+
}
|
|
150
|
+
export interface IDiscoveryOptions {
|
|
151
|
+
/** Service types to discover */
|
|
152
|
+
serviceTypes?: string[];
|
|
153
|
+
/** Discovery timeout in ms */
|
|
154
|
+
timeout?: number;
|
|
155
|
+
}
|
|
156
|
+
export interface IRetryOptions {
|
|
157
|
+
/** Maximum number of retry attempts */
|
|
158
|
+
maxRetries?: number;
|
|
159
|
+
/** Base delay in milliseconds */
|
|
160
|
+
baseDelay?: number;
|
|
161
|
+
/** Maximum delay in milliseconds */
|
|
162
|
+
maxDelay?: number;
|
|
163
|
+
/** Delay multiplier for exponential backoff */
|
|
164
|
+
multiplier?: number;
|
|
165
|
+
/** Whether to add jitter to delays */
|
|
166
|
+
jitter?: boolean;
|
|
167
|
+
}
|
|
168
|
+
export type TDeviceManagerEvents = {
|
|
169
|
+
'scanner:found': (scanner: IScannerInfo) => void;
|
|
170
|
+
'scanner:lost': (scannerId: string) => void;
|
|
171
|
+
'printer:found': (printer: IPrinterInfo) => void;
|
|
172
|
+
'printer:lost': (printerId: string) => void;
|
|
173
|
+
'device:updated': (device: IDeviceInfo) => void;
|
|
174
|
+
'discovery:started': () => void;
|
|
175
|
+
'discovery:stopped': () => void;
|
|
176
|
+
'error': (error: Error) => void;
|
|
177
|
+
};
|
|
178
|
+
export interface IEsclCapabilities {
|
|
179
|
+
version: string;
|
|
180
|
+
makeAndModel: string;
|
|
181
|
+
serialNumber?: string;
|
|
182
|
+
uuid?: string;
|
|
183
|
+
adminUri?: string;
|
|
184
|
+
iconUri?: string;
|
|
185
|
+
platen?: IEsclInputSource;
|
|
186
|
+
adf?: IEsclInputSource;
|
|
187
|
+
adfDuplex?: IEsclInputSource;
|
|
188
|
+
}
|
|
189
|
+
export interface IEsclInputSource {
|
|
190
|
+
minWidth: number;
|
|
191
|
+
maxWidth: number;
|
|
192
|
+
minHeight: number;
|
|
193
|
+
maxHeight: number;
|
|
194
|
+
maxScanRegions: number;
|
|
195
|
+
supportedResolutions: number[];
|
|
196
|
+
colorModes: string[];
|
|
197
|
+
documentFormats: string[];
|
|
198
|
+
}
|
|
199
|
+
export interface IEsclScanStatus {
|
|
200
|
+
state: 'Idle' | 'Processing' | 'Stopped' | 'Testing';
|
|
201
|
+
adfState?: 'Empty' | 'Loaded' | 'Jammed' | 'Open' | 'Closed';
|
|
202
|
+
jobs?: IEsclJobInfo[];
|
|
203
|
+
}
|
|
204
|
+
export interface IEsclJobInfo {
|
|
205
|
+
jobUri: string;
|
|
206
|
+
jobUuid: string;
|
|
207
|
+
age: number;
|
|
208
|
+
imagesCompleted: number;
|
|
209
|
+
imagesToTransfer: number;
|
|
210
|
+
jobState: 'Pending' | 'Processing' | 'Completed' | 'Canceled' | 'Aborted';
|
|
211
|
+
jobStateReason?: string;
|
|
212
|
+
}
|
|
213
|
+
export interface ISaneDevice {
|
|
214
|
+
name: string;
|
|
215
|
+
vendor: string;
|
|
216
|
+
model: string;
|
|
217
|
+
type: string;
|
|
218
|
+
}
|
|
219
|
+
export interface ISaneOption {
|
|
220
|
+
name: string;
|
|
221
|
+
title: string;
|
|
222
|
+
description: string;
|
|
223
|
+
type: 'bool' | 'int' | 'fixed' | 'string' | 'button' | 'group';
|
|
224
|
+
unit: 'none' | 'pixel' | 'bit' | 'mm' | 'dpi' | 'percent' | 'microsecond';
|
|
225
|
+
size: number;
|
|
226
|
+
capabilities: number;
|
|
227
|
+
constraintType: 'none' | 'range' | 'word_list' | 'string_list';
|
|
228
|
+
constraint?: ISaneConstraint;
|
|
229
|
+
}
|
|
230
|
+
export interface ISaneConstraint {
|
|
231
|
+
range?: {
|
|
232
|
+
min: number;
|
|
233
|
+
max: number;
|
|
234
|
+
quant: number;
|
|
235
|
+
};
|
|
236
|
+
wordList?: number[];
|
|
237
|
+
stringList?: string[];
|
|
238
|
+
}
|
|
239
|
+
export interface ISaneParameters {
|
|
240
|
+
format: 'gray' | 'rgb' | 'red' | 'green' | 'blue';
|
|
241
|
+
lastFrame: boolean;
|
|
242
|
+
bytesPerLine: number;
|
|
243
|
+
pixelsPerLine: number;
|
|
244
|
+
lines: number;
|
|
245
|
+
depth: number;
|
|
246
|
+
}
|
|
247
|
+
export interface INetworkScanOptions {
|
|
248
|
+
/** CIDR notation (e.g., "192.168.1.0/24") */
|
|
249
|
+
ipRange?: string;
|
|
250
|
+
/** Start IP address for range scan */
|
|
251
|
+
startIp?: string;
|
|
252
|
+
/** End IP address for range scan */
|
|
253
|
+
endIp?: string;
|
|
254
|
+
/** Maximum concurrent probes (default: 50) */
|
|
255
|
+
concurrency?: number;
|
|
256
|
+
/** Timeout per probe in milliseconds (default: 2000) */
|
|
257
|
+
timeout?: number;
|
|
258
|
+
/** Ports to probe (default: [80, 443, 631, 6566, 9100, 7000, 1400, 8009]) */
|
|
259
|
+
ports?: number[];
|
|
260
|
+
/** Check for eSCL scanners (default: true) */
|
|
261
|
+
probeEscl?: boolean;
|
|
262
|
+
/** Check for IPP printers (default: true) */
|
|
263
|
+
probeIpp?: boolean;
|
|
264
|
+
/** Check for SANE scanners (default: true) */
|
|
265
|
+
probeSane?: boolean;
|
|
266
|
+
/** Check for AirPlay speakers (default: true) */
|
|
267
|
+
probeAirplay?: boolean;
|
|
268
|
+
/** Check for Sonos speakers (default: true) */
|
|
269
|
+
probeSonos?: boolean;
|
|
270
|
+
/** Check for Chromecast devices (default: true) */
|
|
271
|
+
probeChromecast?: boolean;
|
|
272
|
+
}
|
|
273
|
+
export interface INetworkScanDevice {
|
|
274
|
+
type: 'scanner' | 'printer' | 'speaker';
|
|
275
|
+
protocol: 'escl' | 'sane' | 'ipp' | 'jetdirect' | 'airplay' | 'sonos' | 'chromecast';
|
|
276
|
+
port: number;
|
|
277
|
+
name?: string;
|
|
278
|
+
model?: string;
|
|
279
|
+
}
|
|
280
|
+
export interface INetworkScanResult {
|
|
281
|
+
address: string;
|
|
282
|
+
devices: INetworkScanDevice[];
|
|
283
|
+
}
|
|
284
|
+
export interface INetworkScanProgress {
|
|
285
|
+
/** Total IPs to scan */
|
|
286
|
+
total: number;
|
|
287
|
+
/** IPs scanned so far */
|
|
288
|
+
scanned: number;
|
|
289
|
+
/** Percentage complete (0-100) */
|
|
290
|
+
percentage: number;
|
|
291
|
+
/** Current IP being scanned */
|
|
292
|
+
currentIp?: string;
|
|
293
|
+
/** Devices found so far */
|
|
294
|
+
devicesFound: number;
|
|
295
|
+
}
|
|
296
|
+
export type TNetworkScannerEvents = {
|
|
297
|
+
'progress': (progress: INetworkScanProgress) => void;
|
|
298
|
+
'device:found': (result: INetworkScanResult) => void;
|
|
299
|
+
'complete': (results: INetworkScanResult[]) => void;
|
|
300
|
+
'error': (error: Error) => void;
|
|
301
|
+
'cancelled': () => void;
|
|
302
|
+
};
|
|
303
|
+
import type { TFeatureType } from './feature.interfaces.js';
|
|
304
|
+
/**
|
|
305
|
+
* Criteria for selecting devices from the manager.
|
|
306
|
+
* Identity selectors (id, address) match exactly.
|
|
307
|
+
* Attribute selectors (name, model, manufacturer) match partially (case-insensitive).
|
|
308
|
+
* Capability selectors filter by feature availability.
|
|
309
|
+
*/
|
|
310
|
+
export interface IDeviceSelector {
|
|
311
|
+
/** Exact match on device ID */
|
|
312
|
+
id?: string;
|
|
313
|
+
/** Exact match on IP address */
|
|
314
|
+
address?: string;
|
|
315
|
+
/** Partial match on device name (case-insensitive) */
|
|
316
|
+
name?: string;
|
|
317
|
+
/** Partial match on device model (case-insensitive) */
|
|
318
|
+
model?: string;
|
|
319
|
+
/** Partial match on manufacturer name (case-insensitive) */
|
|
320
|
+
manufacturer?: string;
|
|
321
|
+
/** Device must have this feature */
|
|
322
|
+
hasFeature?: TFeatureType;
|
|
323
|
+
/** Device must have ALL of these features */
|
|
324
|
+
hasFeatures?: TFeatureType[];
|
|
325
|
+
/** Device must have ANY of these features */
|
|
326
|
+
hasAnyFeature?: TFeatureType[];
|
|
327
|
+
}
|
|
328
|
+
export * from './feature.interfaces.js';
|
|
329
|
+
export * from './smarthome.interfaces.js';
|
|
330
|
+
export * from './homeassistant.interfaces.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Device Manager Type Definitions
|
|
3
|
+
*/
|
|
4
|
+
// ============================================================================
|
|
5
|
+
// Feature Types (Universal Device Architecture)
|
|
6
|
+
// ============================================================================
|
|
7
|
+
export * from './feature.interfaces.js';
|
|
8
|
+
// ============================================================================
|
|
9
|
+
// Smart Home Types (Generic, Protocol-agnostic)
|
|
10
|
+
// ============================================================================
|
|
11
|
+
export * from './smarthome.interfaces.js';
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// Home Assistant Specific Types
|
|
14
|
+
// ============================================================================
|
|
15
|
+
export * from './homeassistant.interfaces.js';
|
|
16
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9pbnRlcmZhY2VzL2luZGV4LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBa1pILCtFQUErRTtBQUMvRSxnREFBZ0Q7QUFDaEQsK0VBQStFO0FBRS9FLGNBQWMseUJBQXlCLENBQUM7QUFFeEMsK0VBQStFO0FBQy9FLGdEQUFnRDtBQUNoRCwrRUFBK0U7QUFFL0UsY0FBYywyQkFBMkIsQ0FBQztBQUUxQywrRUFBK0U7QUFDL0UsZ0NBQWdDO0FBQ2hDLCtFQUErRTtBQUUvRSxjQUFjLCtCQUErQixDQUFDIn0=
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart Home Device Interfaces
|
|
3
|
+
* Generic types for smart home features (lights, climate, sensors, etc.)
|
|
4
|
+
* Protocol-agnostic - can be implemented by Home Assistant, Hue, MQTT, etc.
|
|
5
|
+
*/
|
|
6
|
+
import type { IFeatureInfo } from './feature.interfaces.js';
|
|
7
|
+
export type TLightProtocol = 'home-assistant' | 'hue' | 'mqtt' | 'zigbee';
|
|
8
|
+
export interface ILightCapabilities {
|
|
9
|
+
supportsBrightness: boolean;
|
|
10
|
+
supportsColorTemp: boolean;
|
|
11
|
+
supportsRgb: boolean;
|
|
12
|
+
supportsHs: boolean;
|
|
13
|
+
supportsXy: boolean;
|
|
14
|
+
supportsEffects: boolean;
|
|
15
|
+
supportsTransition: boolean;
|
|
16
|
+
effects?: string[];
|
|
17
|
+
minMireds?: number;
|
|
18
|
+
maxMireds?: number;
|
|
19
|
+
minColorTempKelvin?: number;
|
|
20
|
+
maxColorTempKelvin?: number;
|
|
21
|
+
}
|
|
22
|
+
export interface ILightState {
|
|
23
|
+
isOn: boolean;
|
|
24
|
+
brightness?: number;
|
|
25
|
+
colorTemp?: number;
|
|
26
|
+
colorTempMireds?: number;
|
|
27
|
+
rgbColor?: [number, number, number];
|
|
28
|
+
hsColor?: [number, number];
|
|
29
|
+
xyColor?: [number, number];
|
|
30
|
+
effect?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ILightFeatureInfo extends IFeatureInfo {
|
|
33
|
+
type: 'light';
|
|
34
|
+
protocol: TLightProtocol;
|
|
35
|
+
capabilities: ILightCapabilities;
|
|
36
|
+
currentState: ILightState;
|
|
37
|
+
}
|
|
38
|
+
export type TClimateProtocol = 'home-assistant' | 'nest' | 'ecobee' | 'mqtt';
|
|
39
|
+
export type THvacMode = 'off' | 'heat' | 'cool' | 'heat_cool' | 'auto' | 'dry' | 'fan_only';
|
|
40
|
+
export type THvacAction = 'off' | 'heating' | 'cooling' | 'drying' | 'idle' | 'fan';
|
|
41
|
+
export interface IClimateCapabilities {
|
|
42
|
+
hvacModes: THvacMode[];
|
|
43
|
+
presetModes?: string[];
|
|
44
|
+
fanModes?: string[];
|
|
45
|
+
swingModes?: string[];
|
|
46
|
+
supportsTargetTemp: boolean;
|
|
47
|
+
supportsTargetTempRange: boolean;
|
|
48
|
+
supportsHumidity: boolean;
|
|
49
|
+
supportsAuxHeat: boolean;
|
|
50
|
+
minTemp: number;
|
|
51
|
+
maxTemp: number;
|
|
52
|
+
tempStep: number;
|
|
53
|
+
minHumidity?: number;
|
|
54
|
+
maxHumidity?: number;
|
|
55
|
+
}
|
|
56
|
+
export interface IClimateState {
|
|
57
|
+
currentTemp?: number;
|
|
58
|
+
targetTemp?: number;
|
|
59
|
+
targetTempHigh?: number;
|
|
60
|
+
targetTempLow?: number;
|
|
61
|
+
hvacMode: THvacMode;
|
|
62
|
+
hvacAction?: THvacAction;
|
|
63
|
+
presetMode?: string;
|
|
64
|
+
fanMode?: string;
|
|
65
|
+
swingMode?: string;
|
|
66
|
+
humidity?: number;
|
|
67
|
+
targetHumidity?: number;
|
|
68
|
+
auxHeat?: boolean;
|
|
69
|
+
}
|
|
70
|
+
export interface IClimateFeatureInfo extends IFeatureInfo {
|
|
71
|
+
type: 'climate';
|
|
72
|
+
protocol: TClimateProtocol;
|
|
73
|
+
capabilities: IClimateCapabilities;
|
|
74
|
+
currentState: IClimateState;
|
|
75
|
+
}
|
|
76
|
+
export type TSensorProtocol = 'home-assistant' | 'mqtt' | 'snmp';
|
|
77
|
+
export type TSensorDeviceClass = 'temperature' | 'humidity' | 'pressure' | 'illuminance' | 'battery' | 'power' | 'energy' | 'voltage' | 'current' | 'frequency' | 'gas' | 'co2' | 'pm25' | 'pm10' | 'signal_strength' | 'timestamp' | 'duration' | 'distance' | 'speed' | 'weight' | 'monetary' | 'data_size' | 'data_rate' | 'water' | 'irradiance' | 'precipitation' | 'precipitation_intensity' | 'wind_speed';
|
|
78
|
+
export type TSensorStateClass = 'measurement' | 'total' | 'total_increasing';
|
|
79
|
+
export interface ISensorCapabilities {
|
|
80
|
+
deviceClass?: TSensorDeviceClass;
|
|
81
|
+
stateClass?: TSensorStateClass;
|
|
82
|
+
unit?: string;
|
|
83
|
+
nativeUnit?: string;
|
|
84
|
+
precision?: number;
|
|
85
|
+
}
|
|
86
|
+
export interface ISensorState {
|
|
87
|
+
value: string | number | boolean;
|
|
88
|
+
numericValue?: number;
|
|
89
|
+
unit?: string;
|
|
90
|
+
lastUpdated: Date;
|
|
91
|
+
}
|
|
92
|
+
export interface ISensorFeatureInfo extends IFeatureInfo {
|
|
93
|
+
type: 'sensor';
|
|
94
|
+
protocol: TSensorProtocol;
|
|
95
|
+
capabilities: ISensorCapabilities;
|
|
96
|
+
currentState: ISensorState;
|
|
97
|
+
}
|
|
98
|
+
export type TCameraProtocol = 'home-assistant' | 'onvif' | 'rtsp';
|
|
99
|
+
export interface ICameraCapabilities {
|
|
100
|
+
supportsStream: boolean;
|
|
101
|
+
supportsPtz: boolean;
|
|
102
|
+
supportsSnapshot: boolean;
|
|
103
|
+
supportsMotionDetection: boolean;
|
|
104
|
+
frontendStreamType?: 'hls' | 'web_rtc';
|
|
105
|
+
streamUrl?: string;
|
|
106
|
+
}
|
|
107
|
+
export interface ICameraState {
|
|
108
|
+
isRecording: boolean;
|
|
109
|
+
isStreaming: boolean;
|
|
110
|
+
motionDetected: boolean;
|
|
111
|
+
}
|
|
112
|
+
export interface ICameraFeatureInfo extends IFeatureInfo {
|
|
113
|
+
type: 'camera';
|
|
114
|
+
protocol: TCameraProtocol;
|
|
115
|
+
capabilities: ICameraCapabilities;
|
|
116
|
+
currentState: ICameraState;
|
|
117
|
+
}
|
|
118
|
+
export type TCoverProtocol = 'home-assistant' | 'mqtt' | 'somfy';
|
|
119
|
+
export type TCoverDeviceClass = 'awning' | 'blind' | 'curtain' | 'damper' | 'door' | 'garage' | 'gate' | 'shade' | 'shutter' | 'window';
|
|
120
|
+
export type TCoverState = 'open' | 'opening' | 'closed' | 'closing' | 'stopped' | 'unknown';
|
|
121
|
+
export interface ICoverCapabilities {
|
|
122
|
+
deviceClass?: TCoverDeviceClass;
|
|
123
|
+
supportsOpen: boolean;
|
|
124
|
+
supportsClose: boolean;
|
|
125
|
+
supportsStop: boolean;
|
|
126
|
+
supportsPosition: boolean;
|
|
127
|
+
supportsTilt: boolean;
|
|
128
|
+
}
|
|
129
|
+
export interface ICoverStateInfo {
|
|
130
|
+
state: TCoverState;
|
|
131
|
+
position?: number;
|
|
132
|
+
tiltPosition?: number;
|
|
133
|
+
}
|
|
134
|
+
export interface ICoverFeatureInfo extends IFeatureInfo {
|
|
135
|
+
type: 'cover';
|
|
136
|
+
protocol: TCoverProtocol;
|
|
137
|
+
capabilities: ICoverCapabilities;
|
|
138
|
+
currentState: ICoverStateInfo;
|
|
139
|
+
}
|
|
140
|
+
export type TSwitchProtocol = 'home-assistant' | 'mqtt' | 'tasmota' | 'tuya';
|
|
141
|
+
export type TSwitchDeviceClass = 'outlet' | 'switch';
|
|
142
|
+
export interface ISwitchCapabilities {
|
|
143
|
+
deviceClass?: TSwitchDeviceClass;
|
|
144
|
+
}
|
|
145
|
+
export interface ISwitchState {
|
|
146
|
+
isOn: boolean;
|
|
147
|
+
}
|
|
148
|
+
export interface ISwitchFeatureInfo extends IFeatureInfo {
|
|
149
|
+
type: 'switch';
|
|
150
|
+
protocol: TSwitchProtocol;
|
|
151
|
+
capabilities: ISwitchCapabilities;
|
|
152
|
+
currentState: ISwitchState;
|
|
153
|
+
}
|
|
154
|
+
export type TLockProtocol = 'home-assistant' | 'mqtt' | 'august' | 'yale';
|
|
155
|
+
export type TLockState = 'locked' | 'unlocked' | 'locking' | 'unlocking' | 'jammed' | 'unknown';
|
|
156
|
+
export interface ILockCapabilities {
|
|
157
|
+
supportsOpen: boolean;
|
|
158
|
+
}
|
|
159
|
+
export interface ILockStateInfo {
|
|
160
|
+
state: TLockState;
|
|
161
|
+
isLocked: boolean;
|
|
162
|
+
}
|
|
163
|
+
export interface ILockFeatureInfo extends IFeatureInfo {
|
|
164
|
+
type: 'lock';
|
|
165
|
+
protocol: TLockProtocol;
|
|
166
|
+
capabilities: ILockCapabilities;
|
|
167
|
+
currentState: ILockStateInfo;
|
|
168
|
+
}
|
|
169
|
+
export type TFanProtocol = 'home-assistant' | 'mqtt' | 'bond';
|
|
170
|
+
export type TFanDirection = 'forward' | 'reverse';
|
|
171
|
+
export interface IFanCapabilities {
|
|
172
|
+
supportsSpeed: boolean;
|
|
173
|
+
supportsOscillate: boolean;
|
|
174
|
+
supportsDirection: boolean;
|
|
175
|
+
supportsPresetModes: boolean;
|
|
176
|
+
presetModes?: string[];
|
|
177
|
+
speedCount?: number;
|
|
178
|
+
}
|
|
179
|
+
export interface IFanState {
|
|
180
|
+
isOn: boolean;
|
|
181
|
+
percentage?: number;
|
|
182
|
+
presetMode?: string;
|
|
183
|
+
oscillating?: boolean;
|
|
184
|
+
direction?: TFanDirection;
|
|
185
|
+
}
|
|
186
|
+
export interface IFanFeatureInfo extends IFeatureInfo {
|
|
187
|
+
type: 'fan';
|
|
188
|
+
protocol: TFanProtocol;
|
|
189
|
+
capabilities: IFanCapabilities;
|
|
190
|
+
currentState: IFanState;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Light protocol client interface
|
|
194
|
+
* Implemented by HomeAssistantProtocol, HueProtocol, etc.
|
|
195
|
+
*/
|
|
196
|
+
export interface ILightProtocolClient {
|
|
197
|
+
turnOn(entityId: string, options?: {
|
|
198
|
+
brightness?: number;
|
|
199
|
+
colorTemp?: number;
|
|
200
|
+
rgb?: [number, number, number];
|
|
201
|
+
transition?: number;
|
|
202
|
+
}): Promise<void>;
|
|
203
|
+
turnOff(entityId: string, options?: {
|
|
204
|
+
transition?: number;
|
|
205
|
+
}): Promise<void>;
|
|
206
|
+
toggle(entityId: string): Promise<void>;
|
|
207
|
+
setBrightness(entityId: string, brightness: number, transition?: number): Promise<void>;
|
|
208
|
+
setColorTemp(entityId: string, kelvin: number, transition?: number): Promise<void>;
|
|
209
|
+
setRgbColor(entityId: string, r: number, g: number, b: number, transition?: number): Promise<void>;
|
|
210
|
+
setEffect(entityId: string, effect: string): Promise<void>;
|
|
211
|
+
getState(entityId: string): Promise<ILightState>;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Climate protocol client interface
|
|
215
|
+
*/
|
|
216
|
+
export interface IClimateProtocolClient {
|
|
217
|
+
setHvacMode(entityId: string, mode: THvacMode): Promise<void>;
|
|
218
|
+
setTargetTemp(entityId: string, temp: number): Promise<void>;
|
|
219
|
+
setTargetTempRange(entityId: string, low: number, high: number): Promise<void>;
|
|
220
|
+
setPresetMode(entityId: string, preset: string): Promise<void>;
|
|
221
|
+
setFanMode(entityId: string, mode: string): Promise<void>;
|
|
222
|
+
setSwingMode(entityId: string, mode: string): Promise<void>;
|
|
223
|
+
setAuxHeat(entityId: string, enabled: boolean): Promise<void>;
|
|
224
|
+
getState(entityId: string): Promise<IClimateState>;
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Sensor protocol client interface (read-only)
|
|
228
|
+
*/
|
|
229
|
+
export interface ISensorProtocolClient {
|
|
230
|
+
getState(entityId: string): Promise<ISensorState>;
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Camera protocol client interface
|
|
234
|
+
*/
|
|
235
|
+
export interface ICameraProtocolClient {
|
|
236
|
+
getSnapshot(entityId: string): Promise<Buffer>;
|
|
237
|
+
getSnapshotUrl(entityId: string): Promise<string>;
|
|
238
|
+
getStreamUrl(entityId: string): Promise<string>;
|
|
239
|
+
getState(entityId: string): Promise<ICameraState>;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Cover protocol client interface
|
|
243
|
+
*/
|
|
244
|
+
export interface ICoverProtocolClient {
|
|
245
|
+
open(entityId: string): Promise<void>;
|
|
246
|
+
close(entityId: string): Promise<void>;
|
|
247
|
+
stop(entityId: string): Promise<void>;
|
|
248
|
+
setPosition(entityId: string, position: number): Promise<void>;
|
|
249
|
+
setTiltPosition(entityId: string, position: number): Promise<void>;
|
|
250
|
+
getState(entityId: string): Promise<ICoverStateInfo>;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Switch protocol client interface
|
|
254
|
+
*/
|
|
255
|
+
export interface ISwitchProtocolClient {
|
|
256
|
+
turnOn(entityId: string): Promise<void>;
|
|
257
|
+
turnOff(entityId: string): Promise<void>;
|
|
258
|
+
toggle(entityId: string): Promise<void>;
|
|
259
|
+
getState(entityId: string): Promise<ISwitchState>;
|
|
260
|
+
}
|
|
261
|
+
/**
|
|
262
|
+
* Lock protocol client interface
|
|
263
|
+
*/
|
|
264
|
+
export interface ILockProtocolClient {
|
|
265
|
+
lock(entityId: string): Promise<void>;
|
|
266
|
+
unlock(entityId: string): Promise<void>;
|
|
267
|
+
open(entityId: string): Promise<void>;
|
|
268
|
+
getState(entityId: string): Promise<ILockStateInfo>;
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Fan protocol client interface
|
|
272
|
+
*/
|
|
273
|
+
export interface IFanProtocolClient {
|
|
274
|
+
turnOn(entityId: string, percentage?: number): Promise<void>;
|
|
275
|
+
turnOff(entityId: string): Promise<void>;
|
|
276
|
+
toggle(entityId: string): Promise<void>;
|
|
277
|
+
setPercentage(entityId: string, percentage: number): Promise<void>;
|
|
278
|
+
setPresetMode(entityId: string, mode: string): Promise<void>;
|
|
279
|
+
setOscillating(entityId: string, oscillating: boolean): Promise<void>;
|
|
280
|
+
setDirection(entityId: string, direction: TFanDirection): Promise<void>;
|
|
281
|
+
getState(entityId: string): Promise<IFanState>;
|
|
282
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Smart Home Device Interfaces
|
|
3
|
+
* Generic types for smart home features (lights, climate, sensors, etc.)
|
|
4
|
+
* Protocol-agnostic - can be implemented by Home Assistant, Hue, MQTT, etc.
|
|
5
|
+
*/
|
|
6
|
+
export {};
|
|
7
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRob21lLmludGVyZmFjZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9pbnRlcmZhY2VzL3NtYXJ0aG9tZS5pbnRlcmZhY2VzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7O0dBSUcifQ==
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const packageDir: string;
|
package/dist_ts/paths.js
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import * as plugins from './plugins.js';
|
|
2
|
+
export const packageDir = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
|
|
3
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicGF0aHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9wYXRocy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssT0FBTyxNQUFNLGNBQWMsQ0FBQztBQUN4QyxNQUFNLENBQUMsTUFBTSxVQUFVLEdBQUcsT0FBTyxDQUFDLElBQUksQ0FBQyxJQUFJLENBQ3pDLE9BQU8sQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLHdCQUF3QixDQUFDLE1BQU0sQ0FBQyxJQUFJLENBQUMsR0FBRyxDQUFDLEVBQy9ELEtBQUssQ0FDTixDQUFDIn0=
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as path from 'path';
|
|
2
|
+
import * as net from 'net';
|
|
3
|
+
import * as dgram from 'dgram';
|
|
4
|
+
import * as events from 'events';
|
|
5
|
+
export { path, net, dgram, events };
|
|
6
|
+
import * as smartpath from '@push.rocks/smartpath';
|
|
7
|
+
import * as smartpromise from '@push.rocks/smartpromise';
|
|
8
|
+
import * as smartdelay from '@push.rocks/smartdelay';
|
|
9
|
+
import * as smartnetwork from '@push.rocks/smartnetwork';
|
|
10
|
+
import { SmartRequest } from '@push.rocks/smartrequest';
|
|
11
|
+
export { SmartRequest };
|
|
12
|
+
export { smartpath, smartpromise, smartdelay, smartnetwork, };
|
|
13
|
+
import * as bonjourService from 'bonjour-service';
|
|
14
|
+
import ipp from 'ipp';
|
|
15
|
+
import * as netSnmp from 'net-snmp';
|
|
16
|
+
import * as sonos from 'sonos';
|
|
17
|
+
import * as castv2Client from 'castv2-client';
|
|
18
|
+
import WebSocket from 'ws';
|
|
19
|
+
declare const nodeSsdp: {
|
|
20
|
+
Client: any;
|
|
21
|
+
Server: any;
|
|
22
|
+
};
|
|
23
|
+
export { bonjourService, ipp, nodeSsdp, netSnmp, sonos, castv2Client, WebSocket };
|