@enyo-energy/energy-app-sdk 0.0.37 → 0.0.39

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.
Files changed (47) hide show
  1. package/dist/cjs/implementations/appliances/appliance-manager.cjs +399 -0
  2. package/dist/cjs/implementations/appliances/appliance-manager.d.cts +191 -0
  3. package/dist/cjs/implementations/appliances/identifier-strategies.cjs +180 -0
  4. package/dist/cjs/implementations/appliances/identifier-strategies.d.cts +140 -0
  5. package/dist/cjs/implementations/appliances/in-memory-appliance-manager.cjs +281 -0
  6. package/dist/cjs/implementations/appliances/in-memory-appliance-manager.d.cts +119 -0
  7. package/dist/cjs/implementations/data-bus/demo-data-bus.cjs +246 -0
  8. package/dist/cjs/implementations/data-bus/demo-data-bus.d.cts +111 -0
  9. package/dist/cjs/implementations/modbus/EnergyAppModbusDataTypeConverter.d.cts +2 -2
  10. package/dist/cjs/implementations/modbus/EnergyAppModbusFaultTolerantReader.cjs +76 -0
  11. package/dist/cjs/implementations/modbus/EnergyAppModbusFaultTolerantReader.d.cts +31 -1
  12. package/dist/cjs/implementations/modbus/EnergyAppModbusRegisterMapper.d.cts +2 -2
  13. package/dist/cjs/implementations/modbus/interfaces.d.cts +7 -93
  14. package/dist/cjs/implementations/modbus/sunspec/sunspec-devices.cjs +342 -0
  15. package/dist/cjs/implementations/modbus/sunspec/sunspec-devices.d.cts +95 -0
  16. package/dist/cjs/implementations/modbus/sunspec/sunspec-modbus-client.cjs +433 -0
  17. package/dist/cjs/implementations/modbus/sunspec/sunspec-modbus-client.d.cts +171 -0
  18. package/dist/cjs/index.cjs +2 -3
  19. package/dist/cjs/index.d.cts +2 -3
  20. package/dist/cjs/types/enyo-data-bus-value.d.cts +2 -1
  21. package/dist/cjs/version.cjs +1 -1
  22. package/dist/cjs/version.d.cts +1 -1
  23. package/dist/implementations/appliances/appliance-manager.d.ts +191 -0
  24. package/dist/implementations/appliances/appliance-manager.js +395 -0
  25. package/dist/implementations/appliances/demo-appliance-manager.d.ts +118 -0
  26. package/dist/implementations/appliances/demo-appliance-manager.js +277 -0
  27. package/dist/implementations/appliances/identifier-strategies.d.ts +140 -0
  28. package/dist/implementations/appliances/identifier-strategies.js +171 -0
  29. package/dist/implementations/appliances/in-memory-appliance-manager.d.ts +119 -0
  30. package/dist/implementations/appliances/in-memory-appliance-manager.js +277 -0
  31. package/dist/implementations/data-bus/demo-data-bus.d.ts +111 -0
  32. package/dist/implementations/data-bus/demo-data-bus.js +242 -0
  33. package/dist/implementations/modbus/EnergyAppModbusDataTypeConverter.d.ts +2 -2
  34. package/dist/implementations/modbus/EnergyAppModbusFaultTolerantReader.d.ts +31 -1
  35. package/dist/implementations/modbus/EnergyAppModbusFaultTolerantReader.js +76 -0
  36. package/dist/implementations/modbus/EnergyAppModbusRegisterMapper.d.ts +2 -2
  37. package/dist/implementations/modbus/interfaces.d.ts +7 -93
  38. package/dist/implementations/modbus/sunspec/sunspec-devices.d.ts +95 -0
  39. package/dist/implementations/modbus/sunspec/sunspec-devices.js +335 -0
  40. package/dist/implementations/modbus/sunspec/sunspec-modbus-client.d.ts +171 -0
  41. package/dist/implementations/modbus/sunspec/sunspec-modbus-client.js +429 -0
  42. package/dist/index.d.ts +2 -3
  43. package/dist/index.js +2 -3
  44. package/dist/types/enyo-data-bus-value.d.ts +2 -1
  45. package/dist/version.d.ts +1 -1
  46. package/dist/version.js +1 -1
  47. package/package.json +1 -1
