@enyo-energy/energy-app-sdk 0.0.95 → 0.0.97

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/README.md CHANGED
@@ -20,6 +20,7 @@ The official TypeScript SDK for building Energy Apps on the enyo platform. Creat
20
20
  - [Data Management](#data-management)
21
21
  - [Energy Resources](#energy-resources)
22
22
  - [User Features](#user-features)
23
+ - [App Intelligence](#app-intelligence)
23
24
  - [Advanced Modbus Integration](#advanced-modbus-integration)
24
25
  - [Examples](#examples)
25
26
  - [Basic Energy App](#basic-energy-app)
@@ -615,6 +616,61 @@ await notifications.sendNotification({
615
616
  });
616
617
  ```
617
618
 
619
+ ### App Intelligence
620
+
621
+ #### `useLearningPhase(): EnergyAppLearningPhase`
622
+
623
+ Track and manage learning phases — periods where an app or a specific appliance is calibrating, gathering data, or optimizing its behavior:
624
+
625
+ ```typescript
626
+ const learningPhase = energyApp.useLearningPhase();
627
+
628
+ // Register a package-wide learning phase
629
+ const phaseId = await learningPhase.registerLearningPhase({
630
+ name: 'consumption-pattern-analysis',
631
+ reason: [
632
+ { language: 'en', value: 'Analyzing energy consumption patterns' },
633
+ { language: 'de', value: 'Analyse der Energieverbrauchsmuster' }
634
+ ],
635
+ description: [
636
+ { language: 'en', value: 'The system is learning your household energy consumption patterns to optimize scheduling.' },
637
+ { language: 'de', value: 'Das System lernt Ihre Energieverbrauchsmuster, um die Planung zu optimieren.' }
638
+ ]
639
+ });
640
+
641
+ // Register a learning phase for a specific appliance
642
+ const heatpumpPhaseId = await learningPhase.registerLearningPhase({
643
+ name: 'heating-curve-optimization',
644
+ applianceId: 'heatpump-001',
645
+ reason: [
646
+ { language: 'en', value: 'Optimizing heating curve' },
647
+ { language: 'de', value: 'Optimierung der Heizkurve' }
648
+ ]
649
+ });
650
+
651
+ // Check if a learning phase is still active
652
+ const isLearning = await learningPhase.isInLearningPhase(heatpumpPhaseId);
653
+ console.log(`Heatpump is ${isLearning ? 'still learning' : 'done learning'}`);
654
+
655
+ // Check if a learning phase is completed
656
+ const isDone = await learningPhase.isLearningPhaseCompleted(heatpumpPhaseId);
657
+
658
+ // Get all learning phases with their status and duration
659
+ const allPhases = await learningPhase.getLearningPhases();
660
+ for (const phase of allPhases) {
661
+ console.log(`${phase.name}: ${phase.durationInHours}h, active: ${!phase.endDate}`);
662
+ }
663
+
664
+ // Get learning phases for a specific appliance
665
+ const heatpumpPhases = await learningPhase.getLearningPhasesByApplianceId('heatpump-001');
666
+
667
+ // Complete a learning phase
668
+ await learningPhase.completeLearningPhase(heatpumpPhaseId);
669
+
670
+ // Remove a learning phase
671
+ await learningPhase.removeLearningPhase(phaseId);
672
+ ```
673
+
618
674
  ## Advanced Modbus Integration
619
675
 
620
676
  The SDK includes a powerful, vendor-agnostic Modbus implementation for energy management systems. This allows you to connect to any Modbus-enabled device through configuration without code changes.
@@ -27,6 +27,7 @@ import { EnergyAppModbusRtu } from "./packages/energy-app-modbus-rtu.cjs";
27
27
  import { EnergyAppEebus } from "./packages/energy-app-eebus.cjs";
28
28
  import { EnergyAppMqtt } from "./packages/energy-app-mqtt.cjs";
29
29
  import { EnergyAppDiagnostics } from "./packages/energy-app-diagnostics.cjs";
30
+ import { EnergyAppLearningPhase } from "./packages/energy-app-learning-phase.cjs";
30
31
  export declare enum EnergyAppStateEnum {
31
32
  Launching = "launching",
32
33
  Running = "running",
@@ -109,4 +110,6 @@ export interface EnyoEnergyAppSdk {
109
110
  useMqtt: () => EnergyAppMqtt;
110
111
  /** Get the Diagnostics API for submitting energy manager diagnostics data */
111
112
  useDiagnostics: () => EnergyAppDiagnostics;
113
+ /** Get the Learning Phase API for registering and tracking learning phases */
114
+ useLearningPhase: () => EnergyAppLearningPhase;
112
115
  }
@@ -165,7 +165,7 @@ export declare class ApplianceManager {
165
165
  * @param applianceId The ID of the appliance
166
166
  * @param attributes The attributes to update
167
167
  */
168
- updateAppliance(applianceId: string, attributes: Partial<EnyoAppliance>): Promise<void>;
168
+ updateAppliance(applianceId: string, attributes: Partial<PartialEnyoAppliance>): Promise<void>;
169
169
  /**
170
170
  * Removes an appliance by its ID.
171
171
  * @param applianceId The ID of the appliance to remove
@@ -218,3 +218,31 @@ export declare class ApplianceManager {
218
218
  */
219
219
  dispose(): void;
220
220
  }
221
+ export interface PartialEnyoAppliance {
222
+ /** Unique identifier for the appliance */
223
+ id: string;
224
+ /** Name of the appliance in different supported languages */
225
+ name: EnyoApplianceName[];
226
+ /** Type/category of the appliance */
227
+ type: EnyoApplianceTypeEnum;
228
+ /** network device IDs associated with the appliance */
229
+ networkDeviceIds: string[];
230
+ /** Optional Metadata of the Appliance */
231
+ metadata?: Partial<EnyoApplianceMetadata>;
232
+ /** Topology Information of the appliance */
233
+ topology?: EnyoApplianceTopology;
234
+ /** Optional Metadata of the Appliance if of type Meter */
235
+ meter?: Partial<EnyoMeterAppliance>;
236
+ /** Optional Metadata of the Appliance if of type Inverter */
237
+ inverter?: Partial<EnyoInverterApplianceMetadata>;
238
+ /** Optional Metadata of the Appliance if of type Charger */
239
+ charger?: Partial<EnyoChargerApplianceMetadata>;
240
+ /** Optional Metadata of the Appliance if of type Heatpump */
241
+ heatpump?: Partial<EnyoHeatpumpApplianceMetadata>;
242
+ /** Optional Metadata of the Appliance if of type Battery */
243
+ battery?: Partial<EnyoBatteryApplianceMetadata>;
244
+ /** Optional Metadata of the Appliance if of type TemperatureSensor */
245
+ temperatureSensor?: Partial<EnyoTemperatureSensorApplianceMetadata>;
246
+ /** Optional custom name for the appliance, defined by the user */
247
+ customName?: string;
248
+ }
@@ -53,6 +53,8 @@ __exportStar(require("./types/enyo-mqtt.cjs"), exports);
53
53
  __exportStar(require("./packages/energy-app-mqtt.cjs"), exports);
54
54
  __exportStar(require("./types/enyo-diagnostics.cjs"), exports);
55
55
  __exportStar(require("./packages/energy-app-diagnostics.cjs"), exports);
56
+ __exportStar(require("./types/enyo-learning-phase.cjs"), exports);
57
+ __exportStar(require("./packages/energy-app-learning-phase.cjs"), exports);
56
58
  class EnergyApp {
57
59
  energyAppSdk;
58
60
  constructor() {
@@ -254,6 +256,15 @@ class EnergyApp {
254
256
  useDiagnostics() {
255
257
  return this.energyAppSdk.useDiagnostics();
256
258
  }
259
+ /**
260
+ * Gets the Learning Phase API for registering and tracking learning phases.
261
+ * Provides methods to register new learning phases, check their status,
262
+ * and retrieve learning phase history for the package or specific appliances.
263
+ * @returns The Learning Phase API instance
264
+ */
265
+ useLearningPhase() {
266
+ return this.energyAppSdk.useLearningPhase();
267
+ }
257
268
  /**
258
269
  * Gets the current SDK version.
259
270
  * @returns The semantic version string of the SDK
@@ -28,6 +28,7 @@ import { EnergyAppModbusRtu } from "./packages/energy-app-modbus-rtu.cjs";
28
28
  import { EnergyAppEebus } from "./packages/energy-app-eebus.cjs";
29
29
  import { EnergyAppMqtt } from "./packages/energy-app-mqtt.cjs";
30
30
  import { EnergyAppDiagnostics } from "./packages/energy-app-diagnostics.cjs";
31
+ import { EnergyAppLearningPhase } from "./packages/energy-app-learning-phase.cjs";
31
32
  export * from './energy-app-appliance-type.enum.cjs';
32
33
  export * from './energy-app-package-definition.cjs';
33
34
  export * from './version.cjs';
@@ -65,6 +66,8 @@ export * from './types/enyo-mqtt.cjs';
65
66
  export * from './packages/energy-app-mqtt.cjs';
66
67
  export * from './types/enyo-diagnostics.cjs';
67
68
  export * from './packages/energy-app-diagnostics.cjs';
69
+ export * from './types/enyo-learning-phase.cjs';
70
+ export * from './packages/energy-app-learning-phase.cjs';
68
71
  export declare class EnergyApp implements EnyoEnergyAppSdk {
69
72
  private readonly energyAppSdk;
70
73
  constructor();
@@ -181,6 +184,13 @@ export declare class EnergyApp implements EnyoEnergyAppSdk {
181
184
  * @returns The Diagnostics API instance
182
185
  */
183
186
  useDiagnostics(): EnergyAppDiagnostics;
187
+ /**
188
+ * Gets the Learning Phase API for registering and tracking learning phases.
189
+ * Provides methods to register new learning phases, check their status,
190
+ * and retrieve learning phase history for the package or specific appliances.
191
+ * @returns The Learning Phase API instance
192
+ */
193
+ useLearningPhase(): EnergyAppLearningPhase;
184
194
  /**
185
195
  * Gets the current SDK version.
186
196
  * @returns The semantic version string of the SDK
@@ -1,4 +1,5 @@
1
1
  import { EnergyManagerFeatureEnum, EnergyManagerInfo } from "../types/enyo-energy-manager.cjs";
2
+ import { EnyoDiagnosticsControlPlan } from "../types/enyo-diagnostics.cjs";
2
3
  /**
3
4
  * Interface for retrieving energy manager information and capabilities.
4
5
  * The energy manager is responsible for optimizing energy usage across appliances.
@@ -23,4 +24,33 @@ export interface EnergyAppEnergyManager {
23
24
  getEnergyManagerInfo(): Promise<EnergyManagerInfo | null>;
24
25
  /** Only for Energy Manager Energy Apps: Register the features which are provided*/
25
26
  registerFeatures(features: EnergyManagerFeatureEnum[]): void;
27
+ /**
28
+ * Only for Energy Manager Energy Apps: Publishes the energy manager's control plan forecast.
29
+ * The control plan contains time-slotted commands for each appliance along with
30
+ * estimated costs and grid power values.
31
+ *
32
+ * @param controlPlan - The time-slotted control plan with commands for each appliance
33
+ * and estimated costs
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const energyManager = energyApp.useEnergyManager();
38
+ * energyManager.publishForecast({
39
+ * commands: [
40
+ * {
41
+ * type: EnyoApplianceTypeEnum.Storage,
42
+ * applianceId: 'battery-1',
43
+ * decision: BatteryDecision.Charge,
44
+ * powerW: 3000,
45
+ * durationInMinutes: 60
46
+ * }
47
+ * ],
48
+ * generatedAtIso: new Date().toISOString(),
49
+ * totalEstimatedCostEur: 3.50,
50
+ * totalGridImportKwh: 12.5,
51
+ * totalGridExportKwh: 4.2
52
+ * });
53
+ * ```
54
+ */
55
+ publishForecast(controlPlan: EnyoDiagnosticsControlPlan): void;
26
56
  }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,88 @@
1
+ import { EnyoLearningPhase, EnyoLearningPhaseRegistration } from "../types/enyo-learning-phase.cjs";
2
+ /**
3
+ * Interface for managing learning phases within Energy App packages.
4
+ * Learning phases represent periods where an app or a specific appliance is calibrating,
5
+ * gathering data, or optimizing its behavior (e.g., a heatpump learning optimal heating curves
6
+ * after installation, or an energy manager learning consumption patterns).
7
+ *
8
+ * Learning phases can be package-wide (no applianceId) or tied to a specific appliance.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const learningPhase = energyApp.useLearningPhase();
13
+ *
14
+ * // Register a learning phase for a specific appliance
15
+ * const phaseId = await learningPhase.registerLearningPhase({
16
+ * name: 'heating-curve-optimization',
17
+ * applianceId: 'heatpump-001',
18
+ * reason: [
19
+ * { language: 'en', value: 'Optimizing heating curve' },
20
+ * { language: 'de', value: 'Optimierung der Heizkurve' }
21
+ * ],
22
+ * description: [
23
+ * { language: 'en', value: 'The heatpump is learning the optimal heating curve for your home.' },
24
+ * { language: 'de', value: 'Die Wärmepumpe lernt die optimale Heizkurve für Ihr Zuhause.' }
25
+ * ]
26
+ * });
27
+ *
28
+ * // Check if still learning
29
+ * const isLearning = await learningPhase.isInLearningPhase(phaseId);
30
+ *
31
+ * // Complete the learning phase
32
+ * await learningPhase.completeLearningPhase(phaseId);
33
+ * ```
34
+ */
35
+ export interface EnergyAppLearningPhase {
36
+ /**
37
+ * Registers a new learning phase and starts tracking it.
38
+ * The learning phase starts immediately upon registration.
39
+ *
40
+ * @param registration - The learning phase registration details including name, optional applianceId, reason, and description
41
+ * @returns Promise that resolves to the unique ID of the newly created learning phase
42
+ */
43
+ registerLearningPhase(registration: EnyoLearningPhaseRegistration): Promise<string>;
44
+ /**
45
+ * Marks a learning phase as completed by setting its end date.
46
+ *
47
+ * @param learningPhaseId - The unique ID of the learning phase to complete
48
+ * @returns Promise that resolves when the learning phase is marked as completed
49
+ */
50
+ completeLearningPhase(learningPhaseId: string): Promise<void>;
51
+ /**
52
+ * Checks whether a specific learning phase is still active (not yet completed).
53
+ *
54
+ * @param learningPhaseId - The unique ID of the learning phase to check
55
+ * @returns Promise that resolves to `true` if the learning phase is still active, `false` otherwise
56
+ */
57
+ isInLearningPhase(learningPhaseId: string): Promise<boolean>;
58
+ /**
59
+ * Checks whether a specific learning phase has been completed.
60
+ *
61
+ * @param learningPhaseId - The unique ID of the learning phase to check
62
+ * @returns Promise that resolves to `true` if the learning phase is completed, `false` otherwise
63
+ */
64
+ isLearningPhaseCompleted(learningPhaseId: string): Promise<boolean>;
65
+ /**
66
+ * Retrieves all learning phases registered by this package.
67
+ * Returns both active and completed learning phases with their current duration.
68
+ *
69
+ * @returns Promise that resolves to an array of all learning phases
70
+ */
71
+ getLearningPhases(): Promise<EnyoLearningPhase[]>;
72
+ /**
73
+ * Retrieves all learning phases associated with a specific appliance.
74
+ * Returns both active and completed learning phases for the given appliance.
75
+ *
76
+ * @param applianceId - The appliance ID to filter learning phases by
77
+ * @returns Promise that resolves to an array of learning phases for the specified appliance
78
+ */
79
+ getLearningPhasesByApplianceId(applianceId: string): Promise<EnyoLearningPhase[]>;
80
+ /**
81
+ * Removes a learning phase from the system.
82
+ * This permanently deletes the learning phase record regardless of its active/completed status.
83
+ *
84
+ * @param learningPhaseId - The unique ID of the learning phase to remove
85
+ * @returns Promise that resolves when the learning phase is removed
86
+ */
87
+ removeLearningPhase(learningPhaseId: string): Promise<void>;
88
+ }
@@ -20,11 +20,11 @@ export type DhwState = "charging" | "discharging" | "idle";
20
20
  /** Heating circuit state. */
21
21
  export type HeatingState = "active" | "idle";
22
22
  /** Battery control decision issued by the energy manager. */
23
- export type BatteryDecision = "normal" | "block_discharge" | "charge_from_grid" | "force_discharge";
23
+ export type BatteryDecision = "block_discharge" | "charge_from_grid" | "force_discharge";
24
24
  /** EV charging control decision issued by the energy manager. */
25
- export type EvDecision = "normal" | "charging_pv" | "charging_grid" | "charging_mixed";
25
+ export type EvDecision = "charging_pv" | "charging_grid" | "charging_mixed";
26
26
  /** Heat pump control decision issued by the energy manager. */
27
- export type HeatpumpDecision = "normal" | "dhw_boost" | "room_overheating" | "buffer_tank_boost";
27
+ export type HeatpumpDecision = "dhw_boost" | "room_overheating" | "buffer_tank_boost";
28
28
  export interface EnyoDiagnosticsForecastInverterAppliance {
29
29
  type: EnyoApplianceTypeEnum.Inverter;
30
30
  applianceId: string;
@@ -56,6 +56,7 @@ export interface EnyoDiagnosticsForecastHeatpumpAppliance {
56
56
  applianceId: string;
57
57
  values: {
58
58
  powerW?: number;
59
+ flowTemperatureC?: number;
59
60
  roomTemperatureC?: number;
60
61
  dhwTemperatureC?: number;
61
62
  bufferTankTemperatureC?: number;
@@ -158,10 +159,14 @@ export interface EnyoDiagnosticsStorageControlCommand {
158
159
  type: EnyoApplianceTypeEnum.Storage;
159
160
  /** Target appliance ID. */
160
161
  applianceId: string;
162
+ /** ISO 8601 timestamp when this command starts. */
163
+ timestampIso: string;
161
164
  /** Control decision for the battery. */
162
165
  decision: BatteryDecision;
163
166
  /** Target power in Watts. */
164
167
  powerW: number;
168
+ /** Duration of this command in minutes. */
169
+ durationInMinutes: number;
165
170
  /** Optional target state of charge as a percentage. */
166
171
  targetSoCPercent?: number;
167
172
  }
@@ -170,10 +175,14 @@ export interface EnyoDiagnosticsChargerControlCommand {
170
175
  type: EnyoApplianceTypeEnum.Charger;
171
176
  /** Target appliance ID. */
172
177
  applianceId: string;
178
+ /** ISO 8601 timestamp when this command starts. */
179
+ timestampIso: string;
173
180
  /** Control decision for the EV charger. */
174
181
  decision: EvDecision;
175
182
  /** Charging power in Watts. */
176
183
  chargingPowerW: number;
184
+ /** Duration of this command in minutes. */
185
+ durationInMinutes: number;
177
186
  /** Optional charging limit in kW. */
178
187
  chargingLimitKw?: number;
179
188
  }
@@ -182,30 +191,23 @@ export interface EnyoDiagnosticsHeatpumpControlCommand {
182
191
  type: EnyoApplianceTypeEnum.Heatpump;
183
192
  /** Target appliance ID. */
184
193
  applianceId: string;
194
+ /** ISO 8601 timestamp when this command starts. */
195
+ timestampIso: string;
185
196
  /** Control decision for the heat pump. */
186
197
  decision: HeatpumpDecision;
187
198
  /** Target power in Watts. */
188
199
  powerW: number;
200
+ /** Duration of this command in minutes. */
201
+ durationInMinutes: number;
189
202
  /** Optional target temperature in Celsius. */
190
203
  targetTempC?: number;
191
204
  }
192
205
  /** Union of all appliance control command types. */
193
206
  export type EnyoDiagnosticsApplianceControlCommand = EnyoDiagnosticsStorageControlCommand | EnyoDiagnosticsChargerControlCommand | EnyoDiagnosticsHeatpumpControlCommand;
194
- /** A single time slot in a control plan with its associated commands. */
195
- export interface EnyoDiagnosticsControlSlot {
196
- /** ISO 8601 timestamp for this slot. */
197
- timestampIso: string;
198
- /** Commands to execute during this slot. */
199
- commands: EnyoDiagnosticsApplianceControlCommand[];
200
- /** Estimated cost for this slot in EUR. */
201
- estimatedSlotCostEur: number;
202
- /** Estimated grid power in Watts for this slot. */
203
- estimatedGridPowerW: number;
204
- }
205
- /** Complete control plan with time-slotted commands and cost estimates. */
207
+ /** Complete control plan with duration-based commands and cost estimates. */
206
208
  export interface EnyoDiagnosticsControlPlan {
207
- /** Time-slotted command sequence. */
208
- slots: EnyoDiagnosticsControlSlot[];
209
+ /** Sequence of appliance control commands, each with its own duration. */
210
+ commands: EnyoDiagnosticsApplianceControlCommand[];
209
211
  /** ISO 8601 timestamp when this plan was generated. */
210
212
  generatedAtIso: string;
211
213
  /** Total estimated cost in EUR. */
@@ -5,8 +5,6 @@ var EnyoHeatpumpApplianceAvailableFeaturesEnum;
5
5
  (function (EnyoHeatpumpApplianceAvailableFeaturesEnum) {
6
6
  /** If the heatpump is capable of domestic hot water*/
7
7
  EnyoHeatpumpApplianceAvailableFeaturesEnum["DomesticHotWater"] = "DomesticHotWater";
8
- /** If the heatpump is capable of domestic hot water boost to use more pv energy*/
9
- EnyoHeatpumpApplianceAvailableFeaturesEnum["DomesticHotWaterBoost"] = "DomesticHotWaterBoost";
10
8
  /** If the heatpump has a heating rod*/
11
9
  EnyoHeatpumpApplianceAvailableFeaturesEnum["HeatingRod"] = "HeatingRod";
12
10
  /** If the heatpump supports room overheating via heating circuits */
@@ -1,8 +1,6 @@
1
1
  export declare enum EnyoHeatpumpApplianceAvailableFeaturesEnum {
2
2
  /** If the heatpump is capable of domestic hot water*/
3
3
  DomesticHotWater = "DomesticHotWater",
4
- /** If the heatpump is capable of domestic hot water boost to use more pv energy*/
5
- DomesticHotWaterBoost = "DomesticHotWaterBoost",
6
4
  /** If the heatpump has a heating rod*/
7
5
  HeatingRod = "HeatingRod",
8
6
  /** If the heatpump supports room overheating via heating circuits */
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,37 @@
1
+ import { EnyoPackageConfigurationTranslatedValue } from "./enyo-settings.cjs";
2
+ /**
3
+ * Represents a learning phase tracked by an Energy App.
4
+ * A learning phase is a period during which an app or appliance is calibrating,
5
+ * gathering data, or optimizing its behavior (e.g., a heatpump learning optimal heating curves).
6
+ */
7
+ export interface EnyoLearningPhase {
8
+ /** Unique identifier of the learning phase */
9
+ id: string;
10
+ /** Name identifying the learning phase (e.g., 'heating-curve-optimization') */
11
+ name: string;
12
+ /** Optional appliance ID — if omitted, the learning phase applies to the entire package */
13
+ applianceId?: string;
14
+ /** Optional translated reason explaining why this learning phase is needed */
15
+ reason?: EnyoPackageConfigurationTranslatedValue[];
16
+ /** Optional translated description providing details about what is being learned */
17
+ description?: EnyoPackageConfigurationTranslatedValue[];
18
+ /** ISO 8601 date string of when the learning phase started */
19
+ startDate: string;
20
+ /** ISO 8601 date string of when the learning phase ended — undefined if still active */
21
+ endDate?: string;
22
+ /** Duration of the learning phase in hours (elapsed if active, total if completed) */
23
+ durationInHours: number;
24
+ }
25
+ /**
26
+ * Registration parameters for creating a new learning phase.
27
+ */
28
+ export interface EnyoLearningPhaseRegistration {
29
+ /** Name identifying the learning phase (e.g., 'heating-curve-optimization') */
30
+ name: string;
31
+ /** Optional appliance ID — if omitted, the learning phase applies to the entire package */
32
+ applianceId?: string;
33
+ /** Optional translated reason explaining why this learning phase is needed */
34
+ reason?: EnyoPackageConfigurationTranslatedValue[];
35
+ /** Optional translated description providing details about what is being learned */
36
+ description?: EnyoPackageConfigurationTranslatedValue[];
37
+ }
@@ -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.95';
12
+ exports.SDK_VERSION = '0.0.97';
13
13
  /**
14
14
  * Gets the current SDK version.
15
15
  * @returns The semantic version string of the SDK
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * Current version of the enyo Energy App SDK.
7
7
  */
8
- export declare const SDK_VERSION = "0.0.95";
8
+ export declare const SDK_VERSION = "0.0.97";
9
9
  /**
10
10
  * Gets the current SDK version.
11
11
  * @returns The semantic version string of the SDK
@@ -27,6 +27,7 @@ import { EnergyAppModbusRtu } from "./packages/energy-app-modbus-rtu.js";
27
27
  import { EnergyAppEebus } from "./packages/energy-app-eebus.js";
28
28
  import { EnergyAppMqtt } from "./packages/energy-app-mqtt.js";
29
29
  import { EnergyAppDiagnostics } from "./packages/energy-app-diagnostics.js";
30
+ import { EnergyAppLearningPhase } from "./packages/energy-app-learning-phase.js";
30
31
  export declare enum EnergyAppStateEnum {
31
32
  Launching = "launching",
32
33
  Running = "running",
@@ -109,4 +110,6 @@ export interface EnyoEnergyAppSdk {
109
110
  useMqtt: () => EnergyAppMqtt;
110
111
  /** Get the Diagnostics API for submitting energy manager diagnostics data */
111
112
  useDiagnostics: () => EnergyAppDiagnostics;
113
+ /** Get the Learning Phase API for registering and tracking learning phases */
114
+ useLearningPhase: () => EnergyAppLearningPhase;
112
115
  }
@@ -165,7 +165,7 @@ export declare class ApplianceManager {
165
165
  * @param applianceId The ID of the appliance
166
166
  * @param attributes The attributes to update
167
167
  */
168
- updateAppliance(applianceId: string, attributes: Partial<EnyoAppliance>): Promise<void>;
168
+ updateAppliance(applianceId: string, attributes: Partial<PartialEnyoAppliance>): Promise<void>;
169
169
  /**
170
170
  * Removes an appliance by its ID.
171
171
  * @param applianceId The ID of the appliance to remove
@@ -218,3 +218,31 @@ export declare class ApplianceManager {
218
218
  */
219
219
  dispose(): void;
220
220
  }
221
+ export interface PartialEnyoAppliance {
222
+ /** Unique identifier for the appliance */
223
+ id: string;
224
+ /** Name of the appliance in different supported languages */
225
+ name: EnyoApplianceName[];
226
+ /** Type/category of the appliance */
227
+ type: EnyoApplianceTypeEnum;
228
+ /** network device IDs associated with the appliance */
229
+ networkDeviceIds: string[];
230
+ /** Optional Metadata of the Appliance */
231
+ metadata?: Partial<EnyoApplianceMetadata>;
232
+ /** Topology Information of the appliance */
233
+ topology?: EnyoApplianceTopology;
234
+ /** Optional Metadata of the Appliance if of type Meter */
235
+ meter?: Partial<EnyoMeterAppliance>;
236
+ /** Optional Metadata of the Appliance if of type Inverter */
237
+ inverter?: Partial<EnyoInverterApplianceMetadata>;
238
+ /** Optional Metadata of the Appliance if of type Charger */
239
+ charger?: Partial<EnyoChargerApplianceMetadata>;
240
+ /** Optional Metadata of the Appliance if of type Heatpump */
241
+ heatpump?: Partial<EnyoHeatpumpApplianceMetadata>;
242
+ /** Optional Metadata of the Appliance if of type Battery */
243
+ battery?: Partial<EnyoBatteryApplianceMetadata>;
244
+ /** Optional Metadata of the Appliance if of type TemperatureSensor */
245
+ temperatureSensor?: Partial<EnyoTemperatureSensorApplianceMetadata>;
246
+ /** Optional custom name for the appliance, defined by the user */
247
+ customName?: string;
248
+ }
package/dist/index.d.ts CHANGED
@@ -28,6 +28,7 @@ import { EnergyAppModbusRtu } from "./packages/energy-app-modbus-rtu.js";
28
28
  import { EnergyAppEebus } from "./packages/energy-app-eebus.js";
29
29
  import { EnergyAppMqtt } from "./packages/energy-app-mqtt.js";
30
30
  import { EnergyAppDiagnostics } from "./packages/energy-app-diagnostics.js";
31
+ import { EnergyAppLearningPhase } from "./packages/energy-app-learning-phase.js";
31
32
  export * from './energy-app-appliance-type.enum.js';
32
33
  export * from './energy-app-package-definition.js';
33
34
  export * from './version.js';
@@ -65,6 +66,8 @@ export * from './types/enyo-mqtt.js';
65
66
  export * from './packages/energy-app-mqtt.js';
66
67
  export * from './types/enyo-diagnostics.js';
67
68
  export * from './packages/energy-app-diagnostics.js';
69
+ export * from './types/enyo-learning-phase.js';
70
+ export * from './packages/energy-app-learning-phase.js';
68
71
  export declare class EnergyApp implements EnyoEnergyAppSdk {
69
72
  private readonly energyAppSdk;
70
73
  constructor();
@@ -181,6 +184,13 @@ export declare class EnergyApp implements EnyoEnergyAppSdk {
181
184
  * @returns The Diagnostics API instance
182
185
  */
183
186
  useDiagnostics(): EnergyAppDiagnostics;
187
+ /**
188
+ * Gets the Learning Phase API for registering and tracking learning phases.
189
+ * Provides methods to register new learning phases, check their status,
190
+ * and retrieve learning phase history for the package or specific appliances.
191
+ * @returns The Learning Phase API instance
192
+ */
193
+ useLearningPhase(): EnergyAppLearningPhase;
184
194
  /**
185
195
  * Gets the current SDK version.
186
196
  * @returns The semantic version string of the SDK
package/dist/index.js CHANGED
@@ -36,6 +36,8 @@ export * from './types/enyo-mqtt.js';
36
36
  export * from './packages/energy-app-mqtt.js';
37
37
  export * from './types/enyo-diagnostics.js';
38
38
  export * from './packages/energy-app-diagnostics.js';
39
+ export * from './types/enyo-learning-phase.js';
40
+ export * from './packages/energy-app-learning-phase.js';
39
41
  export class EnergyApp {
40
42
  energyAppSdk;
41
43
  constructor() {
@@ -237,6 +239,15 @@ export class EnergyApp {
237
239
  useDiagnostics() {
238
240
  return this.energyAppSdk.useDiagnostics();
239
241
  }
242
+ /**
243
+ * Gets the Learning Phase API for registering and tracking learning phases.
244
+ * Provides methods to register new learning phases, check their status,
245
+ * and retrieve learning phase history for the package or specific appliances.
246
+ * @returns The Learning Phase API instance
247
+ */
248
+ useLearningPhase() {
249
+ return this.energyAppSdk.useLearningPhase();
250
+ }
240
251
  /**
241
252
  * Gets the current SDK version.
242
253
  * @returns The semantic version string of the SDK
@@ -1,4 +1,5 @@
1
1
  import { EnergyManagerFeatureEnum, EnergyManagerInfo } from "../types/enyo-energy-manager.js";
2
+ import { EnyoDiagnosticsControlPlan } from "../types/enyo-diagnostics.js";
2
3
  /**
3
4
  * Interface for retrieving energy manager information and capabilities.
4
5
  * The energy manager is responsible for optimizing energy usage across appliances.
@@ -23,4 +24,33 @@ export interface EnergyAppEnergyManager {
23
24
  getEnergyManagerInfo(): Promise<EnergyManagerInfo | null>;
24
25
  /** Only for Energy Manager Energy Apps: Register the features which are provided*/
25
26
  registerFeatures(features: EnergyManagerFeatureEnum[]): void;
27
+ /**
28
+ * Only for Energy Manager Energy Apps: Publishes the energy manager's control plan forecast.
29
+ * The control plan contains time-slotted commands for each appliance along with
30
+ * estimated costs and grid power values.
31
+ *
32
+ * @param controlPlan - The time-slotted control plan with commands for each appliance
33
+ * and estimated costs
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * const energyManager = energyApp.useEnergyManager();
38
+ * energyManager.publishForecast({
39
+ * commands: [
40
+ * {
41
+ * type: EnyoApplianceTypeEnum.Storage,
42
+ * applianceId: 'battery-1',
43
+ * decision: BatteryDecision.Charge,
44
+ * powerW: 3000,
45
+ * durationInMinutes: 60
46
+ * }
47
+ * ],
48
+ * generatedAtIso: new Date().toISOString(),
49
+ * totalEstimatedCostEur: 3.50,
50
+ * totalGridImportKwh: 12.5,
51
+ * totalGridExportKwh: 4.2
52
+ * });
53
+ * ```
54
+ */
55
+ publishForecast(controlPlan: EnyoDiagnosticsControlPlan): void;
26
56
  }
@@ -0,0 +1,88 @@
1
+ import { EnyoLearningPhase, EnyoLearningPhaseRegistration } from "../types/enyo-learning-phase.js";
2
+ /**
3
+ * Interface for managing learning phases within Energy App packages.
4
+ * Learning phases represent periods where an app or a specific appliance is calibrating,
5
+ * gathering data, or optimizing its behavior (e.g., a heatpump learning optimal heating curves
6
+ * after installation, or an energy manager learning consumption patterns).
7
+ *
8
+ * Learning phases can be package-wide (no applianceId) or tied to a specific appliance.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * const learningPhase = energyApp.useLearningPhase();
13
+ *
14
+ * // Register a learning phase for a specific appliance
15
+ * const phaseId = await learningPhase.registerLearningPhase({
16
+ * name: 'heating-curve-optimization',
17
+ * applianceId: 'heatpump-001',
18
+ * reason: [
19
+ * { language: 'en', value: 'Optimizing heating curve' },
20
+ * { language: 'de', value: 'Optimierung der Heizkurve' }
21
+ * ],
22
+ * description: [
23
+ * { language: 'en', value: 'The heatpump is learning the optimal heating curve for your home.' },
24
+ * { language: 'de', value: 'Die Wärmepumpe lernt die optimale Heizkurve für Ihr Zuhause.' }
25
+ * ]
26
+ * });
27
+ *
28
+ * // Check if still learning
29
+ * const isLearning = await learningPhase.isInLearningPhase(phaseId);
30
+ *
31
+ * // Complete the learning phase
32
+ * await learningPhase.completeLearningPhase(phaseId);
33
+ * ```
34
+ */
35
+ export interface EnergyAppLearningPhase {
36
+ /**
37
+ * Registers a new learning phase and starts tracking it.
38
+ * The learning phase starts immediately upon registration.
39
+ *
40
+ * @param registration - The learning phase registration details including name, optional applianceId, reason, and description
41
+ * @returns Promise that resolves to the unique ID of the newly created learning phase
42
+ */
43
+ registerLearningPhase(registration: EnyoLearningPhaseRegistration): Promise<string>;
44
+ /**
45
+ * Marks a learning phase as completed by setting its end date.
46
+ *
47
+ * @param learningPhaseId - The unique ID of the learning phase to complete
48
+ * @returns Promise that resolves when the learning phase is marked as completed
49
+ */
50
+ completeLearningPhase(learningPhaseId: string): Promise<void>;
51
+ /**
52
+ * Checks whether a specific learning phase is still active (not yet completed).
53
+ *
54
+ * @param learningPhaseId - The unique ID of the learning phase to check
55
+ * @returns Promise that resolves to `true` if the learning phase is still active, `false` otherwise
56
+ */
57
+ isInLearningPhase(learningPhaseId: string): Promise<boolean>;
58
+ /**
59
+ * Checks whether a specific learning phase has been completed.
60
+ *
61
+ * @param learningPhaseId - The unique ID of the learning phase to check
62
+ * @returns Promise that resolves to `true` if the learning phase is completed, `false` otherwise
63
+ */
64
+ isLearningPhaseCompleted(learningPhaseId: string): Promise<boolean>;
65
+ /**
66
+ * Retrieves all learning phases registered by this package.
67
+ * Returns both active and completed learning phases with their current duration.
68
+ *
69
+ * @returns Promise that resolves to an array of all learning phases
70
+ */
71
+ getLearningPhases(): Promise<EnyoLearningPhase[]>;
72
+ /**
73
+ * Retrieves all learning phases associated with a specific appliance.
74
+ * Returns both active and completed learning phases for the given appliance.
75
+ *
76
+ * @param applianceId - The appliance ID to filter learning phases by
77
+ * @returns Promise that resolves to an array of learning phases for the specified appliance
78
+ */
79
+ getLearningPhasesByApplianceId(applianceId: string): Promise<EnyoLearningPhase[]>;
80
+ /**
81
+ * Removes a learning phase from the system.
82
+ * This permanently deletes the learning phase record regardless of its active/completed status.
83
+ *
84
+ * @param learningPhaseId - The unique ID of the learning phase to remove
85
+ * @returns Promise that resolves when the learning phase is removed
86
+ */
87
+ removeLearningPhase(learningPhaseId: string): Promise<void>;
88
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -20,11 +20,11 @@ export type DhwState = "charging" | "discharging" | "idle";
20
20
  /** Heating circuit state. */
21
21
  export type HeatingState = "active" | "idle";
22
22
  /** Battery control decision issued by the energy manager. */
23
- export type BatteryDecision = "normal" | "block_discharge" | "charge_from_grid" | "force_discharge";
23
+ export type BatteryDecision = "block_discharge" | "charge_from_grid" | "force_discharge";
24
24
  /** EV charging control decision issued by the energy manager. */
25
- export type EvDecision = "normal" | "charging_pv" | "charging_grid" | "charging_mixed";
25
+ export type EvDecision = "charging_pv" | "charging_grid" | "charging_mixed";
26
26
  /** Heat pump control decision issued by the energy manager. */
27
- export type HeatpumpDecision = "normal" | "dhw_boost" | "room_overheating" | "buffer_tank_boost";
27
+ export type HeatpumpDecision = "dhw_boost" | "room_overheating" | "buffer_tank_boost";
28
28
  export interface EnyoDiagnosticsForecastInverterAppliance {
29
29
  type: EnyoApplianceTypeEnum.Inverter;
30
30
  applianceId: string;
@@ -56,6 +56,7 @@ export interface EnyoDiagnosticsForecastHeatpumpAppliance {
56
56
  applianceId: string;
57
57
  values: {
58
58
  powerW?: number;
59
+ flowTemperatureC?: number;
59
60
  roomTemperatureC?: number;
60
61
  dhwTemperatureC?: number;
61
62
  bufferTankTemperatureC?: number;
@@ -158,10 +159,14 @@ export interface EnyoDiagnosticsStorageControlCommand {
158
159
  type: EnyoApplianceTypeEnum.Storage;
159
160
  /** Target appliance ID. */
160
161
  applianceId: string;
162
+ /** ISO 8601 timestamp when this command starts. */
163
+ timestampIso: string;
161
164
  /** Control decision for the battery. */
162
165
  decision: BatteryDecision;
163
166
  /** Target power in Watts. */
164
167
  powerW: number;
168
+ /** Duration of this command in minutes. */
169
+ durationInMinutes: number;
165
170
  /** Optional target state of charge as a percentage. */
166
171
  targetSoCPercent?: number;
167
172
  }
@@ -170,10 +175,14 @@ export interface EnyoDiagnosticsChargerControlCommand {
170
175
  type: EnyoApplianceTypeEnum.Charger;
171
176
  /** Target appliance ID. */
172
177
  applianceId: string;
178
+ /** ISO 8601 timestamp when this command starts. */
179
+ timestampIso: string;
173
180
  /** Control decision for the EV charger. */
174
181
  decision: EvDecision;
175
182
  /** Charging power in Watts. */
176
183
  chargingPowerW: number;
184
+ /** Duration of this command in minutes. */
185
+ durationInMinutes: number;
177
186
  /** Optional charging limit in kW. */
178
187
  chargingLimitKw?: number;
179
188
  }
@@ -182,30 +191,23 @@ export interface EnyoDiagnosticsHeatpumpControlCommand {
182
191
  type: EnyoApplianceTypeEnum.Heatpump;
183
192
  /** Target appliance ID. */
184
193
  applianceId: string;
194
+ /** ISO 8601 timestamp when this command starts. */
195
+ timestampIso: string;
185
196
  /** Control decision for the heat pump. */
186
197
  decision: HeatpumpDecision;
187
198
  /** Target power in Watts. */
188
199
  powerW: number;
200
+ /** Duration of this command in minutes. */
201
+ durationInMinutes: number;
189
202
  /** Optional target temperature in Celsius. */
190
203
  targetTempC?: number;
191
204
  }
192
205
  /** Union of all appliance control command types. */
193
206
  export type EnyoDiagnosticsApplianceControlCommand = EnyoDiagnosticsStorageControlCommand | EnyoDiagnosticsChargerControlCommand | EnyoDiagnosticsHeatpumpControlCommand;
194
- /** A single time slot in a control plan with its associated commands. */
195
- export interface EnyoDiagnosticsControlSlot {
196
- /** ISO 8601 timestamp for this slot. */
197
- timestampIso: string;
198
- /** Commands to execute during this slot. */
199
- commands: EnyoDiagnosticsApplianceControlCommand[];
200
- /** Estimated cost for this slot in EUR. */
201
- estimatedSlotCostEur: number;
202
- /** Estimated grid power in Watts for this slot. */
203
- estimatedGridPowerW: number;
204
- }
205
- /** Complete control plan with time-slotted commands and cost estimates. */
207
+ /** Complete control plan with duration-based commands and cost estimates. */
206
208
  export interface EnyoDiagnosticsControlPlan {
207
- /** Time-slotted command sequence. */
208
- slots: EnyoDiagnosticsControlSlot[];
209
+ /** Sequence of appliance control commands, each with its own duration. */
210
+ commands: EnyoDiagnosticsApplianceControlCommand[];
209
211
  /** ISO 8601 timestamp when this plan was generated. */
210
212
  generatedAtIso: string;
211
213
  /** Total estimated cost in EUR. */
@@ -1,8 +1,6 @@
1
1
  export declare enum EnyoHeatpumpApplianceAvailableFeaturesEnum {
2
2
  /** If the heatpump is capable of domestic hot water*/
3
3
  DomesticHotWater = "DomesticHotWater",
4
- /** If the heatpump is capable of domestic hot water boost to use more pv energy*/
5
- DomesticHotWaterBoost = "DomesticHotWaterBoost",
6
4
  /** If the heatpump has a heating rod*/
7
5
  HeatingRod = "HeatingRod",
8
6
  /** If the heatpump supports room overheating via heating circuits */
@@ -2,8 +2,6 @@ export var EnyoHeatpumpApplianceAvailableFeaturesEnum;
2
2
  (function (EnyoHeatpumpApplianceAvailableFeaturesEnum) {
3
3
  /** If the heatpump is capable of domestic hot water*/
4
4
  EnyoHeatpumpApplianceAvailableFeaturesEnum["DomesticHotWater"] = "DomesticHotWater";
5
- /** If the heatpump is capable of domestic hot water boost to use more pv energy*/
6
- EnyoHeatpumpApplianceAvailableFeaturesEnum["DomesticHotWaterBoost"] = "DomesticHotWaterBoost";
7
5
  /** If the heatpump has a heating rod*/
8
6
  EnyoHeatpumpApplianceAvailableFeaturesEnum["HeatingRod"] = "HeatingRod";
9
7
  /** If the heatpump supports room overheating via heating circuits */
@@ -0,0 +1,37 @@
1
+ import { EnyoPackageConfigurationTranslatedValue } from "./enyo-settings.js";
2
+ /**
3
+ * Represents a learning phase tracked by an Energy App.
4
+ * A learning phase is a period during which an app or appliance is calibrating,
5
+ * gathering data, or optimizing its behavior (e.g., a heatpump learning optimal heating curves).
6
+ */
7
+ export interface EnyoLearningPhase {
8
+ /** Unique identifier of the learning phase */
9
+ id: string;
10
+ /** Name identifying the learning phase (e.g., 'heating-curve-optimization') */
11
+ name: string;
12
+ /** Optional appliance ID — if omitted, the learning phase applies to the entire package */
13
+ applianceId?: string;
14
+ /** Optional translated reason explaining why this learning phase is needed */
15
+ reason?: EnyoPackageConfigurationTranslatedValue[];
16
+ /** Optional translated description providing details about what is being learned */
17
+ description?: EnyoPackageConfigurationTranslatedValue[];
18
+ /** ISO 8601 date string of when the learning phase started */
19
+ startDate: string;
20
+ /** ISO 8601 date string of when the learning phase ended — undefined if still active */
21
+ endDate?: string;
22
+ /** Duration of the learning phase in hours (elapsed if active, total if completed) */
23
+ durationInHours: number;
24
+ }
25
+ /**
26
+ * Registration parameters for creating a new learning phase.
27
+ */
28
+ export interface EnyoLearningPhaseRegistration {
29
+ /** Name identifying the learning phase (e.g., 'heating-curve-optimization') */
30
+ name: string;
31
+ /** Optional appliance ID — if omitted, the learning phase applies to the entire package */
32
+ applianceId?: string;
33
+ /** Optional translated reason explaining why this learning phase is needed */
34
+ reason?: EnyoPackageConfigurationTranslatedValue[];
35
+ /** Optional translated description providing details about what is being learned */
36
+ description?: EnyoPackageConfigurationTranslatedValue[];
37
+ }
@@ -0,0 +1 @@
1
+ export {};
package/dist/version.d.ts CHANGED
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * Current version of the enyo Energy App SDK.
7
7
  */
8
- export declare const SDK_VERSION = "0.0.95";
8
+ export declare const SDK_VERSION = "0.0.97";
9
9
  /**
10
10
  * Gets the current SDK version.
11
11
  * @returns The semantic version string of the SDK
package/dist/version.js CHANGED
@@ -5,7 +5,7 @@
5
5
  /**
6
6
  * Current version of the enyo Energy App SDK.
7
7
  */
8
- export const SDK_VERSION = '0.0.95';
8
+ export const SDK_VERSION = '0.0.97';
9
9
  /**
10
10
  * Gets the current SDK version.
11
11
  * @returns The semantic version string of the SDK
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@enyo-energy/energy-app-sdk",
3
- "version": "0.0.95",
3
+ "version": "0.0.97",
4
4
  "description": "enyo Energy App SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",