@enyo-energy/energy-app-sdk 1.49.0 → 1.50.0

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
@@ -3906,7 +3906,7 @@ Drives a heatpump. Manages building / DHW overheating commands and grid-power-av
3906
3906
  - `publishHeatpumpControlStatus(applianceId, {sessionId, actions})` — how a session's actions progress (`HeatpumpControlStatusV3`).
3907
3907
  - `publishHeatpumpFlexibility(applianceId, options, {validForSeconds?, repeatEverySeconds?})` — offer per zone how far the heatpump can be raised right now (`HeatpumpFlexibilityAnnouncementV3`); repeated automatically until replaced (see below).
3908
3908
  - `publishHeatpumpValuesUpdate(applianceId, values)` — operation mode, electrical and thermal power, energies.
3909
- - `publishHeatpumpTemperatures(applianceId, temperatures)` — outdoor, flow / target flow / return, DHW tanks, heating circuits (room, flow, target flow, return), buffer tank.
3909
+ - `publishHeatpumpTemperatures(applianceId, temperatures)` — outdoor, flow / target flow / return, DHW tanks, heating circuits (room, flow, target flow, return), buffer tank. Each heating circuit must set at least one current temperature (`temperatureC`, `roomTemperatureC`, `flowTemperatureC` or `returnTemperatureC`) — `temperatureC` itself is optional; the payload is checked with the exported `validateHeatpumpTemperatures(data)` and an invalid one throws.
3910
3910
 
3911
3911
  #### HeatpumpControlV3