@@ -0,0 +1,399 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApplianceManager = void 0;
4
+ const enyo_appliance_js_1 = require("../../types/enyo-appliance.cjs");
5
+ const identifier_strategies_js_1 = require("./identifier-strategies.cjs");
6
+ /**
7
+ * Manages appliances in the energy system with configurable identification strategies.
8
+ * Provides comprehensive CRUD operations and state management for energy appliances.
9
+ */
10
+ class ApplianceManager {
11
+ energyApp;
12
+ applianceCache = new Map();
13
+ identifierToApplianceId = new Map();
14
+ config;
15
+ /**
16
+ * Creates a new ApplianceManager instance.
17
+ * @param energyApp The EnergyApp instance to use for API calls
18
+ * @param config Configuration options for the manager
19
+ */
20
+ constructor(energyApp, config) {
21
+ this.energyApp = energyApp;
22
+ this.config = {
23
+ identifierStrategy: config?.identifierStrategy ?? new identifier_strategies_js_1.NetworkDeviceIdStrategy(),
24
+ autoUpdateMetadata: config?.autoUpdateMetadata ?? true,
25
+ enableLogging: config?.enableLogging ?? true,
26
+ defaultConnectionType: config?.defaultConnectionType ?? enyo_appliance_js_1.EnyoApplianceConnectionType.Connector,
27
+ defaultVendorName: config?.defaultVendorName ?? ''
28
+ };
29
+ }
30
+ /**
31
+ * Creates or updates an appliance with the given configuration.
32
+ * @param config The appliance configuration
33
+ * @param existingApplianceId Optional ID of an existing appliance to update
34
+ * @returns The ID of the created or updated appliance
35
+ */
36
+ async createOrUpdateAppliance(config, existingApplianceId) {
37
+ // Build network device IDs list
38
+ const networkDeviceIds = config.networkDevices?.map(d => d.id) ?? [];
39
+ // Merge metadata with defaults
40
+ const metadata = {
41
+ connectionType: this.config.defaultConnectionType,
42
+ state: enyo_appliance_js_1.EnyoApplianceStateEnum.Connected,
43
+ ...config.metadata
44
+ };
45
+ if (this.config.defaultVendorName && !metadata.vendorName) {
46
+ metadata.vendorName = this.config.defaultVendorName;
47
+ }
48
+ // Build appliance data
49
+ const applianceData = {
50
+ name: config.name,
51
+ type: config.type,
52
+ networkDeviceIds,
53
+ metadata,
54
+ ...(config.topology && { topology: config.topology })
55
+ };
56
+ // Add type-specific metadata
57
+ if (config.typeMetadata) {
58
+ Object.assign(applianceData, config.typeMetadata);
59
+ }
60
+ // Save appliance
61
+ const applianceId = await this.energyApp.useAppliances().save(applianceData, existingApplianceId);
62
+ // Update cache
63
+ const savedAppliance = await this.energyApp.useAppliances().getById(applianceId);
64
+ if (savedAppliance) {
65
+ this.updateCache(savedAppliance, config.networkDevices?.[0]);
66
+ }
67
+ console.log(`${existingApplianceId ? 'Updated' : 'Created'} appliance ${applianceId} of type ${config.type}`);
68
+ return applianceId;
69
+ }
70
+ /**
71
+ * Updates the internal cache with an appliance.
72
+ * @param appliance The appliance to cache
73
+ * @param networkDevice Optional network device for identifier extraction
74
+ */
75
+ updateCache(appliance, networkDevice) {
76
+ this.applianceCache.set(appliance.id, appliance);
77
+ // Extract identifier
78
+ const identifier = this.config.identifierStrategy.extract(appliance, networkDevice);
79
+ if (identifier) {
80
+ if (!this.identifierToApplianceId.has(identifier)) {
81
+ this.identifierToApplianceId.set(identifier, new Set());
82
+ }
83
+ this.identifierToApplianceId.get(identifier).add(appliance.id);
84
+ }
85
+ }
86
+ /**
87
+ * Clears the internal cache.
88
+ */
89
+ clearCache() {
90
+ this.applianceCache.clear();
91
+ this.identifierToApplianceId.clear();
92
+ }
93
+ /**
94
+ * Refreshes the cache with all appliances from the system.
95
+ */
96
+ async refreshCache() {
97
+ this.clearCache();
98
+ const appliances = await this.energyApp.useAppliances().list();
99
+ for (const appliance of appliances) {
100
+ // Try to get network devices if available
101
+ const networkDevices = await this.getNetworkDevicesForAppliance(appliance);
102
+ this.updateCache(appliance, networkDevices[0]);
103
+ }
104
+ }
105
+ /**
106
+ * Gets network devices associated with an appliance.
107
+ * @param appliance The appliance
108
+ * @returns Array of network devices
109
+ */
110
+ async getNetworkDevicesForAppliance(appliance) {
111
+ const devices = [];
112
+ const networkDevices = await this.energyApp.useNetworkDevices().getDevices();
113
+ for (const deviceId of appliance.networkDeviceIds) {
114
+ const device = networkDevices.find(d => d.id === deviceId);
115
+ if (device) {
116
+ devices.push(device);
117
+ }
118
+ }
119
+ return devices;
120
+ }
121
+ /**
122
+ * Finds appliances by their identifier using the configured strategy.
123
+ * @param identifier The identifier to search for
124
+ * @returns Array of matching appliances
125
+ */
126
+ async findByIdentifier(identifier) {
127
+ // Check cache first
128
+ const cachedIds = this.identifierToApplianceId.get(identifier);
129
+ if (cachedIds && cachedIds.size > 0) {
130
+ const appliances = [];
131
+ for (const id of cachedIds) {
132
+ const appliance = this.applianceCache.get(id);
133
+ if (appliance) {
134
+ appliances.push(appliance);
135
+ }
136
+ }
137
+ if (appliances.length > 0) {
138
+ return appliances;
139
+ }
140
+ }
141
+ // Search in all appliances
142
+ const allAppliances = await this.energyApp.useAppliances().list();
143
+ const matches = [];
144
+ for (const appliance of allAppliances) {
145
+ const networkDevices = await this.getNetworkDevicesForAppliance(appliance);
146
+ const extractedId = this.config.identifierStrategy.extract(appliance, networkDevices[0]);
147
+ if (extractedId === identifier) {
148
+ matches.push(appliance);
149
+ this.updateCache(appliance, networkDevices[0]);
150
+ }
151
+ }
152
+ return matches;
153
+ }
154
+ /**
155
+ * Finds an appliance using multiple strategies.
156
+ * @param searchValue The value to search for
157
+ * @param strategies Array of strategies to try
158
+ * @returns The first matching result or undefined
159
+ */
160
+ async findWithStrategies(searchValue, strategies) {
161
+ const allAppliances = await this.energyApp.useAppliances().list();
162
+ for (const strategy of strategies) {
163
+ for (const appliance of allAppliances) {
164
+ const networkDevices = await this.getNetworkDevicesForAppliance(appliance);
165
+ const identifier = strategy.extract(appliance, networkDevices[0]);
166
+ if (identifier === searchValue) {
167
+ return {
168
+ appliance,
169
+ identifier,
170
+ strategy: strategy.name
171
+ };
172
+ }
173
+ }
174
+ }
175
+ return undefined;
176
+ }
177
+ /**
178
+ * Gets all appliances of a specific type.
179
+ * @param type The appliance type to filter by
180
+ * @returns Array of appliances of the specified type
181
+ */
182
+ async getAppliancesByType(type) {
183
+ const allAppliances = await this.energyApp.useAppliances().list();
184
+ return allAppliances.filter(a => a.type === type);
185
+ }
186
+ /**
187
+ * Updates the state of an appliance.
188
+ * @param applianceId The ID of the appliance to update
189
+ * @param connectionType The new Connection type
190
+ * @param state The new state
191
+ */
192
+ async updateApplianceState(applianceId, connectionType, state) {
193
+ try {
194
+ const appliance = await this.energyApp.useAppliances().getById(applianceId);
195
+ if (appliance) {
196
+ const updatedAppliance = {
197
+ ...appliance,
198
+ metadata: { ...appliance.metadata, connectionType, state }
199
+ };
200
+ await this.energyApp.useAppliances().save(updatedAppliance, applianceId);
201
+ // Update cache
202
+ appliance.metadata = { ...appliance.metadata, connectionType, state };
203
+ this.applianceCache.set(applianceId, appliance);
204
+ console.log(`Updated appliance ${applianceId} state to ${state}`);
205
+ }
206
+ }
207
+ catch (error) {
208
+ console.error(`Failed to update appliance state for ${applianceId}: ${error}`);
209
+ throw error;
210
+ }
211
+ }
212
+ /**
213
+ * Updates metadata for an appliance.
214
+ * @param applianceId The ID of the appliance
215
+ * @param metadata The metadata to update
216
+ */
217
+ async updateApplianceMetadata(applianceId, metadata) {
218
+ try {
219
+ const appliance = await this.energyApp.useAppliances().getById(applianceId);
220
+ if (appliance) {
221
+ const updatedAppliance = {
222
+ ...appliance,
223
+ metadata: {
224
+ ...appliance.metadata,
225
+ ...metadata
226
+ }
227
+ };
228
+ await this.energyApp.useAppliances().save(updatedAppliance, applianceId);
229
+ // Update cache
230
+ appliance.metadata = { ...appliance.metadata, ...metadata };
231
+ this.applianceCache.set(applianceId, appliance);
232
+ console.log(`Updated metadata for appliance ${applianceId}`);
233
+ }
234
+ }
235
+ catch (error) {
236
+ console.error(`Failed to update metadata for appliance ${applianceId}: ${error}`);
237
+ throw error;
238
+ }
239
+ }
240
+ /**
241
+ * Removes an appliance by its ID.
242
+ * @param applianceId The ID of the appliance to remove
243
+ */
244
+ async removeAppliance(applianceId) {
245
+ try {
246
+ await this.energyApp.useAppliances().removeById(applianceId);
247
+ // Clean up cache
248
+ const appliance = this.applianceCache.get(applianceId);
249
+ if (appliance) {
250
+ this.applianceCache.delete(applianceId);
251
+ // Clean up identifier mapping
252
+ for (const [identifier, ids] of this.identifierToApplianceId.entries()) {
253
+ ids.delete(applianceId);
254
+ if (ids.size === 0) {
255
+ this.identifierToApplianceId.delete(identifier);
256
+ }
257
+ }
258
+ }
259
+ console.log(`Removed appliance ${applianceId}`);
260
+ }
261
+ catch (error) {
262
+ console.error(`Failed to remove appliance ${applianceId}: ${error}`);
263
+ throw error;
264
+ }
265
+ }
266
+ /**
267
+ * Removes all appliances matching an identifier.
268
+ * @param identifier The identifier to match
269
+ * @returns The number of appliances removed
270
+ */
271
+ async removeAppliancesByIdentifier(identifier) {
272
+ const appliances = await this.findByIdentifier(identifier);
273
+ let removedCount = 0;
274
+ for (const appliance of appliances) {
275
+ try {
276
+ await this.removeAppliance(appliance.id);
277
+ removedCount++;
278
+ }
279
+ catch (error) {
280
+ console.error(`Failed to remove appliance ${appliance.id}: ${error}`);
281
+ }
282
+ }
283
+ return removedCount;
284
+ }
285
+ /**
286
+ * Sets all appliances with a given identifier to offline state.
287
+ * @param identifier The identifier to match
288
+ * @returns The number of appliances updated
289
+ */
290
+ async setAppliancesOfflineByIdentifier(identifier) {
291
+ const appliances = await this.findByIdentifier(identifier);
292
+ let updatedCount = 0;
293
+ for (const appliance of appliances) {
294
+ try {
295
+ await this.updateApplianceState(appliance.id, appliance.metadata?.connectionType || enyo_appliance_js_1.EnyoApplianceConnectionType.Connector, enyo_appliance_js_1.EnyoApplianceStateEnum.Offline);
296
+ updatedCount++;
297
+ }
298
+ catch (error) {
299
+ console.error(`Failed to set appliance ${appliance.id} offline: ${error}`);
300
+ }
301
+ }
302
+ return updatedCount;
303
+ }
304
+ /**
305
+ * Sets all appliances with a given identifier to online (connected) state.
306
+ * @param identifier The identifier to match
307
+ * @returns The number of appliances updated
308
+ */
309
+ async setAppliancesOnlineByIdentifier(identifier) {
310
+ const appliances = await this.findByIdentifier(identifier);
311
+ let updatedCount = 0;
312
+ for (const appliance of appliances) {
313
+ try {
314
+ await this.updateApplianceState(appliance.id, appliance.metadata?.connectionType || enyo_appliance_js_1.EnyoApplianceConnectionType.Connector, enyo_appliance_js_1.EnyoApplianceStateEnum.Connected);
315
+ updatedCount++;
316
+ }
317
+ catch (error) {
318
+ console.error(`Failed to set appliance ${appliance.id} online: ${error}`);
319
+ }
320
+ }
321
+ return updatedCount;
322
+ }
323
+ /**
324
+ * Performs a bulk update on multiple appliances.
325
+ * @param updates Array of updates to perform
326
+ * @returns Results of the bulk update operation
327
+ */
328
+ async bulkUpdate(updates) {
329
+ const succeeded = [];
330
+ const failed = [];
331
+ for (const update of updates) {
332
+ try {
333
+ const appliance = await this.energyApp.useAppliances().getById(update.applianceId);
334
+ if (appliance) {
335
+ const updatedAppliance = {
336
+ ...appliance,
337
+ ...update.data
338
+ };
339
+ await this.energyApp.useAppliances().save(updatedAppliance, update.applianceId);
340
+ succeeded.push(update.applianceId);
341
+ // Update cache
342
+ Object.assign(appliance, update.data);
343
+ this.applianceCache.set(update.applianceId, appliance);
344
+ }
345
+ else {
346
+ failed.push(update.applianceId);
347
+ }
348
+ }
349
+ catch (error) {
350
+ console.error(`Bulk update failed for ${update.applianceId}: ${error}`);
351
+ failed.push(update.applianceId);
352
+ }
353
+ }
354
+ console.log(`Bulk update completed: ${succeeded.length} succeeded, ${failed.length} failed`);
355
+ return { succeeded, failed };
356
+ }
357
+ /**
358
+ * Gets statistics about the managed appliances.
359
+ * @returns Statistics object
360
+ */
361
+ async getStatistics() {
362
+ const appliances = await this.energyApp.useAppliances().list();
363
+ const byType = {};
364
+ const byState = {};
365
+ for (const appliance of appliances) {
366
+ // Count by type
367
+ byType[appliance.type] = (byType[appliance.type] ?? 0) + 1;
368
+ // Count by state
369
+ const state = appliance.metadata?.state ?? 'unknown';
370
+ byState[state] = (byState[state] ?? 0) + 1;
371
+ }
372
+ return {
373
+ total: appliances.length,
374
+ byType,
375
+ byState,
376
+ cached: this.applianceCache.size
377
+ };
378
+ }
379
+ /**
380
+ * Changes the identifier strategy at runtime.
381
+ * @param strategy The new strategy to use
382
+ * @param rebuildCache Whether to rebuild the cache with the new strategy
383
+ */
384
+ async setIdentifierStrategy(strategy, rebuildCache = true) {
385
+ this.config.identifierStrategy = strategy;
386
+ console.log(`Changed identifier strategy to: ${strategy.name}`);
387
+ if (rebuildCache) {
388
+ await this.refreshCache();
389
+ }
390
+ }
391
+ /**
392
+ * Gets the current identifier strategy.
393
+ * @returns The current identifier strategy
394
+ */
395
+ getIdentifierStrategy() {
396
+ return this.config.identifierStrategy;
397
+ }
398
+ }
399
+ exports.ApplianceManager = ApplianceManager;
@@ -0,0 +1,191 @@
1
+ import type { EnergyApp } from "../../index.cjs";
2
+ import type { EnyoNetworkDevice } from "../../types/enyo-network-device.cjs";
3
+ import { EnyoAppliance, EnyoApplianceConnectionType, EnyoApplianceMetadata, EnyoApplianceName, EnyoApplianceStateEnum, EnyoApplianceTopology, EnyoApplianceTypeEnum } from "../../types/enyo-appliance.cjs";
4
+ import type { EnyoChargerApplianceMetadata } from "../../types/enyo-charger-appliance.cjs";
5
+ import type { EnyoHeatpumpApplianceMetadata } from "../../types/enyo-heatpump-appliance.cjs";
6
+ import type { EnyoBatteryApplianceMetadata } from "../../types/enyo-battery-appliance.cjs";
7
+ import type { EnyoInverterApplianceMetadata } from "../../types/enyo-inverter-appliance.cjs";
8
+ import type { EnyoMeterAppliance } from "../../types/enyo-meter-appliance.cjs";
9
+ import { IdentifierStrategy } from "./identifier-strategies.cjs";
10
+ /**
11
+ * Configuration for creating or updating an appliance.
12
+ */
13
+ export interface ApplianceConfig {
14
+ /** Name of the appliance in different languages */
15
+ name: EnyoApplianceName[];
16
+ /** Type of the appliance */
17
+ type: EnyoApplianceTypeEnum;
18
+ /** Network device(s) associated with the appliance */
19
+ networkDevices?: EnyoNetworkDevice[];
20
+ /** Appliance metadata */
21
+ metadata?: Partial<EnyoApplianceMetadata>;
22
+ /** Topology information */
23
+ topology?: EnyoApplianceTopology;
24
+ /** Type-specific metadata based on appliance type */
25
+ typeMetadata?: {
26
+ meter?: EnyoMeterAppliance;
27
+ inverter?: EnyoInverterApplianceMetadata;
28
+ charger?: EnyoChargerApplianceMetadata;
29
+ heatpump?: EnyoHeatpumpApplianceMetadata;
30
+ battery?: EnyoBatteryApplianceMetadata;
31
+ };
32
+ }
33
+ /**
34
+ * Configuration options for the ApplianceManager.
35
+ */
36
+ export interface ApplianceManagerConfig {
37
+ /** Strategy for identifying appliances. Defaults to NetworkDeviceIdStrategy */
38
+ identifierStrategy?: IdentifierStrategy;
39
+ /** Whether to auto-update appliance metadata on changes. Defaults to true */
40
+ autoUpdateMetadata?: boolean;
41
+ /** Whether to log operations. Defaults to true */
42
+ enableLogging?: boolean;
43
+ /** Default connection type for new appliances. Defaults to Connector */
44
+ defaultConnectionType?: EnyoApplianceConnectionType;
45
+ /** Default vendor name when not specified */
46
+ defaultVendorName?: string;
47
+ }
48
+ /**
49
+ * Result of a find operation.
50
+ */
51
+ export interface FindResult {
52
+ /** The found appliance */
53
+ appliance: EnyoAppliance;
54
+ /** The identifier that matched */
55
+ identifier: string;
56
+ /** The strategy that found the match */
57
+ strategy: string;
58
+ }
59
+ /**
60
+ * Manages appliances in the energy system with configurable identification strategies.
61
+ * Provides comprehensive CRUD operations and state management for energy appliances.
62
+ */
63
+ export declare class ApplianceManager {
64
+ private energyApp;
65
+ private applianceCache;
66
+ private identifierToApplianceId;
67
+ private config;
68
+ /**
69
+ * Creates a new ApplianceManager instance.
70
+ * @param energyApp The EnergyApp instance to use for API calls
71
+ * @param config Configuration options for the manager
72
+ */
73
+ constructor(energyApp: EnergyApp, config?: ApplianceManagerConfig);
74
+ /**
75
+ * Creates or updates an appliance with the given configuration.
76
+ * @param config The appliance configuration
77
+ * @param existingApplianceId Optional ID of an existing appliance to update
78
+ * @returns The ID of the created or updated appliance
79
+ */
80
+ createOrUpdateAppliance(config: ApplianceConfig, existingApplianceId?: string): Promise<string>;
81
+ /**
82
+ * Updates the internal cache with an appliance.
83
+ * @param appliance The appliance to cache
84
+ * @param networkDevice Optional network device for identifier extraction
85
+ */
86
+ protected updateCache(appliance: EnyoAppliance, networkDevice?: EnyoNetworkDevice): void;
87
+ /**
88
+ * Clears the internal cache.
89
+ */
90
+ clearCache(): void;
91
+ /**
92
+ * Refreshes the cache with all appliances from the system.
93
+ */
94
+ refreshCache(): Promise<void>;
95
+ /**
96
+ * Gets network devices associated with an appliance.
97
+ * @param appliance The appliance
98
+ * @returns Array of network devices
99
+ */
100
+ private getNetworkDevicesForAppliance;
101
+ /**
102
+ * Finds appliances by their identifier using the configured strategy.
103
+ * @param identifier The identifier to search for
104
+ * @returns Array of matching appliances
105
+ */
106
+ findByIdentifier(identifier: string): Promise<EnyoAppliance[]>;
107
+ /**
108
+ * Finds an appliance using multiple strategies.
109
+ * @param searchValue The value to search for
110
+ * @param strategies Array of strategies to try
111
+ * @returns The first matching result or undefined
112
+ */
113
+ findWithStrategies(searchValue: string, strategies: IdentifierStrategy[]): Promise<FindResult | undefined>;
114
+ /**
115
+ * Gets all appliances of a specific type.
116
+ * @param type The appliance type to filter by
117
+ * @returns Array of appliances of the specified type
118
+ */
119
+ getAppliancesByType(type: EnyoApplianceTypeEnum): Promise<EnyoAppliance[]>;
120
+ /**
121
+ * Updates the state of an appliance.
122
+ * @param applianceId The ID of the appliance to update
123
+ * @param connectionType The new Connection type
124
+ * @param state The new state
125
+ */
126
+ updateApplianceState(applianceId: string, connectionType: EnyoApplianceConnectionType, state: EnyoApplianceStateEnum): Promise<void>;
127
+ /**
128
+ * Updates metadata for an appliance.
129
+ * @param applianceId The ID of the appliance
130
+ * @param metadata The metadata to update
131
+ */
132
+ updateApplianceMetadata(applianceId: string, metadata: Partial<EnyoApplianceMetadata> & {
133
+ connectionType: EnyoApplianceConnectionType;
134
+ }): Promise<void>;
135
+ /**
136
+ * Removes an appliance by its ID.
137
+ * @param applianceId The ID of the appliance to remove
138
+ */
139
+ removeAppliance(applianceId: string): Promise<void>;
140
+ /**
141
+ * Removes all appliances matching an identifier.
142
+ * @param identifier The identifier to match
143
+ * @returns The number of appliances removed
144
+ */
145
+ removeAppliancesByIdentifier(identifier: string): Promise<number>;
146
+ /**
147
+ * Sets all appliances with a given identifier to offline state.
148
+ * @param identifier The identifier to match
149
+ * @returns The number of appliances updated
150
+ */
151
+ setAppliancesOfflineByIdentifier(identifier: string): Promise<number>;
152
+ /**
153
+ * Sets all appliances with a given identifier to online (connected) state.
154
+ * @param identifier The identifier to match
155
+ * @returns The number of appliances updated
156
+ */
157
+ setAppliancesOnlineByIdentifier(identifier: string): Promise<number>;
158
+ /**
159
+ * Performs a bulk update on multiple appliances.
160
+ * @param updates Array of updates to perform
161
+ * @returns Results of the bulk update operation
162
+ */
163
+ bulkUpdate(updates: Array<{
164
+ applianceId: string;
165
+ data: Partial<Omit<EnyoAppliance, 'id'>>;
166
+ }>): Promise<{
167
+ succeeded: string[];
168
+ failed: string[];
169
+ }>;
170
+ /**
171
+ * Gets statistics about the managed appliances.
172
+ * @returns Statistics object
173
+ */
174
+ getStatistics(): Promise<{
175
+ total: number;
176
+ byType: Record<string, number>;
177
+ byState: Record<string, number>;
178
+ cached: number;
179
+ }>;
180
+ /**
181
+ * Changes the identifier strategy at runtime.
182
+ * @param strategy The new strategy to use
183
+ * @param rebuildCache Whether to rebuild the cache with the new strategy
184
+ */
185
+ setIdentifierStrategy(strategy: IdentifierStrategy, rebuildCache?: boolean): Promise<void>;
186
+ /**
187
+ * Gets the current identifier strategy.
188
+ * @returns The current identifier strategy
189
+ */
190
+ getIdentifierStrategy(): IdentifierStrategy;
191
+ }