@enyo-energy/energy-app-sdk 0.0.59 → 0.0.60

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 (43) hide show
  1. package/dist/cjs/energy-app-permission.type.cjs +6 -0
  2. package/dist/cjs/energy-app-permission.type.d.cts +8 -2
  3. package/dist/cjs/enyo-energy-app-sdk.d.cts +10 -1
  4. package/dist/cjs/implementations/data-bus/data-bus-command-handler.cjs +140 -0
  5. package/dist/cjs/implementations/data-bus/data-bus-command-handler.d.cts +114 -0
  6. package/dist/cjs/index.cjs +32 -0
  7. package/dist/cjs/index.d.cts +29 -0
  8. package/dist/cjs/packages/energy-app-pv-forecasting.cjs +2 -0
  9. package/dist/cjs/packages/energy-app-pv-forecasting.d.cts +63 -0
  10. package/dist/cjs/packages/energy-app-pv-system.cjs +2 -0
  11. package/dist/cjs/packages/energy-app-pv-system.d.cts +70 -0
  12. package/dist/cjs/packages/energy-app-weather-forecasting.cjs +2 -0
  13. package/dist/cjs/packages/energy-app-weather-forecasting.d.cts +89 -0
  14. package/dist/cjs/types/enyo-data-bus-value.cjs +19 -1
  15. package/dist/cjs/types/enyo-data-bus-value.d.cts +93 -3
  16. package/dist/cjs/types/enyo-forecasting.cjs +25 -0
  17. package/dist/cjs/types/enyo-forecasting.d.cts +110 -0
  18. package/dist/cjs/types/enyo-pv-system.cjs +26 -0
  19. package/dist/cjs/types/enyo-pv-system.d.cts +70 -0
  20. package/dist/cjs/version.cjs +1 -1
  21. package/dist/cjs/version.d.cts +1 -1
  22. package/dist/energy-app-permission.type.d.ts +8 -2
  23. package/dist/energy-app-permission.type.js +6 -0
  24. package/dist/enyo-energy-app-sdk.d.ts +10 -1
  25. package/dist/implementations/data-bus/data-bus-command-handler.d.ts +114 -0
  26. package/dist/implementations/data-bus/data-bus-command-handler.js +135 -0
  27. package/dist/index.d.ts +29 -0
  28. package/dist/index.js +32 -0
  29. package/dist/packages/energy-app-pv-forecasting.d.ts +63 -0
  30. package/dist/packages/energy-app-pv-forecasting.js +1 -0
  31. package/dist/packages/energy-app-pv-system.d.ts +70 -0
  32. package/dist/packages/energy-app-pv-system.js +1 -0
  33. package/dist/packages/energy-app-weather-forecasting.d.ts +89 -0
  34. package/dist/packages/energy-app-weather-forecasting.js +1 -0
  35. package/dist/types/enyo-data-bus-value.d.ts +93 -3
  36. package/dist/types/enyo-data-bus-value.js +18 -0
  37. package/dist/types/enyo-forecasting.d.ts +110 -0
  38. package/dist/types/enyo-forecasting.js +22 -0
  39. package/dist/types/enyo-pv-system.d.ts +70 -0
  40. package/dist/types/enyo-pv-system.js +23 -0
  41. package/dist/version.d.ts +1 -1
  42. package/dist/version.js +1 -1
  43. package/package.json +1 -1
@@ -24,4 +24,10 @@ var EnergyAppPermissionTypeEnum;
24
24
  EnergyAppPermissionTypeEnum["Timeseries"] = "Timeseries";
25
25
  EnergyAppPermissionTypeEnum["EnergyManagerInfo"] = "EnergyManagerInfo";
26
26
  EnergyAppPermissionTypeEnum["ElectricityTariff"] = "ElectricityTariff";
27
+ EnergyAppPermissionTypeEnum["WeatherForecastRegister"] = "WeatherForecastRegister";
28
+ EnergyAppPermissionTypeEnum["WeatherForecastUse"] = "WeatherForecastUse";
29
+ EnergyAppPermissionTypeEnum["PvForecastRegister"] = "PvForecastRegister";
30
+ EnergyAppPermissionTypeEnum["PvForecastUse"] = "PvForecastUse";
31
+ EnergyAppPermissionTypeEnum["PvSystemRegister"] = "PvSystemRegister";
32
+ EnergyAppPermissionTypeEnum["PvSystemUse"] = "PvSystemUse";
27
33
  })(EnergyAppPermissionTypeEnum || (exports.EnergyAppPermissionTypeEnum = EnergyAppPermissionTypeEnum = {}));
