@enyo-energy/energy-app-sdk 0.0.44 → 0.0.46
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/dist/cjs/implementations/appliances/appliance-manager.cjs +27 -10
- package/dist/cjs/implementations/appliances/appliance-manager.d.cts +8 -4
- package/dist/cjs/packages/energy-app-secret-manager.d.cts +1 -1
- package/dist/cjs/types/enyo-inverter-appliance.d.cts +5 -0
- package/dist/cjs/version.cjs +1 -1
- package/dist/cjs/version.d.cts +1 -1
- package/dist/implementations/appliances/appliance-manager.d.ts +8 -4
- package/dist/implementations/appliances/appliance-manager.js +27 -10
- package/dist/packages/energy-app-secret-manager.d.ts +1 -1
- package/dist/types/enyo-inverter-appliance.d.ts +5 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -179,6 +179,27 @@ class ApplianceManager {
|
|
|
179
179
|
}
|
|
180
180
|
return matches;
|
|
181
181
|
}
|
|
182
|
+
/**
|
|
183
|
+
* Gets an appliance by its unique ID.
|
|
184
|
+
* @param applianceId The ID of the appliance to retrieve
|
|
185
|
+
* @returns The appliance if found, null otherwise
|
|
186
|
+
*/
|
|
187
|
+
async findApplianceById(applianceId) {
|
|
188
|
+
try {
|
|
189
|
+
const appliance = await this.energyApp.useAppliances().getById(applianceId);
|
|
190
|
+
if (appliance) {
|
|
191
|
+
// Update cache with the fetched appliance
|
|
192
|
+
this.updateCache(appliance);
|
|
193
|
+
return appliance;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
catch (error) {
|
|
197
|
+
if (this.config.enableLogging) {
|
|
198
|
+
console.error(`Failed to get appliance ${applianceId}: ${error}`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
182
203
|
/**
|
|
183
204
|
* Finds an appliance using multiple strategies.
|
|
184
205
|
* @param searchValue The value to search for
|
|
@@ -240,28 +261,24 @@ class ApplianceManager {
|
|
|
240
261
|
/**
|
|
241
262
|
* Updates metadata for an appliance.
|
|
242
263
|
* @param applianceId The ID of the appliance
|
|
243
|
-
* @param
|
|
264
|
+
* @param attributes The attributes to update
|
|
244
265
|
*/
|
|
245
|
-
async
|
|
266
|
+
async updateAppliance(applianceId, attributes) {
|
|
246
267
|
try {
|
|
247
268
|
const appliance = await this.energyApp.useAppliances().getById(applianceId);
|
|
248
269
|
if (appliance) {
|
|
249
270
|
const updatedAppliance = {
|
|
250
271
|
...appliance,
|
|
251
|
-
|
|
252
|
-
...appliance.metadata,
|
|
253
|
-
...metadata
|
|
254
|
-
}
|
|
272
|
+
...attributes
|
|
255
273
|
};
|
|
256
274
|
await this.energyApp.useAppliances().save(updatedAppliance, applianceId);
|
|
257
275
|
// Update cache
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
console.log(`Updated metadata for appliance ${applianceId}`);
|
|
276
|
+
this.applianceCache.set(applianceId, { id: applianceId, ...updatedAppliance });
|
|
277
|
+
console.log(`Updated appliance ${applianceId}`);
|
|
261
278
|
}
|
|
262
279
|
}
|
|
263
280
|
catch (error) {
|
|
264
|
-
console.error(`Failed to update
|
|
281
|
+
console.error(`Failed to update appliance ${applianceId}: ${error}`);
|
|
265
282
|
throw error;
|
|
266
283
|
}
|
|
267
284
|
}
|
|
@@ -109,6 +109,12 @@ export declare class ApplianceManager {
|
|
|
109
109
|
* @returns Array of matching appliances
|
|
110
110
|
*/
|
|
111
111
|
findByIdentifier(identifier: string): Promise<EnyoAppliance[]>;
|
|
112
|
+
/**
|
|
113
|
+
* Gets an appliance by its unique ID.
|
|
114
|
+
* @param applianceId The ID of the appliance to retrieve
|
|
115
|
+
* @returns The appliance if found, null otherwise
|
|
116
|
+
*/
|
|
117
|
+
findApplianceById(applianceId: string): Promise<EnyoAppliance | null>;
|
|
112
118
|
/**
|
|
113
119
|
* Finds an appliance using multiple strategies.
|
|
114
120
|
* @param searchValue The value to search for
|
|
@@ -132,11 +138,9 @@ export declare class ApplianceManager {
|
|
|
132
138
|
/**
|
|
133
139
|
* Updates metadata for an appliance.
|
|
134
140
|
* @param applianceId The ID of the appliance
|
|
135
|
-
* @param
|
|
141
|
+
* @param attributes The attributes to update
|
|
136
142
|
*/
|
|
137
|
-
|
|
138
|
-
connectionType: EnyoApplianceConnectionType;
|
|
139
|
-
}): Promise<void>;
|
|
143
|
+
updateAppliance(applianceId: string, attributes: Partial<EnyoAppliance>): Promise<void>;
|
|
140
144
|
/**
|
|
141
145
|
* Removes an appliance by its ID.
|
|
142
146
|
* @param applianceId The ID of the appliance to remove
|
|
@@ -79,5 +79,5 @@ export interface EnergyAppSecretManager {
|
|
|
79
79
|
* });
|
|
80
80
|
* ```
|
|
81
81
|
*/
|
|
82
|
-
saveSecret<T
|
|
82
|
+
saveSecret<T>(secretName: string, encryptionKey: string, secret: T): Promise<void>;
|
|
83
83
|
}
|
package/dist/cjs/version.cjs
CHANGED
|
@@ -9,7 +9,7 @@ exports.getSdkVersion = getSdkVersion;
|
|
|
9
9
|
/**
|
|
10
10
|
* Current version of the enyo Energy App SDK.
|
|
11
11
|
*/
|
|
12
|
-
exports.SDK_VERSION = '0.0.
|
|
12
|
+
exports.SDK_VERSION = '0.0.46';
|
|
13
13
|
/**
|
|
14
14
|
* Gets the current SDK version.
|
|
15
15
|
* @returns The semantic version string of the SDK
|
package/dist/cjs/version.d.cts
CHANGED
|
@@ -109,6 +109,12 @@ export declare class ApplianceManager {
|
|
|
109
109
|
* @returns Array of matching appliances
|
|
110
110
|
*/
|
|
111
111
|
findByIdentifier(identifier: string): Promise<EnyoAppliance[]>;
|
|
112
|
+
/**
|
|
113
|
+
* Gets an appliance by its unique ID.
|
|
114
|
+
* @param applianceId The ID of the appliance to retrieve
|
|
115
|
+
* @returns The appliance if found, null otherwise
|
|
116
|
+
*/
|
|
117
|
+
findApplianceById(applianceId: string): Promise<EnyoAppliance | null>;
|
|
112
118
|
/**
|
|
113
119
|
* Finds an appliance using multiple strategies.
|
|
114
120
|
* @param searchValue The value to search for
|
|
@@ -132,11 +138,9 @@ export declare class ApplianceManager {
|
|
|
132
138
|
/**
|
|
133
139
|
* Updates metadata for an appliance.
|
|
134
140
|
* @param applianceId The ID of the appliance
|
|
135
|
-
* @param
|
|
141
|
+
* @param attributes The attributes to update
|
|
136
142
|
*/
|
|
137
|
-
|
|
138
|
-
connectionType: EnyoApplianceConnectionType;
|
|
139
|
-
}): Promise<void>;
|
|
143
|
+
updateAppliance(applianceId: string, attributes: Partial<EnyoAppliance>): Promise<void>;
|
|
140
144
|
/**
|
|
141
145
|
* Removes an appliance by its ID.
|
|
142
146
|
* @param applianceId The ID of the appliance to remove
|
|
@@ -176,6 +176,27 @@ export class ApplianceManager {
|
|
|
176
176
|
}
|
|
177
177
|
return matches;
|
|
178
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Gets an appliance by its unique ID.
|
|
181
|
+
* @param applianceId The ID of the appliance to retrieve
|
|
182
|
+
* @returns The appliance if found, null otherwise
|
|
183
|
+
*/
|
|
184
|
+
async findApplianceById(applianceId) {
|
|
185
|
+
try {
|
|
186
|
+
const appliance = await this.energyApp.useAppliances().getById(applianceId);
|
|
187
|
+
if (appliance) {
|
|
188
|
+
// Update cache with the fetched appliance
|
|
189
|
+
this.updateCache(appliance);
|
|
190
|
+
return appliance;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
catch (error) {
|
|
194
|
+
if (this.config.enableLogging) {
|
|
195
|
+
console.error(`Failed to get appliance ${applianceId}: ${error}`);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return null;
|
|
199
|
+
}
|
|
179
200
|
/**
|
|
180
201
|
* Finds an appliance using multiple strategies.
|
|
181
202
|
* @param searchValue The value to search for
|
|
@@ -237,28 +258,24 @@ export class ApplianceManager {
|
|
|
237
258
|
/**
|
|
238
259
|
* Updates metadata for an appliance.
|
|
239
260
|
* @param applianceId The ID of the appliance
|
|
240
|
-
* @param
|
|
261
|
+
* @param attributes The attributes to update
|
|
241
262
|
*/
|
|
242
|
-
async
|
|
263
|
+
async updateAppliance(applianceId, attributes) {
|
|
243
264
|
try {
|
|
244
265
|
const appliance = await this.energyApp.useAppliances().getById(applianceId);
|
|
245
266
|
if (appliance) {
|
|
246
267
|
const updatedAppliance = {
|
|
247
268
|
...appliance,
|
|
248
|
-
|
|
249
|
-
...appliance.metadata,
|
|
250
|
-
...metadata
|
|
251
|
-
}
|
|
269
|
+
...attributes
|
|
252
270
|
};
|
|
253
271
|
await this.energyApp.useAppliances().save(updatedAppliance, applianceId);
|
|
254
272
|
// Update cache
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
console.log(`Updated metadata for appliance ${applianceId}`);
|
|
273
|
+
this.applianceCache.set(applianceId, { id: applianceId, ...updatedAppliance });
|
|
274
|
+
console.log(`Updated appliance ${applianceId}`);
|
|
258
275
|
}
|
|
259
276
|
}
|
|
260
277
|
catch (error) {
|
|
261
|
-
console.error(`Failed to update
|
|
278
|
+
console.error(`Failed to update appliance ${applianceId}: ${error}`);
|
|
262
279
|
throw error;
|
|
263
280
|
}
|
|
264
281
|
}
|
|
@@ -79,5 +79,5 @@ export interface EnergyAppSecretManager {
|
|
|
79
79
|
* });
|
|
80
80
|
* ```
|
|
81
81
|
*/
|
|
82
|
-
saveSecret<T
|
|
82
|
+
saveSecret<T>(secretName: string, encryptionKey: string, secret: T): Promise<void>;
|
|
83
83
|
}
|
package/dist/version.d.ts
CHANGED
package/dist/version.js
CHANGED