@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,248 @@
|
|
|
1
|
+
import * as plugins from '../plugins.js';
|
|
2
|
+
import type { IHomeAssistantInstanceConfig, IHomeAssistantEntity, IHomeAssistantConfig, IHomeAssistantLightServiceData, IHomeAssistantClimateServiceData, IHomeAssistantFanServiceData } from '../interfaces/homeassistant.interfaces.js';
|
|
3
|
+
/**
|
|
4
|
+
* Home Assistant WebSocket Protocol Handler
|
|
5
|
+
* Connects to HA via WebSocket, handles authentication, state subscriptions, and service calls
|
|
6
|
+
*/
|
|
7
|
+
export declare class HomeAssistantProtocol extends plugins.events.EventEmitter {
|
|
8
|
+
private ws;
|
|
9
|
+
private config;
|
|
10
|
+
private messageId;
|
|
11
|
+
private pendingRequests;
|
|
12
|
+
private isAuthenticated;
|
|
13
|
+
private haConfig;
|
|
14
|
+
private reconnectAttempt;
|
|
15
|
+
private reconnectTimer;
|
|
16
|
+
private stateSubscriptionId;
|
|
17
|
+
private entityStates;
|
|
18
|
+
private intentionalDisconnect;
|
|
19
|
+
constructor(config: IHomeAssistantInstanceConfig);
|
|
20
|
+
/**
|
|
21
|
+
* Get the WebSocket URL for this HA instance
|
|
22
|
+
*/
|
|
23
|
+
private get wsUrl();
|
|
24
|
+
/**
|
|
25
|
+
* Get connection state
|
|
26
|
+
*/
|
|
27
|
+
get isConnected(): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Get HA config if authenticated
|
|
30
|
+
*/
|
|
31
|
+
get homeAssistantConfig(): IHomeAssistantConfig | null;
|
|
32
|
+
/**
|
|
33
|
+
* Get all cached entity states
|
|
34
|
+
*/
|
|
35
|
+
get entities(): Map<string, IHomeAssistantEntity>;
|
|
36
|
+
/**
|
|
37
|
+
* Connect to Home Assistant
|
|
38
|
+
*/
|
|
39
|
+
connect(): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Disconnect from Home Assistant
|
|
42
|
+
*/
|
|
43
|
+
disconnect(): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Send authentication message
|
|
46
|
+
*/
|
|
47
|
+
private sendAuth;
|
|
48
|
+
/**
|
|
49
|
+
* Handle incoming messages
|
|
50
|
+
*/
|
|
51
|
+
private handleMessage;
|
|
52
|
+
/**
|
|
53
|
+
* Send a request and wait for response
|
|
54
|
+
*/
|
|
55
|
+
private sendRequest;
|
|
56
|
+
/**
|
|
57
|
+
* Schedule reconnection attempt
|
|
58
|
+
*/
|
|
59
|
+
private scheduleReconnect;
|
|
60
|
+
/**
|
|
61
|
+
* Get HA config
|
|
62
|
+
*/
|
|
63
|
+
getConfig(): Promise<IHomeAssistantConfig>;
|
|
64
|
+
/**
|
|
65
|
+
* Subscribe to state change events
|
|
66
|
+
*/
|
|
67
|
+
subscribeToStateChanges(): Promise<number>;
|
|
68
|
+
/**
|
|
69
|
+
* Get all entity states
|
|
70
|
+
*/
|
|
71
|
+
getStates(): Promise<IHomeAssistantEntity[]>;
|
|
72
|
+
/**
|
|
73
|
+
* Get a specific entity state
|
|
74
|
+
*/
|
|
75
|
+
getState(entityId: string): Promise<IHomeAssistantEntity | null>;
|
|
76
|
+
/**
|
|
77
|
+
* Get entities by domain
|
|
78
|
+
*/
|
|
79
|
+
getEntitiesByDomain(domain: string): Promise<IHomeAssistantEntity[]>;
|
|
80
|
+
/**
|
|
81
|
+
* Call a Home Assistant service
|
|
82
|
+
*/
|
|
83
|
+
callService(domain: string, service: string, target?: {
|
|
84
|
+
entity_id?: string | string[];
|
|
85
|
+
device_id?: string | string[];
|
|
86
|
+
area_id?: string | string[];
|
|
87
|
+
}, serviceData?: Record<string, unknown>): Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Turn on an entity
|
|
90
|
+
*/
|
|
91
|
+
turnOn(entityId: string, data?: Record<string, unknown>): Promise<void>;
|
|
92
|
+
/**
|
|
93
|
+
* Turn off an entity
|
|
94
|
+
*/
|
|
95
|
+
turnOff(entityId: string): Promise<void>;
|
|
96
|
+
/**
|
|
97
|
+
* Toggle an entity
|
|
98
|
+
*/
|
|
99
|
+
toggle(entityId: string): Promise<void>;
|
|
100
|
+
/**
|
|
101
|
+
* Control a light
|
|
102
|
+
*/
|
|
103
|
+
lightTurnOn(entityId: string, options?: IHomeAssistantLightServiceData): Promise<void>;
|
|
104
|
+
lightTurnOff(entityId: string, options?: {
|
|
105
|
+
transition?: number;
|
|
106
|
+
}): Promise<void>;
|
|
107
|
+
lightToggle(entityId: string, options?: IHomeAssistantLightServiceData): Promise<void>;
|
|
108
|
+
/**
|
|
109
|
+
* Set HVAC mode
|
|
110
|
+
*/
|
|
111
|
+
climateSetHvacMode(entityId: string, hvacMode: string): Promise<void>;
|
|
112
|
+
/**
|
|
113
|
+
* Set target temperature
|
|
114
|
+
*/
|
|
115
|
+
climateSetTemperature(entityId: string, options: IHomeAssistantClimateServiceData): Promise<void>;
|
|
116
|
+
/**
|
|
117
|
+
* Set fan mode
|
|
118
|
+
*/
|
|
119
|
+
climateSetFanMode(entityId: string, fanMode: string): Promise<void>;
|
|
120
|
+
/**
|
|
121
|
+
* Set preset mode
|
|
122
|
+
*/
|
|
123
|
+
climateSetPresetMode(entityId: string, presetMode: string): Promise<void>;
|
|
124
|
+
/**
|
|
125
|
+
* Set swing mode
|
|
126
|
+
*/
|
|
127
|
+
climateSetSwingMode(entityId: string, swingMode: string): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Set aux heat
|
|
130
|
+
*/
|
|
131
|
+
climateSetAuxHeat(entityId: string, auxHeat: boolean): Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* Open cover
|
|
134
|
+
*/
|
|
135
|
+
coverOpen(entityId: string): Promise<void>;
|
|
136
|
+
/**
|
|
137
|
+
* Close cover
|
|
138
|
+
*/
|
|
139
|
+
coverClose(entityId: string): Promise<void>;
|
|
140
|
+
/**
|
|
141
|
+
* Stop cover
|
|
142
|
+
*/
|
|
143
|
+
coverStop(entityId: string): Promise<void>;
|
|
144
|
+
/**
|
|
145
|
+
* Set cover position
|
|
146
|
+
*/
|
|
147
|
+
coverSetPosition(entityId: string, position: number): Promise<void>;
|
|
148
|
+
/**
|
|
149
|
+
* Set cover tilt position
|
|
150
|
+
*/
|
|
151
|
+
coverSetTiltPosition(entityId: string, tiltPosition: number): Promise<void>;
|
|
152
|
+
/**
|
|
153
|
+
* Turn on fan
|
|
154
|
+
*/
|
|
155
|
+
fanTurnOn(entityId: string, options?: IHomeAssistantFanServiceData): Promise<void>;
|
|
156
|
+
/**
|
|
157
|
+
* Turn off fan
|
|
158
|
+
*/
|
|
159
|
+
fanTurnOff(entityId: string): Promise<void>;
|
|
160
|
+
/**
|
|
161
|
+
* Set fan percentage
|
|
162
|
+
*/
|
|
163
|
+
fanSetPercentage(entityId: string, percentage: number): Promise<void>;
|
|
164
|
+
/**
|
|
165
|
+
* Set fan preset mode
|
|
166
|
+
*/
|
|
167
|
+
fanSetPresetMode(entityId: string, presetMode: string): Promise<void>;
|
|
168
|
+
/**
|
|
169
|
+
* Oscillate fan
|
|
170
|
+
*/
|
|
171
|
+
fanOscillate(entityId: string, oscillating: boolean): Promise<void>;
|
|
172
|
+
/**
|
|
173
|
+
* Set fan direction
|
|
174
|
+
*/
|
|
175
|
+
fanSetDirection(entityId: string, direction: 'forward' | 'reverse'): Promise<void>;
|
|
176
|
+
/**
|
|
177
|
+
* Lock
|
|
178
|
+
*/
|
|
179
|
+
lockLock(entityId: string): Promise<void>;
|
|
180
|
+
/**
|
|
181
|
+
* Unlock
|
|
182
|
+
*/
|
|
183
|
+
lockUnlock(entityId: string): Promise<void>;
|
|
184
|
+
/**
|
|
185
|
+
* Open (if supported)
|
|
186
|
+
*/
|
|
187
|
+
lockOpen(entityId: string): Promise<void>;
|
|
188
|
+
/**
|
|
189
|
+
* Turn on switch
|
|
190
|
+
*/
|
|
191
|
+
switchTurnOn(entityId: string): Promise<void>;
|
|
192
|
+
/**
|
|
193
|
+
* Turn off switch
|
|
194
|
+
*/
|
|
195
|
+
switchTurnOff(entityId: string): Promise<void>;
|
|
196
|
+
/**
|
|
197
|
+
* Toggle switch
|
|
198
|
+
*/
|
|
199
|
+
switchToggle(entityId: string): Promise<void>;
|
|
200
|
+
/**
|
|
201
|
+
* Play media
|
|
202
|
+
*/
|
|
203
|
+
mediaPlayerPlay(entityId: string): Promise<void>;
|
|
204
|
+
/**
|
|
205
|
+
* Pause media
|
|
206
|
+
*/
|
|
207
|
+
mediaPlayerPause(entityId: string): Promise<void>;
|
|
208
|
+
/**
|
|
209
|
+
* Stop media
|
|
210
|
+
*/
|
|
211
|
+
mediaPlayerStop(entityId: string): Promise<void>;
|
|
212
|
+
/**
|
|
213
|
+
* Next track
|
|
214
|
+
*/
|
|
215
|
+
mediaPlayerNext(entityId: string): Promise<void>;
|
|
216
|
+
/**
|
|
217
|
+
* Previous track
|
|
218
|
+
*/
|
|
219
|
+
mediaPlayerPrevious(entityId: string): Promise<void>;
|
|
220
|
+
/**
|
|
221
|
+
* Set volume
|
|
222
|
+
*/
|
|
223
|
+
mediaPlayerSetVolume(entityId: string, volumeLevel: number): Promise<void>;
|
|
224
|
+
/**
|
|
225
|
+
* Mute/unmute
|
|
226
|
+
*/
|
|
227
|
+
mediaPlayerMute(entityId: string, isMuted: boolean): Promise<void>;
|
|
228
|
+
/**
|
|
229
|
+
* Seek to position
|
|
230
|
+
*/
|
|
231
|
+
mediaPlayerSeek(entityId: string, position: number): Promise<void>;
|
|
232
|
+
/**
|
|
233
|
+
* Select source
|
|
234
|
+
*/
|
|
235
|
+
mediaPlayerSelectSource(entityId: string, source: string): Promise<void>;
|
|
236
|
+
/**
|
|
237
|
+
* Get camera snapshot URL
|
|
238
|
+
*/
|
|
239
|
+
getCameraSnapshotUrl(entityId: string): string;
|
|
240
|
+
/**
|
|
241
|
+
* Get camera stream URL
|
|
242
|
+
*/
|
|
243
|
+
getCameraStreamUrl(entityId: string): string;
|
|
244
|
+
/**
|
|
245
|
+
* Probe if a Home Assistant instance is reachable
|
|
246
|
+
*/
|
|
247
|
+
static probe(host: string, port?: number, secure?: boolean, timeout?: number): Promise<boolean>;
|
|
248
|
+
}
|