@@ -1,4 +1,4 @@
1
- export type EnergyAppPermissionType = 'RestrictedInternetAccess' | 'NetworkDeviceDiscovery' | 'NetworkDeviceSearch' | 'NetworkDeviceAccess' | 'Modbus' | 'Storage' | 'Appliance' | 'AllAppliances' | 'SendDataBusValues' | 'SubscribeDataBus' | 'SendDataBusCommands' | 'OcppServer' | 'ChargingCard' | 'Vehicle' | 'Charge' | 'SecretManager' | 'LocationZipCode' | 'LocationCoordinates' | 'Timeseries' | 'EnergyManagerInfo' | 'ElectricityTariff';
1
+ export type EnergyAppPermissionType = 'RestrictedInternetAccess' | 'NetworkDeviceDiscovery' | 'NetworkDeviceSearch' | 'NetworkDeviceAccess' | 'Modbus' | 'Storage' | 'Appliance' | 'AllAppliances' | 'SendDataBusValues' | 'SubscribeDataBus' | 'SendDataBusCommands' | 'OcppServer' | 'ChargingCard' | 'Vehicle' | 'Charge' | 'SecretManager' | 'LocationZipCode' | 'LocationCoordinates' | 'Timeseries' | 'EnergyManagerInfo' | 'ElectricityTariff' | 'WeatherForecastRegister' | 'WeatherForecastUse' | 'PvForecastRegister' | 'PvForecastUse' | 'PvSystemRegister' | 'PvSystemUse';
2
2
  export declare enum EnergyAppPermissionTypeEnum {
3
3
  RestrictedInternetAccess = "RestrictedInternetAccess",
4
4
  NetworkDeviceDiscovery = "NetworkDeviceDiscovery",
@@ -20,5 +20,11 @@ export declare enum EnergyAppPermissionTypeEnum {
20
20
  LocationCoordinates = "LocationCoordinates",
21
21
  Timeseries = "Timeseries",
22
22
  EnergyManagerInfo = "EnergyManagerInfo",
23
- ElectricityTariff = "ElectricityTariff"
23
+ ElectricityTariff = "ElectricityTariff",
24
+ WeatherForecastRegister = "WeatherForecastRegister",
25
+ WeatherForecastUse = "WeatherForecastUse",
26
+ PvForecastRegister = "PvForecastRegister",
27
+ PvForecastUse = "PvForecastUse",
28
+ PvSystemRegister = "PvSystemRegister",
29
+ PvSystemUse = "PvSystemUse"
24
30
  }
@@ -19,6 +19,9 @@ import { EnergyAppTimeseries } from "./packages/energy-app-timeseries.cjs";
19
19
  import { EnyoPackageChannel } from "./enyo-package-channel.cjs";
20
20
  import { EnergyAppEnergyManager } from "./packages/energy-app-energy-manager.cjs";
21
21
  import { EnergyAppElectricityTariff } from "./packages/energy-app-electricity-tariff.cjs";
22
+ import { EnergyAppWeatherForecasting } from "./packages/energy-app-weather-forecasting.cjs";
23
+ import { EnergyAppPvForecasting } from "./packages/energy-app-pv-forecasting.cjs";
24
+ import { EnergyAppPvSystem } from "./packages/energy-app-pv-system.cjs";
22
25
  export declare enum EnergyAppStateEnum {
23
26
  Launching = "launching",
24
27
  Running = "running",
@@ -34,7 +37,7 @@ export declare enum EnergyAppStateEnum {
34
37
  */
35
38
  export interface EnyoEnergyAppSdk {
36
39
  /** Register a callback that gets called when the package is initialized */
37
- register: (callback: (packageName: string, version: number, channel: EnyoPackageChannel) => void) => void;
40
+ register: (callback: (packageName: string, version: number, channel: EnyoPackageChannel) => void | Promise<void>) => void;
38
41
  /** Register a callback that gets called when the system is shutting down */
39
42
  onShutdown: (callback: () => Promise<void>) => void;
40
43
  /** Update the state of the Energy App. Default state set is launching*/
@@ -83,4 +86,10 @@ export interface EnyoEnergyAppSdk {
83
86
  useEnergyManager: () => EnergyAppEnergyManager;
84
87
  /** Get the Electricity Tariff API for managing electricity tariffs */
85
88
  useElectricityTariff: () => EnergyAppElectricityTariff;
89
+ /** Get the Weather Forecasting API for managing weather forecast providers and retrieving weather forecasts */
90
+ useWeatherForecasting: () => EnergyAppWeatherForecasting;
91
+ /** Get the PV Forecasting API for managing PV forecast providers and retrieving PV forecasts */
92
+ usePvForecasting: () => EnergyAppPvForecasting;
93
+ /** Get the PV System API for managing PV system registrations and configurations */
94
+ usePvSystem: () => EnergyAppPvSystem;
86
95
  }
@@ -0,0 +1,140 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DataBusCommandHandler = exports.CommandTimeoutError = void 0;
4
+ const enyo_data_bus_value_js_1 = require("../../types/enyo-data-bus-value.cjs");
5
+ /**
6
+ * Error thrown when a command does not receive an acknowledgment within the configured timeout.
7
+ */
8
+ class CommandTimeoutError extends Error {
9
+ /**
10
+ * The ID of the command message that timed out.
11
+ */
12
+ messageId;
13
+ /**
14
+ * The timeout duration in milliseconds that was exceeded.
15
+ */
16
+ timeoutMs;
17
+ /**
18
+ * Creates a new CommandTimeoutError.
19
+ * @param messageId - The ID of the command message that timed out
20
+ * @param timeoutMs - The timeout duration in milliseconds
21
+ */
22
+ constructor(messageId, timeoutMs) {
23
+ super(`Command ${messageId} timed out after ${timeoutMs}ms without acknowledgment`);
24
+ this.name = 'CommandTimeoutError';
25
+ this.messageId = messageId;
26
+ this.timeoutMs = timeoutMs;
27
+ }
28
+ }
29
+ exports.CommandTimeoutError = CommandTimeoutError;
30
+ /**
31
+ * Utility class that wraps an {@link EnergyAppDataBus} to provide promise-based command sending
32
+ * with automatic acknowledgment matching and timeout handling.
33
+ *
34
+ * Commands are sent via the data bus and the handler waits for a matching
35
+ * {@link EnyoDataBusMessageEnum.CommandAcknowledgeV1} message. The returned promise resolves
36
+ * with the acknowledgment for all answer types (Accepted, Rejected, NotSupported) — the
37
+ * consumer is responsible for inspecting the `data.answer` field. The promise only rejects
38
+ * on timeout or when {@link dispose} is called.
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const commandHandler = new DataBusCommandHandler(energyApp.useDataBus());
43
+ *
44
+ * try {
45
+ * const ack = await commandHandler.sendCommand(myStartChargeCommand);
46
+ * if (ack.data.answer === EnyoCommandAcknowledgeAnswerEnum.Accepted) {
47
+ * console.log('Command accepted');
48
+ * } else {
49
+ * console.log('Rejected:', ack.data.rejectionReason);
50
+ * }
51
+ * } catch (error) {
52
+ * if (error instanceof CommandTimeoutError) {
53
+ * console.error('No acknowledgment within timeout');
54
+ * }
55
+ * }
56
+ *
57
+ * // Clean up when done
58
+ * commandHandler.dispose();
59
+ * ```
60
+ */
61
+ class DataBusCommandHandler {
62
+ dataBus;
63
+ defaultTimeoutMs;
64
+ pendingCommands = new Map();
65
+ listenerId;
66
+ disposed = false;
67
+ /**
68
+ * Creates a new DataBusCommandHandler.
69
+ * @param dataBus - The data bus instance to send commands through and listen for acknowledgments on
70
+ * @param options - Optional configuration options
71
+ */
72
+ constructor(dataBus, options) {
73
+ this.dataBus = dataBus;
74
+ this.defaultTimeoutMs = options?.defaultTimeoutMs ?? 10_000;
75
+ this.listenerId = this.dataBus.listenForMessages([enyo_data_bus_value_js_1.EnyoDataBusMessageEnum.CommandAcknowledgeV1], (entry) => this.handleAcknowledge(entry));
76
+ }
77
+ /**
78
+ * Sends a command message on the data bus and waits for its acknowledgment.
79
+ *
80
+ * The returned promise resolves with the {@link EnyoDataBusCommandAcknowledgeV1} for all
81
+ * acknowledgment answer types (Accepted, Rejected, NotSupported). It only rejects when:
82
+ * - The timeout is exceeded (throws {@link CommandTimeoutError})
83
+ * - The handler has been disposed
84
+ *
85
+ * @param command - The command message to send. Its `id` field is used to correlate
86
+ * the acknowledgment response.
87
+ * @param options - Optional per-call options to override the default timeout
88
+ * @returns A promise that resolves with the command acknowledgment
89
+ * @throws {CommandTimeoutError} If no acknowledgment is received within the timeout
90
+ * @throws {Error} If the handler has been disposed
91
+ */
92
+ sendCommand(command, options) {
93
+ if (this.disposed) {
94
+ return Promise.reject(new Error('DataBusCommandHandler has been disposed'));
95
+ }
96
+ const timeoutMs = options?.timeoutMs ?? this.defaultTimeoutMs;
97
+ return new Promise((resolve, reject) => {
98
+ const timer = setTimeout(() => {
99
+ this.pendingCommands.delete(command.id);
100
+ reject(new CommandTimeoutError(command.id, timeoutMs));
101
+ }, timeoutMs);
102
+ // Store the pending entry BEFORE calling sendMessage to handle
103
+ // synchronous acknowledgment (e.g. DemoDataBus notifies listeners inline).
104
+ this.pendingCommands.set(command.id, { resolve, reject, timer });
105
+ this.dataBus.sendMessage([command]);
106
+ });
107
+ }
108
+ /**
109
+ * Disposes the command handler by unsubscribing from the data bus,
110
+ * rejecting all pending commands, and clearing internal state.
111
+ *
112
+ * After calling dispose, any subsequent calls to {@link sendCommand} will reject immediately.
113
+ */
114
+ dispose() {
115
+ if (this.disposed) {
116
+ return;
117
+ }
118
+ this.disposed = true;
119
+ this.dataBus.unsubscribe(this.listenerId);
120
+ for (const [messageId, pending] of this.pendingCommands) {
121
+ clearTimeout(pending.timer);
122
+ pending.reject(new Error(`DataBusCommandHandler disposed while waiting for acknowledgment of command ${messageId}`));
123
+ }
124
+ this.pendingCommands.clear();
125
+ }
126
+ /**
127
+ * Handles an incoming CommandAcknowledgeV1 message by resolving the
128
+ * corresponding pending command promise, if one exists.
129
+ */
130
+ handleAcknowledge(ack) {
131
+ const pending = this.pendingCommands.get(ack.data.messageId);
132
+ if (!pending) {
133
+ return;
134
+ }
135
+ clearTimeout(pending.timer);
136
+ this.pendingCommands.delete(ack.data.messageId);
137
+ pending.resolve(ack);
138
+ }
139
+ }
140
+ exports.DataBusCommandHandler = DataBusCommandHandler;
@@ -0,0 +1,114 @@
1
+ import { EnergyAppDataBus } from "../../packages/energy-app-data-bus.cjs";
2
+ import { EnyoDataBusCommandAcknowledgeV1, EnyoDataBusMessage } from "../../types/enyo-data-bus-value.cjs";
3
+ /**
4
+ * Configuration options for the {@link DataBusCommandHandler}.
5
+ */
6
+ export interface DataBusCommandHandlerOptions {
7
+ /**
8
+ * Default timeout in milliseconds to wait for a command acknowledgment.
9
+ * Individual calls to {@link DataBusCommandHandler.sendCommand} can override this value.
10
+ * @default 10000
11
+ */
12
+ defaultTimeoutMs?: number;
13
+ }
14
+ /**
15
+ * Per-call options for {@link DataBusCommandHandler.sendCommand}.
16
+ */
17
+ export interface SendCommandOptions {
18
+ /**
19
+ * Timeout in milliseconds for this specific command.
20
+ * Overrides the default timeout configured in {@link DataBusCommandHandlerOptions}.
21
+ */
22
+ timeoutMs?: number;
23
+ }
24
+ /**
25
+ * Error thrown when a command does not receive an acknowledgment within the configured timeout.
26
+ */
27
+ export declare class CommandTimeoutError extends Error {
28
+ /**
29
+ * The ID of the command message that timed out.
30
+ */
31
+ readonly messageId: string;
32
+ /**
33
+ * The timeout duration in milliseconds that was exceeded.
34
+ */
35
+ readonly timeoutMs: number;
36
+ /**
37
+ * Creates a new CommandTimeoutError.
38
+ * @param messageId - The ID of the command message that timed out
39
+ * @param timeoutMs - The timeout duration in milliseconds
40
+ */
41
+ constructor(messageId: string, timeoutMs: number);
42
+ }
43
+ /**
44
+ * Utility class that wraps an {@link EnergyAppDataBus} to provide promise-based command sending
45
+ * with automatic acknowledgment matching and timeout handling.
46
+ *
47
+ * Commands are sent via the data bus and the handler waits for a matching
48
+ * {@link EnyoDataBusMessageEnum.CommandAcknowledgeV1} message. The returned promise resolves
49
+ * with the acknowledgment for all answer types (Accepted, Rejected, NotSupported) — the
50
+ * consumer is responsible for inspecting the `data.answer` field. The promise only rejects
51
+ * on timeout or when {@link dispose} is called.
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const commandHandler = new DataBusCommandHandler(energyApp.useDataBus());
56
+ *
57
+ * try {
58
+ * const ack = await commandHandler.sendCommand(myStartChargeCommand);
59
+ * if (ack.data.answer === EnyoCommandAcknowledgeAnswerEnum.Accepted) {
60
+ * console.log('Command accepted');
61
+ * } else {
62
+ * console.log('Rejected:', ack.data.rejectionReason);
63
+ * }
64
+ * } catch (error) {
65
+ * if (error instanceof CommandTimeoutError) {
66
+ * console.error('No acknowledgment within timeout');
67
+ * }
68
+ * }
69
+ *
70
+ * // Clean up when done
71
+ * commandHandler.dispose();
72
+ * ```
73
+ */
74
+ export declare class DataBusCommandHandler {
75
+ private readonly dataBus;
76
+ private readonly defaultTimeoutMs;
77
+ private readonly pendingCommands;
78
+ private readonly listenerId;
79
+ private disposed;
80
+ /**
81
+ * Creates a new DataBusCommandHandler.
82
+ * @param dataBus - The data bus instance to send commands through and listen for acknowledgments on
83
+ * @param options - Optional configuration options
84
+ */
85
+ constructor(dataBus: EnergyAppDataBus, options?: DataBusCommandHandlerOptions);
86
+ /**
87
+ * Sends a command message on the data bus and waits for its acknowledgment.
88
+ *
89
+ * The returned promise resolves with the {@link EnyoDataBusCommandAcknowledgeV1} for all
90
+ * acknowledgment answer types (Accepted, Rejected, NotSupported). It only rejects when:
91
+ * - The timeout is exceeded (throws {@link CommandTimeoutError})
92
+ * - The handler has been disposed
93
+ *
94
+ * @param command - The command message to send. Its `id` field is used to correlate
95
+ * the acknowledgment response.
96
+ * @param options - Optional per-call options to override the default timeout
97
+ * @returns A promise that resolves with the command acknowledgment
98
+ * @throws {CommandTimeoutError} If no acknowledgment is received within the timeout
99
+ * @throws {Error} If the handler has been disposed
100
+ */
101
+ sendCommand(command: EnyoDataBusMessage, options?: SendCommandOptions): Promise<EnyoDataBusCommandAcknowledgeV1>;
102
+ /**
103
+ * Disposes the command handler by unsubscribing from the data bus,
104
+ * rejecting all pending commands, and clearing internal state.
105
+ *
106
+ * After calling dispose, any subsequent calls to {@link sendCommand} will reject immediately.
107
+ */
108
+ dispose(): void;
109
+ /**
110
+ * Handles an incoming CommandAcknowledgeV1 message by resolving the
111
+ * corresponding pending command promise, if one exists.
112
+ */
113
+ private handleAcknowledge;
114
+ }
@@ -37,6 +37,12 @@ __exportStar(require("./packages/energy-app-energy-manager.cjs"), exports);
37
37
  __exportStar(require("./types/enyo-electricity-tariff.cjs"), exports);
38
38
  __exportStar(require("./packages/energy-app-electricity-tariff.cjs"), exports);
39
39
  __exportStar(require("./types/enyo-pv-forecast.cjs"), exports);
40
+ __exportStar(require("./types/enyo-forecasting.cjs"), exports);
41
+ __exportStar(require("./packages/energy-app-weather-forecasting.cjs"), exports);
42
+ __exportStar(require("./packages/energy-app-pv-forecasting.cjs"), exports);
43
+ __exportStar(require("./types/enyo-pv-system.cjs"), exports);
44
+ __exportStar(require("./packages/energy-app-pv-system.cjs"), exports);
45
+ __exportStar(require("./implementations/data-bus/data-bus-command-handler.cjs"), exports);
40
46
  class EnergyApp {
41
47
  energyAppSdk;
42
48
  constructor() {
@@ -159,6 +165,32 @@ class EnergyApp {
159
165
  useElectricityTariff() {
160
166
  return this.energyAppSdk.useElectricityTariff();
161
167
  }
168
+ /**
169
+ * Gets the Weather Forecasting API for managing weather forecast providers and retrieving weather forecasts.
170
+ * Provides methods to register/deregister weather forecast providers, list available providers,
171
+ * and fetch weather forecasts by zip code or coordinates.
172
+ * @returns The Weather Forecasting API instance
173
+ */
174
+ useWeatherForecasting() {
175
+ return this.energyAppSdk.useWeatherForecasting();
176
+ }
177
+ /**
178
+ * Gets the PV Forecasting API for managing PV forecast providers and retrieving PV forecasts.
179
+ * Provides methods to register/deregister PV forecast providers and fetch power production forecasts.
180
+ * @returns The PV Forecasting API instance
181
+ */
182
+ usePvForecasting() {
183
+ return this.energyAppSdk.usePvForecasting();
184
+ }
185
+ /**
186
+ * Gets the PV System API for managing PV system registrations and configurations.
187
+ * Provides methods to register, retrieve, update, and remove PV systems
188
+ * including DC string orientations, peak power, associated appliances, and feature flags.
189
+ * @returns The PV System API instance
190
+ */
191
+ usePvSystem() {
192
+ return this.energyAppSdk.usePvSystem();
193
+ }
162
194
  /**
163
195
  * Gets the current SDK version.
164
196
  * @returns The semantic version string of the SDK
@@ -20,6 +20,9 @@ import { EnergyAppTimeseries } from "./packages/energy-app-timeseries.cjs";
20
20
  import { EnyoPackageChannel } from "./enyo-package-channel.cjs";
21
21
  import { EnergyAppEnergyManager } from "./packages/energy-app-energy-manager.cjs";
22
22
  import { EnergyAppElectricityTariff } from "./packages/energy-app-electricity-tariff.cjs";
23
+ import { EnergyAppWeatherForecasting } from "./packages/energy-app-weather-forecasting.cjs";
24
+ import { EnergyAppPvForecasting } from "./packages/energy-app-pv-forecasting.cjs";
25
+ import { EnergyAppPvSystem } from "./packages/energy-app-pv-system.cjs";
23
26
  export * from './energy-app-package-definition.cjs';
24
27
  export * from './version.cjs';
25
28
  export * from './implementations/ocpp/ocpp16.cjs';
@@ -41,6 +44,12 @@ export * from './packages/energy-app-energy-manager.cjs';
41
44
  export * from './types/enyo-electricity-tariff.cjs';
42
45
  export * from './packages/energy-app-electricity-tariff.cjs';
43
46
  export * from './types/enyo-pv-forecast.cjs';
47
+ export * from './types/enyo-forecasting.cjs';
48
+ export * from './packages/energy-app-weather-forecasting.cjs';
49
+ export * from './packages/energy-app-pv-forecasting.cjs';
50
+ export * from './types/enyo-pv-system.cjs';
51
+ export * from './packages/energy-app-pv-system.cjs';
52
+ export * from './implementations/data-bus/data-bus-command-handler.cjs';
44
53
  export declare class EnergyApp implements EnyoEnergyAppSdk {
45
54
  private readonly energyAppSdk;
46
55
  constructor();
@@ -96,6 +105,26 @@ export declare class EnergyApp implements EnyoEnergyAppSdk {
96
105
  * @returns The Electricity Tariff API instance
97
106
  */
98
107
  useElectricityTariff(): EnergyAppElectricityTariff;
108
+ /**
109
+ * Gets the Weather Forecasting API for managing weather forecast providers and retrieving weather forecasts.
110
+ * Provides methods to register/deregister weather forecast providers, list available providers,
111
+ * and fetch weather forecasts by zip code or coordinates.
112
+ * @returns The Weather Forecasting API instance
113
+ */
114
+ useWeatherForecasting(): EnergyAppWeatherForecasting;
115
+ /**
116
+ * Gets the PV Forecasting API for managing PV forecast providers and retrieving PV forecasts.
117
+ * Provides methods to register/deregister PV forecast providers and fetch power production forecasts.
118
+ * @returns The PV Forecasting API instance
119
+ */
120
+ usePvForecasting(): EnergyAppPvForecasting;
121
+ /**
122
+ * Gets the PV System API for managing PV system registrations and configurations.
123
+ * Provides methods to register, retrieve, update, and remove PV systems
124
+ * including DC string orientations, peak power, associated appliances, and feature flags.
125
+ * @returns The PV System API instance
126
+ */
127
+ usePvSystem(): EnergyAppPvSystem;
99
128
  /**
100
129
  * Gets the current SDK version.
101
130
  * @returns The semantic version string of the SDK
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,63 @@
1
+ import { PvForecastProviderRegistration, PvForecastProviderInfo, PvForecastResponse } from "../types/enyo-forecasting.cjs";
2
+ /**
3
+ * Interface for managing PV forecast providers and retrieving PV forecasts.
4
+ * Allows energy apps to register PV forecast providers and fetch power production forecasts.
5
+ */
6
+ export interface EnergyAppPvForecasting {
7
+ /**
8
+ * Registers a new PV forecast provider or updates an existing one.
9
+ * Uses upsert logic based on forecastId - if a provider with the same ID exists,
10
+ * it will be updated; otherwise, a new provider will be created.
11
+ *
12
+ * @param registration - The forecast provider registration data
13
+ * @returns Promise that resolves when the provider has been registered
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * await pvForecasting.registerForecast({
18
+ * forecastId: 'solcast-1',
19
+ * name: 'Solcast Forecast',
20
+ * vendor: 'Solcast'
21
+ * });
22
+ * ```
23
+ */
24
+ registerForecast(registration: PvForecastProviderRegistration): Promise<void>;
25
+ /**
26
+ * Removes a registered PV forecast provider by its ID.
27
+ * If the provider does not exist, this operation is a no-op.
28
+ *
29
+ * @param forecastId - The unique identifier of the forecast provider to remove
30
+ * @returns Promise that resolves when the provider has been removed
31
+ */
32
+ deregisterForecast(forecastId: string): Promise<void>;
33
+ /**
34
+ * Retrieves all registered PV forecast providers.
35
+ *
36
+ * @returns Promise that resolves to an array of all registered PV forecast providers
37
+ *
38
+ * @example
39
+ * ```typescript
40
+ * const providers = await pvForecasting.listForecasts();
41
+ * providers.forEach(p => console.log(`${p.name} (${p.vendor})`));
42
+ * ```
43
+ */
44
+ listForecasts(): Promise<PvForecastProviderInfo[]>;
45
+ /**
46
+ * Fetches a PV power production forecast for a specific PV system.
47
+ * Returns forecasted power output entries based on the PV system's configuration.
48
+ *
49
+ * @param forecastId - The unique identifier of the forecast provider to use
50
+ * @param pvSystemId - The unique identifier of the PV system to get the forecast for
51
+ * @returns Promise that resolves to the PV forecast data with resolution and entries
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * const forecast = await pvForecasting.getPvForecast('solcast-1', 'pv-system-001');
56
+ * console.log(`Resolution: ${forecast.resolution}`);
57
+ * forecast.entries.forEach(e =>
58
+ * console.log(`${e.timestampIso}: ${e.forecastedKw} kW`)
59
+ * );
60
+ * ```
61
+ */
62
+ getPvForecast(forecastId: string, pvSystemId: string): Promise<PvForecastResponse>;
63
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,70 @@
1
+ import { PvSystemRegistration, PvSystemInfo } from "../types/enyo-pv-system.cjs";
2
+ /**
3
+ * Interface for managing PV systems.
4
+ * Allows energy apps to register, retrieve, update, and remove PV system configurations
5
+ * including DC string orientations, peak power, associated appliances, and feature flags.
6
+ */
7
+ export interface EnergyAppPvSystem {
8
+ /**
9
+ * Registers a new PV system.
10
+ * The PV system describes the physical installation including peak power,
11
+ * DC string configurations with module count and orientation, optional appliances,
12
+ * and feature flags.
13
+ *
14
+ * @param pvSystem - The PV system registration data
15
+ * @returns Promise that resolves to the registered PV system info including its generated ID
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const pvSystem = await pvSystemApi.registerPvSystem({
20
+ * kWp: 10.5,
21
+ * dcStrings: [
22
+ * { numberOfModules: 12, orientation: PvOrientationEnum.South, orientationSource: 'user' },
23
+ * { numberOfModules: 8, orientation: PvOrientationEnum.West }
24
+ * ],
25
+ * appliances: [
26
+ * { applianceId: 'inv-1', applianceType: EnergyAppApplianceTypeEnum.Inverter }
27
+ * ],
28
+ * features: ['only-grid-feed-in']
29
+ * });
30
+ * console.log(`Registered PV system: ${pvSystem.pvSystemId}`);
31
+ * ```
32
+ */
33
+ registerPvSystem(pvSystem: PvSystemRegistration): Promise<PvSystemInfo>;
34
+ /**
35
+ * Retrieves a registered PV system by its ID.
36
+ *
37
+ * @param pvSystemId - The unique identifier of the PV system
38
+ * @returns Promise that resolves to the PV system info, or null if not found
39
+ */
40
+ getPvSystem(pvSystemId: string): Promise<PvSystemInfo | null>;
41
+ /**
42
+ * Updates an existing PV system configuration.
43
+ * Allows changing the kWp, DC string configurations, appliances, and features
44
+ * of a registered PV system.
45
+ *
46
+ * @param pvSystemId - The unique identifier of the PV system to update
47
+ * @param pvSystem - The updated PV system registration data
48
+ * @returns Promise that resolves to the updated PV system info
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * const updated = await pvSystemApi.updatePvSystem('pv-system-001', {
53
+ * kWp: 12.0,
54
+ * dcStrings: [
55
+ * { numberOfModules: 14, orientation: PvOrientationEnum.South },
56
+ * { numberOfModules: 10, orientation: PvOrientationEnum.West }
57
+ * ]
58
+ * });
59
+ * ```
60
+ */
61
+ updatePvSystem(pvSystemId: string, pvSystem: PvSystemRegistration): Promise<PvSystemInfo>;
62
+ /**
63
+ * Removes a registered PV system by its ID.
64
+ * If the PV system does not exist, this operation is a no-op.
65
+ *
66
+ * @param pvSystemId - The unique identifier of the PV system to remove
67
+ * @returns Promise that resolves when the PV system has been removed
68
+ */
69
+ removePvSystem(pvSystemId: string): Promise<void>;
70
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,89 @@
1
+ import { WeatherForecastRegistration, WeatherForecastInfo, WeatherForecastByZipCodeRequest, WeatherForecastByCoordinatesRequest, WeatherForecastResponse } from "../types/enyo-forecasting.cjs";
2
+ /**
3
+ * Interface for managing weather forecast providers and retrieving weather forecasts.
4
+ * Allows energy apps to register weather forecast providers and fetch forecasts
5
+ * using either zip code or geographic coordinates depending on the provider's requirements.
6
+ */
7
+ export interface EnergyAppWeatherForecasting {
8
+ /**
9
+ * Registers a new weather forecast provider or updates an existing one.
10
+ * Uses upsert logic based on forecastId - if a provider with the same ID exists,
11
+ * it will be updated; otherwise, a new provider will be created.
12
+ *
13
+ * @param registration - The forecast provider registration data
14
+ * @returns Promise that resolves when the provider has been registered
15
+ *
16
+ * @example
17
+ * ```typescript
18
+ * await weatherForecasting.registerForecast({
19
+ * forecastId: 'openweather-1',
20
+ * name: 'OpenWeather Forecast',
21
+ * vendor: 'OpenWeather',
22
+ * locationType: WeatherForecastLocationTypeEnum.ZipCode
23
+ * });
24
+ * ```
25
+ */
26
+ registerForecast(registration: WeatherForecastRegistration): Promise<void>;
27
+ /**
28
+ * Removes a registered weather forecast provider by its ID.
29
+ * If the provider does not exist, this operation is a no-op.
30
+ *
31
+ * @param forecastId - The unique identifier of the forecast provider to remove
32
+ * @returns Promise that resolves when the provider has been removed
33
+ */
34
+ deregisterForecast(forecastId: string): Promise<void>;
35
+ /**
36
+ * Retrieves all registered weather forecast providers.
37
+ *
38
+ * @returns Promise that resolves to an array of all registered weather forecast providers
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const providers = await weatherForecasting.listForecasts();
43
+ * providers.forEach(p => console.log(`${p.name} (${p.vendor})`));
44
+ * ```
45
+ */
46
+ listForecasts(): Promise<WeatherForecastInfo[]>;
47
+ /**
48
+ * Fetches a weather forecast using a zip code.
49
+ * The forecast provider must be configured with locationType 'zip-code'.
50
+ *
51
+ * @param forecastId - The unique identifier of the forecast provider to use
52
+ * @param request - The request containing the zip code
53
+ * @returns Promise that resolves to the weather forecast data with resolution and entries
54
+ *
55
+ * @example
56
+ * ```typescript
57
+ * const forecast = await weatherForecasting.getWeatherForecastByZipCode(
58
+ * 'openweather-1',
59
+ * { zipCode: '80331' }
60
+ * );
61
+ * console.log(`Resolution: ${forecast.resolution}`);
62
+ * forecast.entries.forEach(e =>
63
+ * console.log(`${e.timestampIso}: ${e.outdoorTemperatureCelsius}°C`)
64
+ * );
65
+ * ```
66
+ */
67
+ getWeatherForecastByZipCode(forecastId: string, request: WeatherForecastByZipCodeRequest): Promise<WeatherForecastResponse>;
68
+ /**
69
+ * Fetches a weather forecast using geographic coordinates.
70
+ * The forecast provider must be configured with locationType 'coordinates'.
71
+ *
72
+ * @param forecastId - The unique identifier of the forecast provider to use
73
+ * @param request - The request containing latitude and longitude
74
+ * @returns Promise that resolves to the weather forecast data with resolution and entries
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * const forecast = await weatherForecasting.getWeatherForecastByCoordinates(
79
+ * 'weather-api-1',
80
+ * { latitude: 48.1351, longitude: 11.5820 }
81
+ * );
82
+ * console.log(`Resolution: ${forecast.resolution}`);
83
+ * forecast.entries.forEach(e =>
84
+ * console.log(`${e.timestampIso}: ${e.outdoorTemperatureCelsius}°C`)
85
+ * );
86
+ * ```
87
+ */
88
+ getWeatherForecastByCoordinates(forecastId: string, request: WeatherForecastByCoordinatesRequest): Promise<WeatherForecastResponse>;
89
+ }