3912
3912
 
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.validateHeatpumpTemperatures = validateHeatpumpTemperatures;
4
+ /** The current-temperature fields of a heating circuit, at least one of which must be set. */
5
+ const HEATING_CIRCUIT_CURRENT_TEMPERATURE_FIELDS = [
6
+ 'temperatureC',
7
+ 'roomTemperatureC',
8
+ 'flowTemperatureC',
9
+ 'returnTemperatureC',
10
+ ];
11
+ /**
12
+ * Validates the data of a `HeatpumpTemperaturesUpdateV1`.
13
+ *
14
+ * Errors:
15
+ * - A heating circuit carries no current temperature — none of
16
+ * `temperatureC`, `roomTemperatureC`, `flowTemperatureC` or
17
+ * `returnTemperatureC` is a finite number. Since `temperatureC` is optional,
18
+ * such a circuit would report nothing but its target.
19
+ *
20
+ * @param data - The message's `data`.
21
+ * @returns The validation result; `ok` is `false` when there are errors.
22
+ */
23
+ function validateHeatpumpTemperatures(data) {
24
+ const errors = [];
25
+ for (const circuit of data.heatingCircuits ?? []) {
26
+ const hasCurrentTemperature = HEATING_CIRCUIT_CURRENT_TEMPERATURE_FIELDS.some((field) => Number.isFinite(circuit[field]));
27
+ if (!hasCurrentTemperature) {
28
+ errors.push(`heatingCircuits[index=${circuit.index}] must set at least one of ` +
29
+ `${HEATING_CIRCUIT_CURRENT_TEMPERATURE_FIELDS.join(', ')}`);
30
+ }
31
+ }
32
+ return { ok: errors.length === 0, errors };
33
+ }
@@ -0,0 +1,24 @@
1
+ import { EnyoDataBusHeatpumpTemperaturesV1 } from '../../types/enyo-data-bus-value.cjs';
2
+ /**
3
+ * Result of {@link validateHeatpumpTemperatures}: `ok` is `false` when there
4
+ * are errors.
5
+ */
6
+ export interface HeatpumpTemperaturesValidationResult {
7
+ /** `true` when there are no errors. */
8
+ ok: boolean;
9
+ /** Problems that make the temperature update wrong. */
10
+ errors: string[];
11
+ }
12
+ /**
13
+ * Validates the data of a `HeatpumpTemperaturesUpdateV1`.
14
+ *
15
+ * Errors:
16
+ * - A heating circuit carries no current temperature — none of
17
+ * `temperatureC`, `roomTemperatureC`, `flowTemperatureC` or
18
+ * `returnTemperatureC` is a finite number. Since `temperatureC` is optional,
19
+ * such a circuit would report nothing but its target.
20
+ *
21
+ * @param data - The message's `data`.
22
+ * @returns The validation result; `ok` is `false` when there are errors.
23
+ */
24
+ export declare function validateHeatpumpTemperatures(data: EnyoDataBusHeatpumpTemperaturesV1['data']): HeatpumpTemperaturesValidationResult;
@@ -110,6 +110,7 @@ __exportStar(require("./implementations/heatpump/heatpump-metadata-validators.cj
110
110
  __exportStar(require("./implementations/heatpump/heatpump-control-validators.cjs"), exports);
111
111
  __exportStar(require("./implementations/heatpump/heatpump-control-session.cjs"), exports);
112
112
  __exportStar(require("./implementations/heatpump/heatpump-flexibility-validators.cjs"), exports);
113
+ __exportStar(require("./implementations/heatpump/heatpump-temperatures-validators.cjs"), exports);
113
114
  __exportStar(require("./implementations/heatpump/heatpump-heating-curve-offset.cjs"), exports);
114
115
  __exportStar(require("./implementations/heatpump/heatpump-curve-optimization-rooms.cjs"), exports);
115
116
  __exportStar(require("./types/enyo-inverter-appliance.cjs"), exports);
@@ -94,6 +94,7 @@ export * from './implementations/heatpump/heatpump-metadata-validators.cjs';
94
94
  export * from './implementations/heatpump/heatpump-control-validators.cjs';
95
95
  export * from './implementations/heatpump/heatpump-control-session.cjs';
96
96
  export * from './implementations/heatpump/heatpump-flexibility-validators.cjs';
97
+ export * from './implementations/heatpump/heatpump-temperatures-validators.cjs';
97
98
  export * from './implementations/heatpump/heatpump-heating-curve-offset.cjs';
98
99
  export * from './implementations/heatpump/heatpump-curve-optimization-rooms.cjs';
99
100
  export * from './types/enyo-inverter-appliance.cjs';
@@ -6,6 +6,7 @@ const integration_energy_app_js_1 = require("./integration-energy-app.cjs");
6
6
  const enyo_appliance_js_1 = require("../types/enyo-appliance.cjs");
7
7
  const enyo_data_bus_value_js_1 = require("../types/enyo-data-bus-value.cjs");
8
8
  const heatpump_flexibility_validators_js_1 = require("../implementations/heatpump/heatpump-flexibility-validators.cjs");
9
+ const heatpump_temperatures_validators_js_1 = require("../implementations/heatpump/heatpump-temperatures-validators.cjs");
9
10
  const enyo_heatpump_appliance_js_1 = require("../types/enyo-heatpump-appliance.cjs");
10
11
  const heatpump_control_validators_js_1 = require("../implementations/heatpump/heatpump-control-validators.cjs");
11
12
  const heatpump_control_session_js_1 = require("../implementations/heatpump/heatpump-control-session.cjs");
@@ -584,8 +585,14 @@ class HeatpumpIntegrationEnergyApp extends integration_energy_app_js_1.Integrati
584
585
  * @param applianceId - The heatpump appliance ID this update is for.
585
586
  * @param temperatures - Temperature payload — see
586
587
  * {@link EnyoDataBusHeatpumpTemperaturesV1.data}.
588
+ * @throws Error when the payload fails {@link validateHeatpumpTemperatures},
589
+ * e.g. a heating circuit without any current temperature.
587
590
  */
588
591
  publishHeatpumpTemperatures(applianceId, temperatures) {
592
+ const { ok, errors } = (0, heatpump_temperatures_validators_js_1.validateHeatpumpTemperatures)(temperatures);
593
+ if (!ok) {
594
+ throw new Error(`Invalid heatpump temperatures: ${errors.join('; ')}`);
595
+ }
589
596
  const message = {
590
597
  id: this.generateMessageId(),
591
598
  type: 'message',
@@ -512,6 +512,8 @@ export declare abstract class HeatpumpIntegrationEnergyApp extends IntegrationEn
512
512
  * @param applianceId - The heatpump appliance ID this update is for.
513
513
  * @param temperatures - Temperature payload — see
514
514
  * {@link EnyoDataBusHeatpumpTemperaturesV1.data}.
515
+ * @throws Error when the payload fails {@link validateHeatpumpTemperatures},
516
+ * e.g. a heating circuit without any current temperature.
515
517
  */
516
518
  publishHeatpumpTemperatures(applianceId: string, temperatures: EnyoDataBusHeatpumpTemperaturesV1['data']): void;
517
519
  private sendHeatpumpFlexibility;
@@ -4098,8 +4098,13 @@ export interface EnyoDataBusHeatpumpTemperaturesV1 extends EnyoDataBusMessage {
4098
4098
  * reports it. Prefer the explicit {@link flowTemperatureC} and
4099
4099
  * {@link roomTemperatureC} where available — this field does not
4100
4100
  * say which of the two it is.
4101
+ *
4102
+ * Optional, but every circuit must carry at least one current
4103
+ * temperature: this field, {@link roomTemperatureC},
4104
+ * {@link flowTemperatureC} or {@link returnTemperatureC}. See
4105
+ * {@link validateHeatpumpTemperatures}.
4101
4106
  */
4102
- temperatureC: number;
4107
+ temperatureC?: number;
4103
4108
  /** Target room temperature in Celsius */
4104
4109
  targetRoomTemperatureC?: number;
4105
4110
  /**
@@ -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 = '1.49.0';
12
+ exports.SDK_VERSION = '1.50.0';
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 = "1.49.0";
8
+ export declare const SDK_VERSION = "1.50.0";
9
9
  /**
10
10
  * Gets the current SDK version.
11
11
  * @returns The semantic version string of the SDK
@@ -0,0 +1,24 @@
1
+ import { EnyoDataBusHeatpumpTemperaturesV1 } from '../../types/enyo-data-bus-value.js';
2
+ /**
3
+ * Result of {@link validateHeatpumpTemperatures}: `ok` is `false` when there
4
+ * are errors.
5
+ */
6
+ export interface HeatpumpTemperaturesValidationResult {
7
+ /** `true` when there are no errors. */
8
+ ok: boolean;
9
+ /** Problems that make the temperature update wrong. */
10
+ errors: string[];
11
+ }
12
+ /**
13
+ * Validates the data of a `HeatpumpTemperaturesUpdateV1`.
14
+ *
15
+ * Errors:
16
+ * - A heating circuit carries no current temperature — none of
17
+ * `temperatureC`, `roomTemperatureC`, `flowTemperatureC` or
18
+ * `returnTemperatureC` is a finite number. Since `temperatureC` is optional,
19
+ * such a circuit would report nothing but its target.
20
+ *
21
+ * @param data - The message's `data`.
22
+ * @returns The validation result; `ok` is `false` when there are errors.
23
+ */
24
+ export declare function validateHeatpumpTemperatures(data: EnyoDataBusHeatpumpTemperaturesV1['data']): HeatpumpTemperaturesValidationResult;
@@ -0,0 +1,30 @@
1
+ /** The current-temperature fields of a heating circuit, at least one of which must be set. */
2
+ const HEATING_CIRCUIT_CURRENT_TEMPERATURE_FIELDS = [
3
+ 'temperatureC',
4
+ 'roomTemperatureC',
5
+ 'flowTemperatureC',
6
+ 'returnTemperatureC',
7
+ ];
8
+ /**
9
+ * Validates the data of a `HeatpumpTemperaturesUpdateV1`.
10
+ *
11
+ * Errors:
12
+ * - A heating circuit carries no current temperature — none of
13
+ * `temperatureC`, `roomTemperatureC`, `flowTemperatureC` or
14
+ * `returnTemperatureC` is a finite number. Since `temperatureC` is optional,
15
+ * such a circuit would report nothing but its target.
16
+ *
17
+ * @param data - The message's `data`.
18
+ * @returns The validation result; `ok` is `false` when there are errors.
19
+ */
20
+ export function validateHeatpumpTemperatures(data) {
21
+ const errors = [];
22
+ for (const circuit of data.heatingCircuits ?? []) {
23
+ const hasCurrentTemperature = HEATING_CIRCUIT_CURRENT_TEMPERATURE_FIELDS.some((field) => Number.isFinite(circuit[field]));
24
+ if (!hasCurrentTemperature) {
25
+ errors.push(`heatingCircuits[index=${circuit.index}] must set at least one of ` +
26
+ `${HEATING_CIRCUIT_CURRENT_TEMPERATURE_FIELDS.join(', ')}`);
27
+ }
28
+ }
29
+ return { ok: errors.length === 0, errors };
30
+ }
package/dist/index.d.ts CHANGED
@@ -94,6 +94,7 @@ export * from './implementations/heatpump/heatpump-metadata-validators.js';
94
94
  export * from './implementations/heatpump/heatpump-control-validators.js';
95
95
  export * from './implementations/heatpump/heatpump-control-session.js';
96
96
  export * from './implementations/heatpump/heatpump-flexibility-validators.js';
97
+ export * from './implementations/heatpump/heatpump-temperatures-validators.js';
97
98
  export * from './implementations/heatpump/heatpump-heating-curve-offset.js';
98
99
  export * from './implementations/heatpump/heatpump-curve-optimization-rooms.js';
99
100
  export * from './types/enyo-inverter-appliance.js';
package/dist/index.js CHANGED
@@ -94,6 +94,7 @@ export * from './implementations/heatpump/heatpump-metadata-validators.js';
94
94
  export * from './implementations/heatpump/heatpump-control-validators.js';
95
95
  export * from './implementations/heatpump/heatpump-control-session.js';
96
96
  export * from './implementations/heatpump/heatpump-flexibility-validators.js';
97
+ export * from './implementations/heatpump/heatpump-temperatures-validators.js';
97
98
  export * from './implementations/heatpump/heatpump-heating-curve-offset.js';
98
99
  export * from './implementations/heatpump/heatpump-curve-optimization-rooms.js';
99
100
  export * from './types/enyo-inverter-appliance.js';
@@ -512,6 +512,8 @@ export declare abstract class HeatpumpIntegrationEnergyApp extends IntegrationEn
512
512
  * @param applianceId - The heatpump appliance ID this update is for.
513
513
  * @param temperatures - Temperature payload — see
514
514
  * {@link EnyoDataBusHeatpumpTemperaturesV1.data}.
515
+ * @throws Error when the payload fails {@link validateHeatpumpTemperatures},
516
+ * e.g. a heating circuit without any current temperature.
515
517
  */
516
518
  publishHeatpumpTemperatures(applianceId: string, temperatures: EnyoDataBusHeatpumpTemperaturesV1['data']): void;
517
519
  private sendHeatpumpFlexibility;
@@ -2,6 +2,7 @@ import { IntegrationEnergyApp } from "./integration-energy-app.js";
2
2
  import { EnyoApplianceTypeEnum } from "../types/enyo-appliance.js";
3
3
  import { EnyoCommandAcknowledgeAnswerEnum, EnyoDataBusMessageEnum } from "../types/enyo-data-bus-value.js";
4
4
  import { heatpumpFlexibilityOfferId, validateHeatpumpFlexibilityAnnouncement } from "../implementations/heatpump/heatpump-flexibility-validators.js";
5
+ import { validateHeatpumpTemperatures } from "../implementations/heatpump/heatpump-temperatures-validators.js";
5
6
  import { EnyoHeatpumpApplianceAvailableFeaturesEnum, EnyoHeatpumpProgramModeEnum } from "../types/enyo-heatpump-appliance.js";
6
7
  import { validateHeatpumpControlAction, validateHeatpumpHeatingCurveOffset, validateHeatpumpProgramSwitch } from "../implementations/heatpump/heatpump-control-validators.js";
7
8
  import { HeatpumpControlEndCauseEnum, heatpumpControlActionsKey, HeatpumpControlSessionTracker } from "../implementations/heatpump/heatpump-control-session.js";
@@ -580,8 +581,14 @@ export class HeatpumpIntegrationEnergyApp extends IntegrationEnergyApp {
580
581
  * @param applianceId - The heatpump appliance ID this update is for.
581
582
  * @param temperatures - Temperature payload — see
582
583
  * {@link EnyoDataBusHeatpumpTemperaturesV1.data}.
584
+ * @throws Error when the payload fails {@link validateHeatpumpTemperatures},
585
+ * e.g. a heating circuit without any current temperature.
583
586
  */
584
587
  publishHeatpumpTemperatures(applianceId, temperatures) {
588
+ const { ok, errors } = validateHeatpumpTemperatures(temperatures);
589
+ if (!ok) {
590
+ throw new Error(`Invalid heatpump temperatures: ${errors.join('; ')}`);
591
+ }
585
592
  const message = {
586
593
  id: this.generateMessageId(),
587
594
  type: 'message',
@@ -4098,8 +4098,13 @@ export interface EnyoDataBusHeatpumpTemperaturesV1 extends EnyoDataBusMessage {
4098
4098
  * reports it. Prefer the explicit {@link flowTemperatureC} and
4099
4099
  * {@link roomTemperatureC} where available — this field does not
4100
4100
  * say which of the two it is.
4101
+ *
4102
+ * Optional, but every circuit must carry at least one current
4103
+ * temperature: this field, {@link roomTemperatureC},
4104
+ * {@link flowTemperatureC} or {@link returnTemperatureC}. See
4105
+ * {@link validateHeatpumpTemperatures}.
4101
4106
  */
4102
- temperatureC: number;
4107
+ temperatureC?: number;
4103
4108
  /** Target room temperature in Celsius */
4104
4109
  targetRoomTemperatureC?: number;
4105
4110
  /**
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 = "1.49.0";
8
+ export declare const SDK_VERSION = "1.50.0";
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 = '1.49.0';
8
+ export const SDK_VERSION = '1.50.0';
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": "1.49.0",
3
+ "version": "1.50.0",
4
4
  "description": "enyo Energy App SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",