@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,550 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Home Assistant Specific Interfaces
|
|
3
|
+
* Types for Home Assistant WebSocket API, entities, and configuration
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Configuration for connecting to a Home Assistant instance
|
|
7
|
+
*/
|
|
8
|
+
export interface IHomeAssistantInstanceConfig {
|
|
9
|
+
/** Home Assistant host (IP or hostname) */
|
|
10
|
+
host: string;
|
|
11
|
+
/** Port number (default: 8123) */
|
|
12
|
+
port?: number;
|
|
13
|
+
/** Long-lived access token from HA */
|
|
14
|
+
token: string;
|
|
15
|
+
/** Use secure WebSocket (wss://) */
|
|
16
|
+
secure?: boolean;
|
|
17
|
+
/** Friendly name for this instance */
|
|
18
|
+
friendlyName?: string;
|
|
19
|
+
/** Auto-reconnect on disconnect (default: true) */
|
|
20
|
+
autoReconnect?: boolean;
|
|
21
|
+
/** Reconnect delay in ms (default: 5000) */
|
|
22
|
+
reconnectDelay?: number;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Home Assistant configuration in DeviceManager options
|
|
26
|
+
*/
|
|
27
|
+
export interface IHomeAssistantOptions {
|
|
28
|
+
/** Enable mDNS auto-discovery of HA instances */
|
|
29
|
+
autoDiscovery?: boolean;
|
|
30
|
+
/** Manually configured HA instances */
|
|
31
|
+
instances?: IHomeAssistantInstanceConfig[];
|
|
32
|
+
/** Filter: only discover these domains (default: all) */
|
|
33
|
+
enabledDomains?: THomeAssistantDomain[];
|
|
34
|
+
/** Auto-reconnect on disconnect (default: true) */
|
|
35
|
+
autoReconnect?: boolean;
|
|
36
|
+
/** Reconnect delay in ms (default: 5000) */
|
|
37
|
+
reconnectDelay?: number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Supported Home Assistant domains that map to features
|
|
41
|
+
*/
|
|
42
|
+
export type THomeAssistantDomain = 'light' | 'switch' | 'sensor' | 'binary_sensor' | 'climate' | 'fan' | 'cover' | 'lock' | 'camera' | 'media_player';
|
|
43
|
+
/**
|
|
44
|
+
* Home Assistant entity state
|
|
45
|
+
*/
|
|
46
|
+
export interface IHomeAssistantEntity {
|
|
47
|
+
/** Entity ID (e.g., "light.living_room") */
|
|
48
|
+
entity_id: string;
|
|
49
|
+
/** Current state value (e.g., "on", "off", "25.5") */
|
|
50
|
+
state: string;
|
|
51
|
+
/** Additional attributes */
|
|
52
|
+
attributes: IHomeAssistantEntityAttributes;
|
|
53
|
+
/** Last changed timestamp */
|
|
54
|
+
last_changed: string;
|
|
55
|
+
/** Last updated timestamp */
|
|
56
|
+
last_updated: string;
|
|
57
|
+
/** Context information */
|
|
58
|
+
context: IHomeAssistantContext;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Common entity attributes
|
|
62
|
+
*/
|
|
63
|
+
export interface IHomeAssistantEntityAttributes {
|
|
64
|
+
/** Friendly name */
|
|
65
|
+
friendly_name?: string;
|
|
66
|
+
/** Device class */
|
|
67
|
+
device_class?: string;
|
|
68
|
+
/** Unit of measurement */
|
|
69
|
+
unit_of_measurement?: string;
|
|
70
|
+
/** Icon */
|
|
71
|
+
icon?: string;
|
|
72
|
+
/** Entity category */
|
|
73
|
+
entity_category?: string;
|
|
74
|
+
/** Assumed state (for optimistic updates) */
|
|
75
|
+
assumed_state?: boolean;
|
|
76
|
+
/** Supported features bitmask */
|
|
77
|
+
supported_features?: number;
|
|
78
|
+
/** Additional dynamic attributes */
|
|
79
|
+
[key: string]: unknown;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Light-specific attributes
|
|
83
|
+
*/
|
|
84
|
+
export interface IHomeAssistantLightAttributes extends IHomeAssistantEntityAttributes {
|
|
85
|
+
brightness?: number;
|
|
86
|
+
color_temp?: number;
|
|
87
|
+
color_temp_kelvin?: number;
|
|
88
|
+
hs_color?: [number, number];
|
|
89
|
+
rgb_color?: [number, number, number];
|
|
90
|
+
xy_color?: [number, number];
|
|
91
|
+
rgbw_color?: [number, number, number, number];
|
|
92
|
+
rgbww_color?: [number, number, number, number, number];
|
|
93
|
+
effect?: string;
|
|
94
|
+
effect_list?: string[];
|
|
95
|
+
color_mode?: string;
|
|
96
|
+
supported_color_modes?: string[];
|
|
97
|
+
min_mireds?: number;
|
|
98
|
+
max_mireds?: number;
|
|
99
|
+
min_color_temp_kelvin?: number;
|
|
100
|
+
max_color_temp_kelvin?: number;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Climate-specific attributes
|
|
104
|
+
*/
|
|
105
|
+
export interface IHomeAssistantClimateAttributes extends IHomeAssistantEntityAttributes {
|
|
106
|
+
hvac_modes?: string[];
|
|
107
|
+
hvac_action?: string;
|
|
108
|
+
current_temperature?: number;
|
|
109
|
+
target_temp_high?: number;
|
|
110
|
+
target_temp_low?: number;
|
|
111
|
+
temperature?: number;
|
|
112
|
+
preset_mode?: string;
|
|
113
|
+
preset_modes?: string[];
|
|
114
|
+
fan_mode?: string;
|
|
115
|
+
fan_modes?: string[];
|
|
116
|
+
swing_mode?: string;
|
|
117
|
+
swing_modes?: string[];
|
|
118
|
+
aux_heat?: boolean;
|
|
119
|
+
current_humidity?: number;
|
|
120
|
+
humidity?: number;
|
|
121
|
+
min_temp?: number;
|
|
122
|
+
max_temp?: number;
|
|
123
|
+
target_temp_step?: number;
|
|
124
|
+
min_humidity?: number;
|
|
125
|
+
max_humidity?: number;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Sensor-specific attributes
|
|
129
|
+
*/
|
|
130
|
+
export interface IHomeAssistantSensorAttributes extends IHomeAssistantEntityAttributes {
|
|
131
|
+
state_class?: 'measurement' | 'total' | 'total_increasing';
|
|
132
|
+
native_unit_of_measurement?: string;
|
|
133
|
+
native_value?: string | number;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Cover-specific attributes
|
|
137
|
+
*/
|
|
138
|
+
export interface IHomeAssistantCoverAttributes extends IHomeAssistantEntityAttributes {
|
|
139
|
+
current_position?: number;
|
|
140
|
+
current_tilt_position?: number;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Fan-specific attributes
|
|
144
|
+
*/
|
|
145
|
+
export interface IHomeAssistantFanAttributes extends IHomeAssistantEntityAttributes {
|
|
146
|
+
percentage?: number;
|
|
147
|
+
percentage_step?: number;
|
|
148
|
+
preset_mode?: string;
|
|
149
|
+
preset_modes?: string[];
|
|
150
|
+
oscillating?: boolean;
|
|
151
|
+
direction?: 'forward' | 'reverse';
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Lock-specific attributes
|
|
155
|
+
*/
|
|
156
|
+
export interface IHomeAssistantLockAttributes extends IHomeAssistantEntityAttributes {
|
|
157
|
+
is_locked?: boolean;
|
|
158
|
+
is_locking?: boolean;
|
|
159
|
+
is_unlocking?: boolean;
|
|
160
|
+
is_jammed?: boolean;
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Camera-specific attributes
|
|
164
|
+
*/
|
|
165
|
+
export interface IHomeAssistantCameraAttributes extends IHomeAssistantEntityAttributes {
|
|
166
|
+
access_token?: string;
|
|
167
|
+
entity_picture?: string;
|
|
168
|
+
frontend_stream_type?: 'hls' | 'web_rtc';
|
|
169
|
+
is_streaming?: boolean;
|
|
170
|
+
motion_detection?: boolean;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Media player-specific attributes
|
|
174
|
+
*/
|
|
175
|
+
export interface IHomeAssistantMediaPlayerAttributes extends IHomeAssistantEntityAttributes {
|
|
176
|
+
volume_level?: number;
|
|
177
|
+
is_volume_muted?: boolean;
|
|
178
|
+
media_content_id?: string;
|
|
179
|
+
media_content_type?: string;
|
|
180
|
+
media_duration?: number;
|
|
181
|
+
media_position?: number;
|
|
182
|
+
media_position_updated_at?: string;
|
|
183
|
+
media_title?: string;
|
|
184
|
+
media_artist?: string;
|
|
185
|
+
media_album_name?: string;
|
|
186
|
+
media_album_artist?: string;
|
|
187
|
+
media_track?: number;
|
|
188
|
+
media_series_title?: string;
|
|
189
|
+
media_season?: number;
|
|
190
|
+
media_episode?: number;
|
|
191
|
+
app_id?: string;
|
|
192
|
+
app_name?: string;
|
|
193
|
+
source?: string;
|
|
194
|
+
source_list?: string[];
|
|
195
|
+
sound_mode?: string;
|
|
196
|
+
sound_mode_list?: string[];
|
|
197
|
+
shuffle?: boolean;
|
|
198
|
+
repeat?: 'off' | 'all' | 'one';
|
|
199
|
+
entity_picture_local?: string;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Context for entity state changes
|
|
203
|
+
*/
|
|
204
|
+
export interface IHomeAssistantContext {
|
|
205
|
+
id: string;
|
|
206
|
+
parent_id?: string;
|
|
207
|
+
user_id?: string;
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Base message structure
|
|
211
|
+
*/
|
|
212
|
+
export interface IHomeAssistantMessage {
|
|
213
|
+
id?: number;
|
|
214
|
+
type: string;
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Authentication required message
|
|
218
|
+
*/
|
|
219
|
+
export interface IHomeAssistantAuthRequired extends IHomeAssistantMessage {
|
|
220
|
+
type: 'auth_required';
|
|
221
|
+
ha_version: string;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Authentication message to send
|
|
225
|
+
*/
|
|
226
|
+
export interface IHomeAssistantAuth extends IHomeAssistantMessage {
|
|
227
|
+
type: 'auth';
|
|
228
|
+
access_token: string;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Authentication success
|
|
232
|
+
*/
|
|
233
|
+
export interface IHomeAssistantAuthOk extends IHomeAssistantMessage {
|
|
234
|
+
type: 'auth_ok';
|
|
235
|
+
ha_version: string;
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Authentication invalid
|
|
239
|
+
*/
|
|
240
|
+
export interface IHomeAssistantAuthInvalid extends IHomeAssistantMessage {
|
|
241
|
+
type: 'auth_invalid';
|
|
242
|
+
message: string;
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Result message
|
|
246
|
+
*/
|
|
247
|
+
export interface IHomeAssistantResult extends IHomeAssistantMessage {
|
|
248
|
+
id: number;
|
|
249
|
+
type: 'result';
|
|
250
|
+
success: boolean;
|
|
251
|
+
result?: unknown;
|
|
252
|
+
error?: {
|
|
253
|
+
code: string;
|
|
254
|
+
message: string;
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Event message
|
|
259
|
+
*/
|
|
260
|
+
export interface IHomeAssistantEvent extends IHomeAssistantMessage {
|
|
261
|
+
id: number;
|
|
262
|
+
type: 'event';
|
|
263
|
+
event: {
|
|
264
|
+
event_type: string;
|
|
265
|
+
data: unknown;
|
|
266
|
+
origin: string;
|
|
267
|
+
time_fired: string;
|
|
268
|
+
context: IHomeAssistantContext;
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* State changed event data
|
|
273
|
+
*/
|
|
274
|
+
export interface IHomeAssistantStateChangedEvent {
|
|
275
|
+
entity_id: string;
|
|
276
|
+
old_state: IHomeAssistantEntity | null;
|
|
277
|
+
new_state: IHomeAssistantEntity | null;
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Subscribe events request
|
|
281
|
+
*/
|
|
282
|
+
export interface IHomeAssistantSubscribeEvents extends IHomeAssistantMessage {
|
|
283
|
+
id: number;
|
|
284
|
+
type: 'subscribe_events';
|
|
285
|
+
event_type?: string;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Get states request
|
|
289
|
+
*/
|
|
290
|
+
export interface IHomeAssistantGetStates extends IHomeAssistantMessage {
|
|
291
|
+
id: number;
|
|
292
|
+
type: 'get_states';
|
|
293
|
+
}
|
|
294
|
+
/**
|
|
295
|
+
* Call service request
|
|
296
|
+
*/
|
|
297
|
+
export interface IHomeAssistantCallService extends IHomeAssistantMessage {
|
|
298
|
+
id: number;
|
|
299
|
+
type: 'call_service';
|
|
300
|
+
domain: string;
|
|
301
|
+
service: string;
|
|
302
|
+
target?: {
|
|
303
|
+
entity_id?: string | string[];
|
|
304
|
+
device_id?: string | string[];
|
|
305
|
+
area_id?: string | string[];
|
|
306
|
+
};
|
|
307
|
+
service_data?: Record<string, unknown>;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Get services request
|
|
311
|
+
*/
|
|
312
|
+
export interface IHomeAssistantGetServices extends IHomeAssistantMessage {
|
|
313
|
+
id: number;
|
|
314
|
+
type: 'get_services';
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Get config request
|
|
318
|
+
*/
|
|
319
|
+
export interface IHomeAssistantGetConfig extends IHomeAssistantMessage {
|
|
320
|
+
id: number;
|
|
321
|
+
type: 'get_config';
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Home Assistant config response
|
|
325
|
+
*/
|
|
326
|
+
export interface IHomeAssistantConfig {
|
|
327
|
+
latitude: number;
|
|
328
|
+
longitude: number;
|
|
329
|
+
elevation: number;
|
|
330
|
+
unit_system: {
|
|
331
|
+
length: string;
|
|
332
|
+
mass: string;
|
|
333
|
+
pressure: string;
|
|
334
|
+
temperature: string;
|
|
335
|
+
volume: string;
|
|
336
|
+
};
|
|
337
|
+
location_name: string;
|
|
338
|
+
time_zone: string;
|
|
339
|
+
components: string[];
|
|
340
|
+
config_dir: string;
|
|
341
|
+
allowlist_external_dirs: string[];
|
|
342
|
+
allowlist_external_urls: string[];
|
|
343
|
+
version: string;
|
|
344
|
+
config_source: string;
|
|
345
|
+
safe_mode: boolean;
|
|
346
|
+
state: 'NOT_RUNNING' | 'STARTING' | 'RUNNING' | 'STOPPING' | 'FINAL_WRITE';
|
|
347
|
+
external_url: string | null;
|
|
348
|
+
internal_url: string | null;
|
|
349
|
+
currency: string;
|
|
350
|
+
country: string;
|
|
351
|
+
language: string;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Light service data
|
|
355
|
+
*/
|
|
356
|
+
export interface IHomeAssistantLightServiceData {
|
|
357
|
+
brightness?: number;
|
|
358
|
+
brightness_pct?: number;
|
|
359
|
+
brightness_step?: number;
|
|
360
|
+
brightness_step_pct?: number;
|
|
361
|
+
color_temp?: number;
|
|
362
|
+
color_temp_kelvin?: number;
|
|
363
|
+
hs_color?: [number, number];
|
|
364
|
+
rgb_color?: [number, number, number];
|
|
365
|
+
xy_color?: [number, number];
|
|
366
|
+
rgbw_color?: [number, number, number, number];
|
|
367
|
+
rgbww_color?: [number, number, number, number, number];
|
|
368
|
+
color_name?: string;
|
|
369
|
+
kelvin?: number;
|
|
370
|
+
effect?: string;
|
|
371
|
+
transition?: number;
|
|
372
|
+
flash?: 'short' | 'long';
|
|
373
|
+
profile?: string;
|
|
374
|
+
[key: string]: unknown;
|
|
375
|
+
}
|
|
376
|
+
/**
|
|
377
|
+
* Climate service data
|
|
378
|
+
*/
|
|
379
|
+
export interface IHomeAssistantClimateServiceData {
|
|
380
|
+
hvac_mode?: string;
|
|
381
|
+
temperature?: number;
|
|
382
|
+
target_temp_high?: number;
|
|
383
|
+
target_temp_low?: number;
|
|
384
|
+
humidity?: number;
|
|
385
|
+
fan_mode?: string;
|
|
386
|
+
swing_mode?: string;
|
|
387
|
+
preset_mode?: string;
|
|
388
|
+
aux_heat?: boolean;
|
|
389
|
+
[key: string]: unknown;
|
|
390
|
+
}
|
|
391
|
+
/**
|
|
392
|
+
* Cover service data
|
|
393
|
+
*/
|
|
394
|
+
export interface IHomeAssistantCoverServiceData {
|
|
395
|
+
position?: number;
|
|
396
|
+
tilt_position?: number;
|
|
397
|
+
}
|
|
398
|
+
/**
|
|
399
|
+
* Fan service data
|
|
400
|
+
*/
|
|
401
|
+
export interface IHomeAssistantFanServiceData {
|
|
402
|
+
percentage?: number;
|
|
403
|
+
percentage_step?: number;
|
|
404
|
+
preset_mode?: string;
|
|
405
|
+
direction?: 'forward' | 'reverse';
|
|
406
|
+
oscillating?: boolean;
|
|
407
|
+
[key: string]: unknown;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Media player service data
|
|
411
|
+
*/
|
|
412
|
+
export interface IHomeAssistantMediaPlayerServiceData {
|
|
413
|
+
volume_level?: number;
|
|
414
|
+
is_volume_muted?: boolean;
|
|
415
|
+
media_content_id?: string;
|
|
416
|
+
media_content_type?: string;
|
|
417
|
+
enqueue?: 'play' | 'next' | 'add' | 'replace';
|
|
418
|
+
seek_position?: number;
|
|
419
|
+
source?: string;
|
|
420
|
+
sound_mode?: string;
|
|
421
|
+
shuffle?: boolean;
|
|
422
|
+
repeat?: 'off' | 'all' | 'one';
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Discovered Home Assistant instance via mDNS
|
|
426
|
+
*/
|
|
427
|
+
export interface IHomeAssistantDiscoveredInstance {
|
|
428
|
+
/** Instance ID (derived from host) */
|
|
429
|
+
id: string;
|
|
430
|
+
/** Host address */
|
|
431
|
+
host: string;
|
|
432
|
+
/** Port number */
|
|
433
|
+
port: number;
|
|
434
|
+
/** Base URL */
|
|
435
|
+
base_url: string;
|
|
436
|
+
/** mDNS TXT records */
|
|
437
|
+
txtRecords: Record<string, string>;
|
|
438
|
+
/** Whether connection requires token */
|
|
439
|
+
requires_api_password: boolean;
|
|
440
|
+
/** Friendly name from mDNS */
|
|
441
|
+
friendlyName?: string;
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Events emitted by HomeAssistantProtocol
|
|
445
|
+
*/
|
|
446
|
+
export type THomeAssistantProtocolEvents = {
|
|
447
|
+
'connected': () => void;
|
|
448
|
+
'disconnected': () => void;
|
|
449
|
+
'reconnecting': (attempt: number) => void;
|
|
450
|
+
'authenticated': (config: IHomeAssistantConfig) => void;
|
|
451
|
+
'auth:failed': (message: string) => void;
|
|
452
|
+
'state:changed': (event: IHomeAssistantStateChangedEvent) => void;
|
|
453
|
+
'states:loaded': (entities: IHomeAssistantEntity[]) => void;
|
|
454
|
+
'error': (error: Error) => void;
|
|
455
|
+
};
|
|
456
|
+
/**
|
|
457
|
+
* Events emitted by HomeAssistantDiscovery
|
|
458
|
+
*/
|
|
459
|
+
export type THomeAssistantDiscoveryEvents = {
|
|
460
|
+
'instance:found': (instance: IHomeAssistantDiscoveredInstance) => void;
|
|
461
|
+
'instance:lost': (instanceId: string) => void;
|
|
462
|
+
'entity:found': (entity: IHomeAssistantEntity) => void;
|
|
463
|
+
'entity:updated': (entity: IHomeAssistantEntity) => void;
|
|
464
|
+
'entity:removed': (entityId: string) => void;
|
|
465
|
+
'error': (error: Error) => void;
|
|
466
|
+
};
|
|
467
|
+
/**
|
|
468
|
+
* Extract domain from entity_id
|
|
469
|
+
*/
|
|
470
|
+
export declare function getEntityDomain(entityId: string): THomeAssistantDomain | null;
|
|
471
|
+
/**
|
|
472
|
+
* Map HA domain to feature type
|
|
473
|
+
*/
|
|
474
|
+
export declare function domainToFeatureType(domain: THomeAssistantDomain): string;
|
|
475
|
+
/**
|
|
476
|
+
* Supported light color modes in HA
|
|
477
|
+
*/
|
|
478
|
+
export type THomeAssistantColorMode = 'unknown' | 'onoff' | 'brightness' | 'color_temp' | 'hs' | 'xy' | 'rgb' | 'rgbw' | 'rgbww' | 'white';
|
|
479
|
+
/**
|
|
480
|
+
* Light supported features bitmask
|
|
481
|
+
*/
|
|
482
|
+
export declare const LIGHT_SUPPORT: {
|
|
483
|
+
readonly EFFECT: 4;
|
|
484
|
+
readonly FLASH: 8;
|
|
485
|
+
readonly TRANSITION: 32;
|
|
486
|
+
};
|
|
487
|
+
/**
|
|
488
|
+
* Climate supported features bitmask
|
|
489
|
+
*/
|
|
490
|
+
export declare const CLIMATE_SUPPORT: {
|
|
491
|
+
readonly TARGET_TEMPERATURE: 1;
|
|
492
|
+
readonly TARGET_TEMPERATURE_RANGE: 2;
|
|
493
|
+
readonly TARGET_HUMIDITY: 4;
|
|
494
|
+
readonly FAN_MODE: 8;
|
|
495
|
+
readonly PRESET_MODE: 16;
|
|
496
|
+
readonly SWING_MODE: 32;
|
|
497
|
+
readonly AUX_HEAT: 64;
|
|
498
|
+
};
|
|
499
|
+
/**
|
|
500
|
+
* Cover supported features bitmask
|
|
501
|
+
*/
|
|
502
|
+
export declare const COVER_SUPPORT: {
|
|
503
|
+
readonly OPEN: 1;
|
|
504
|
+
readonly CLOSE: 2;
|
|
505
|
+
readonly SET_POSITION: 4;
|
|
506
|
+
readonly STOP: 8;
|
|
507
|
+
readonly OPEN_TILT: 16;
|
|
508
|
+
readonly CLOSE_TILT: 32;
|
|
509
|
+
readonly STOP_TILT: 64;
|
|
510
|
+
readonly SET_TILT_POSITION: 128;
|
|
511
|
+
};
|
|
512
|
+
/**
|
|
513
|
+
* Fan supported features bitmask
|
|
514
|
+
*/
|
|
515
|
+
export declare const FAN_SUPPORT: {
|
|
516
|
+
readonly SET_SPEED: 1;
|
|
517
|
+
readonly OSCILLATE: 2;
|
|
518
|
+
readonly DIRECTION: 4;
|
|
519
|
+
readonly PRESET_MODE: 8;
|
|
520
|
+
};
|
|
521
|
+
/**
|
|
522
|
+
* Lock supported features bitmask
|
|
523
|
+
*/
|
|
524
|
+
export declare const LOCK_SUPPORT: {
|
|
525
|
+
readonly OPEN: 1;
|
|
526
|
+
};
|
|
527
|
+
/**
|
|
528
|
+
* Media player supported features bitmask
|
|
529
|
+
*/
|
|
530
|
+
export declare const MEDIA_PLAYER_SUPPORT: {
|
|
531
|
+
readonly PAUSE: 1;
|
|
532
|
+
readonly SEEK: 2;
|
|
533
|
+
readonly VOLUME_SET: 4;
|
|
534
|
+
readonly VOLUME_MUTE: 8;
|
|
535
|
+
readonly PREVIOUS_TRACK: 16;
|
|
536
|
+
readonly NEXT_TRACK: 32;
|
|
537
|
+
readonly TURN_ON: 128;
|
|
538
|
+
readonly TURN_OFF: 256;
|
|
539
|
+
readonly PLAY_MEDIA: 512;
|
|
540
|
+
readonly VOLUME_STEP: 1024;
|
|
541
|
+
readonly SELECT_SOURCE: 2048;
|
|
542
|
+
readonly STOP: 4096;
|
|
543
|
+
readonly CLEAR_PLAYLIST: 8192;
|
|
544
|
+
readonly PLAY: 16384;
|
|
545
|
+
readonly SHUFFLE_SET: 32768;
|
|
546
|
+
readonly SELECT_SOUND_MODE: 65536;
|
|
547
|
+
readonly BROWSE_MEDIA: 131072;
|
|
548
|
+
readonly REPEAT_SET: 262144;
|
|
549
|
+
readonly GROUPING: 524288;
|
|
550
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Home Assistant Specific Interfaces
|
|
3
|
+
* Types for Home Assistant WebSocket API, entities, and configuration
|
|
4
|
+
*/
|
|
5
|
+
// ============================================================================
|
|
6
|
+
// Helper Types
|
|
7
|
+
// ============================================================================
|
|
8
|
+
/**
|
|
9
|
+
* Extract domain from entity_id
|
|
10
|
+
*/
|
|
11
|
+
export function getEntityDomain(entityId) {
|
|
12
|
+
const domain = entityId.split('.')[0];
|
|
13
|
+
const validDomains = [
|
|
14
|
+
'light', 'switch', 'sensor', 'binary_sensor', 'climate',
|
|
15
|
+
'fan', 'cover', 'lock', 'camera', 'media_player'
|
|
16
|
+
];
|
|
17
|
+
return validDomains.includes(domain)
|
|
18
|
+
? domain
|
|
19
|
+
: null;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Map HA domain to feature type
|
|
23
|
+
*/
|
|
24
|
+
export function domainToFeatureType(domain) {
|
|
25
|
+
const mapping = {
|
|
26
|
+
'light': 'light',
|
|
27
|
+
'switch': 'switch',
|
|
28
|
+
'sensor': 'sensor',
|
|
29
|
+
'binary_sensor': 'sensor',
|
|
30
|
+
'climate': 'climate',
|
|
31
|
+
'fan': 'fan',
|
|
32
|
+
'cover': 'cover',
|
|
33
|
+
'lock': 'lock',
|
|
34
|
+
'camera': 'camera',
|
|
35
|
+
'media_player': 'playback',
|
|
36
|
+
};
|
|
37
|
+
return mapping[domain];
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Light supported features bitmask
|
|
41
|
+
*/
|
|
42
|
+
export const LIGHT_SUPPORT = {
|
|
43
|
+
EFFECT: 4,
|
|
44
|
+
FLASH: 8,
|
|
45
|
+
TRANSITION: 32,
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Climate supported features bitmask
|
|
49
|
+
*/
|
|
50
|
+
export const CLIMATE_SUPPORT = {
|
|
51
|
+
TARGET_TEMPERATURE: 1,
|
|
52
|
+
TARGET_TEMPERATURE_RANGE: 2,
|
|
53
|
+
TARGET_HUMIDITY: 4,
|
|
54
|
+
FAN_MODE: 8,
|
|
55
|
+
PRESET_MODE: 16,
|
|
56
|
+
SWING_MODE: 32,
|
|
57
|
+
AUX_HEAT: 64,
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Cover supported features bitmask
|
|
61
|
+
*/
|
|
62
|
+
export const COVER_SUPPORT = {
|
|
63
|
+
OPEN: 1,
|
|
64
|
+
CLOSE: 2,
|
|
65
|
+
SET_POSITION: 4,
|
|
66
|
+
STOP: 8,
|
|
67
|
+
OPEN_TILT: 16,
|
|
68
|
+
CLOSE_TILT: 32,
|
|
69
|
+
STOP_TILT: 64,
|
|
70
|
+
SET_TILT_POSITION: 128,
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Fan supported features bitmask
|
|
74
|
+
*/
|
|
75
|
+
export const FAN_SUPPORT = {
|
|
76
|
+
SET_SPEED: 1,
|
|
77
|
+
OSCILLATE: 2,
|
|
78
|
+
DIRECTION: 4,
|
|
79
|
+
PRESET_MODE: 8,
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Lock supported features bitmask
|
|
83
|
+
*/
|
|
84
|
+
export const LOCK_SUPPORT = {
|
|
85
|
+
OPEN: 1,
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Media player supported features bitmask
|
|
89
|
+
*/
|
|
90
|
+
export const MEDIA_PLAYER_SUPPORT = {
|
|
91
|
+
PAUSE: 1,
|
|
92
|
+
SEEK: 2,
|
|
93
|
+
VOLUME_SET: 4,
|
|
94
|
+
VOLUME_MUTE: 8,
|
|
95
|
+
PREVIOUS_TRACK: 16,
|
|
96
|
+
NEXT_TRACK: 32,
|
|
97
|
+
TURN_ON: 128,
|
|
98
|
+
TURN_OFF: 256,
|
|
99
|
+
PLAY_MEDIA: 512,
|
|
100
|
+
VOLUME_STEP: 1024,
|
|
101
|
+
SELECT_SOURCE: 2048,
|
|
102
|
+
STOP: 4096,
|
|
103
|
+
CLEAR_PLAYLIST: 8192,
|
|
104
|
+
PLAY: 16384,
|
|
105
|
+
SHUFFLE_SET: 32768,
|
|
106
|
+
SELECT_SOUND_MODE: 65536,
|
|
107
|
+
BROWSE_MEDIA: 131072,
|
|
108
|
+
REPEAT_SET: 262144,
|
|
109
|
+
GROUPING: 524288,
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaG9tZWFzc2lzdGFud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