@enyo-energy/energy-app-sdk 0.0.191 → 0.0.192

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
@@ -757,18 +757,33 @@ the update callback cheap.
757
757
 
758
758
  #### `useChargingCard(): EnergyAppChargingCard`
759
759
 
760
- Handle charging authentication:
760
+ Read registered charging cards and pair new RFID cards:
761
761
 
762
762
  ```typescript
763
763
  const chargingCards = energyApp.useChargingCard();
764
764
 
765
- // Validate charging card
766
- const isValid = await chargingCards.validateCard('RFID-12345');
765
+ // List all registered charging cards
766
+ const cards = await chargingCards.list();
767
767
 
768
- // Get card information
769
- const cardInfo = await chargingCards.getCardInfo('RFID-12345');
768
+ // Get a single card
769
+ const card = await chargingCards.getById('card-id');
770
+
771
+ // Handle pairing requests coming from the app
772
+ const listenerId = chargingCards.listenForPairingStarted(async (request) => {
773
+ // Put the reader into pairing mode and wait for a card to be presented.
774
+ // Resolve with the RFID read from the card - the host assigns it to
775
+ // request.chargingCardId and clears its pendingRegistration flag.
776
+ return await charger.enterPairingMode(request.applianceId, request.timeoutMs);
777
+ });
778
+
779
+ chargingCards.removeListener(listenerId);
770
780
  ```
771
781
 
782
+ Reject the promise returned by the pairing listener when no card was presented or
783
+ the charger refused to enter pairing mode - the host then reports the attempt as
784
+ failed and leaves the card pending. A package managing several chargers should
785
+ check `request.applianceId` and reject requests for appliances it does not own.
786
+
772
787
  ### User Features
773
788
 
774
789
  #### `useAuthentication(): EnergyAppAuthentication`
@@ -83,6 +83,8 @@ __exportStar(require("./packages/energy-app-configuration-manager.cjs"), exports
83
83
  __exportStar(require("./types/enyo-air-conditioning-appliance.cjs"), exports);
84
84
  __exportStar(require("./types/enyo-heating-rod-appliance.cjs"), exports);
85
85
  __exportStar(require("./types/enyo-charger-appliance.cjs"), exports);
86
+ __exportStar(require("./types/enyo-charging-card.cjs"), exports);
87
+ __exportStar(require("./packages/energy-app-charging-card.cjs"), exports);
86
88
  __exportStar(require("./types/enyo-battery-appliance.cjs"), exports);
87
89
  __exportStar(require("./types/enyo-heatpump-appliance.cjs"), exports);
88
90
  __exportStar(require("./types/enyo-inverter-appliance.cjs"), exports);
@@ -67,6 +67,8 @@ export * from './packages/energy-app-configuration-manager.cjs';
67
67
  export * from './types/enyo-air-conditioning-appliance.cjs';
68
68
  export * from './types/enyo-heating-rod-appliance.cjs';
69
69
  export * from './types/enyo-charger-appliance.cjs';
70
+ export * from './types/enyo-charging-card.cjs';
71
+ export * from './packages/energy-app-charging-card.cjs';
70
72
  export * from './types/enyo-battery-appliance.cjs';
71
73
  export * from './types/enyo-heatpump-appliance.cjs';
72
74
  export * from './types/enyo-inverter-appliance.cjs';
@@ -1,11 +1,56 @@
1
- import { EnyoChargingCard } from "../types/enyo-charging-card.cjs";
1
+ import { EnyoChargingCard, EnyoChargingCardPairingRequest } from "../types/enyo-charging-card.cjs";
2
2
  /**
3
3
  * Interface for managing charging cards in enyo packages.
4
- * Provides read-only operations for charging card information.
4
+ * Provides read-only operations for charging card information as well as
5
+ * RFID pairing support.
5
6
  */
6
7
  export interface EnergyAppChargingCard {
7
8
  /** Get a list of all registered charging cards */
8
9
  list: () => Promise<EnyoChargingCard[]>;
9
10
  /** Get a specific charging card by its ID */
10
11
  getById: (id: string) => Promise<EnyoChargingCard | null>;
12
+ /**
13
+ * Listen for pairing requests, i.e. the host asking this package to put its
14
+ * RFID reader into pairing mode — typically because a user started adding a
15
+ * new charging card in the app.
16
+ *
17
+ * The listener owns the whole pairing attempt: it enables pairing mode on
18
+ * the charger, waits for a card to be held against the reader and resolves
19
+ * with the RFID identifier that was read (the value stored in
20
+ * {@link EnyoChargingCard.rfid}). The host assigns it to the charging card
21
+ * named by {@link EnyoChargingCardPairingRequest.chargingCardId} and clears
22
+ * that card's {@link EnyoChargingCard.pendingRegistration} flag.
23
+ *
24
+ * Reject the returned promise when no card was presented or the charger
25
+ * refused to enter pairing mode; the host then reports the attempt as
26
+ * failed and leaves the card pending. Honour
27
+ * {@link EnyoChargingCardPairingRequest.timeoutMs} when it is set — the host
28
+ * ignores a result that arrives after the deadline.
29
+ *
30
+ * Only register a listener when the package actually drives an RFID reader.
31
+ * Requests carry an optional
32
+ * {@link EnyoChargingCardPairingRequest.applianceId}; a package managing
33
+ * several chargers should check it and reject requests for appliances it
34
+ * does not own.
35
+ *
36
+ * @param listener - Callback invoked for every pairing request, resolving
37
+ * with the RFID identifier read from the presented card
38
+ * @returns A unique listener ID that can be used to remove the listener
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const chargingCard = energyApp.useChargingCard();
43
+ * const listenerId = chargingCard.listenForPairingStarted(async (request) => {
44
+ * const rfid = await charger.enterPairingMode(request.applianceId, request.timeoutMs);
45
+ * return rfid;
46
+ * });
47
+ * ```
48
+ */
49
+ listenForPairingStarted: (listener: (request: EnyoChargingCardPairingRequest) => Promise<string>) => string;
50
+ /**
51
+ * Removes a previously registered listener.
52
+ *
53
+ * @param listenerId - The ID returned by {@link listenForPairingStarted}
54
+ */
55
+ removeListener: (listenerId: string) => void;
11
56
  }
@@ -9,3 +9,24 @@ export interface EnyoChargingCard {
9
9
  rfid?: string;
10
10
  pendingRegistration?: boolean;
11
11
  }
12
+ /**
13
+ * Details of a pairing request handed to a
14
+ * {@link EnergyAppChargingCard.listenForPairingStarted} listener when the
15
+ * host asks a package to put its RFID reader into pairing mode.
16
+ */
17
+ export interface EnyoChargingCardPairingRequest {
18
+ /** ID of the charging card record the scanned RFID should be assigned to */
19
+ chargingCardId: string;
20
+ /**
21
+ * Appliance (charger) whose RFID reader should enter pairing mode. Omitted
22
+ * when the host does not target a specific charger — in that case the
23
+ * package decides which of its readers to use.
24
+ */
25
+ applianceId?: string;
26
+ /**
27
+ * Time budget, in milliseconds, the package has to deliver a scanned card.
28
+ * The host stops waiting once it elapses, so a listener that resolves later
29
+ * has no effect. Omitted when the host does not impose a deadline.
30
+ */
31
+ timeoutMs?: number;
32
+ }
@@ -15,6 +15,15 @@ var EnyoDataBusCommandReasonTypeEnum;
15
15
  EnyoDataBusCommandReasonTypeEnum["PvSurplusAvailable"] = "pv-surplus-available";
16
16
  /** Command issued because PV surplus is unavailable */
17
17
  EnyoDataBusCommandReasonTypeEnum["PvSurplusUnavailable"] = "pv-surplus-unavailable";
18
+ /**
19
+ * Command issued because PV surplus exists but is allocated to another
20
+ * appliance. Belongs to the
21
+ * {@link EnyoDataBusCommandReasonCategoryEnum.PvSurplus} category. Set
22
+ * {@link EnyoDataBusCommandReason.inFavourOfApplianceType} so the
23
+ * end-user text can name the appliance that got the surplus instead of
24
+ * saying "elsewhere".
25
+ */
26
+ EnyoDataBusCommandReasonTypeEnum["PvSurplusAllocatedElsewhere"] = "pv-surplus-allocated-elsewhere";
18
27
  /** Command issued because battery capacity is available */
19
28
  EnyoDataBusCommandReasonTypeEnum["BatteryCapacityAvailable"] = "battery-capacity-available";
20
29
  /** Command issued because battery capacity is unavailable */
@@ -23,6 +23,15 @@ export declare enum EnyoDataBusCommandReasonTypeEnum {
23
23
  PvSurplusAvailable = "pv-surplus-available",
24
24
  /** Command issued because PV surplus is unavailable */
25
25
  PvSurplusUnavailable = "pv-surplus-unavailable",
26
+ /**
27
+ * Command issued because PV surplus exists but is allocated to another
28
+ * appliance. Belongs to the
29
+ * {@link EnyoDataBusCommandReasonCategoryEnum.PvSurplus} category. Set
30
+ * {@link EnyoDataBusCommandReason.inFavourOfApplianceType} so the
31
+ * end-user text can name the appliance that got the surplus instead of
32
+ * saying "elsewhere".
33
+ */
34
+ PvSurplusAllocatedElsewhere = "pv-surplus-allocated-elsewhere",
26
35
  /** Command issued because battery capacity is available */
27
36
  BatteryCapacityAvailable = "battery-capacity-available",
28
37
  /** Command issued because battery capacity is unavailable */
@@ -100,6 +109,16 @@ export interface EnyoDataBusCommandReason {
100
109
  temperatureC?: number;
101
110
  /** Relevant state of charge as a percentage (battery-driven reasons) */
102
111
  socPercent?: number;
112
+ /**
113
+ * The appliance category the decision was made in favour of.
114
+ *
115
+ * Set on reasons that describe a trade-off between appliances — most
116
+ * notably
117
+ * {@link EnyoDataBusCommandReasonTypeEnum.PvSurplusAllocatedElsewhere} —
118
+ * so the end-user text can name the winning appliance (e.g. "the battery")
119
+ * rather than saying "elsewhere".
120
+ */
121
+ inFavourOfApplianceType?: EnyoApplianceTypeEnum;
103
122
  }
104
123
  /**
105
124
  * Whether a grid operator power limitation caps power drawn from the grid
@@ -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.191';
12
+ exports.SDK_VERSION = '0.0.192';
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.191";
8
+ export declare const SDK_VERSION = "0.0.192";
9
9
  /**
10
10
  * Gets the current SDK version.
11
11
  * @returns The semantic version string of the SDK
package/dist/index.d.ts CHANGED
@@ -67,6 +67,8 @@ export * from './packages/energy-app-configuration-manager.js';
67
67
  export * from './types/enyo-air-conditioning-appliance.js';
68
68
  export * from './types/enyo-heating-rod-appliance.js';
69
69
  export * from './types/enyo-charger-appliance.js';
70
+ export * from './types/enyo-charging-card.js';
71
+ export * from './packages/energy-app-charging-card.js';
70
72
  export * from './types/enyo-battery-appliance.js';
71
73
  export * from './types/enyo-heatpump-appliance.js';
72
74
  export * from './types/enyo-inverter-appliance.js';
package/dist/index.js CHANGED
@@ -67,6 +67,8 @@ export * from './packages/energy-app-configuration-manager.js';
67
67
  export * from './types/enyo-air-conditioning-appliance.js';
68
68
  export * from './types/enyo-heating-rod-appliance.js';
69
69
  export * from './types/enyo-charger-appliance.js';
70
+ export * from './types/enyo-charging-card.js';
71
+ export * from './packages/energy-app-charging-card.js';
70
72
  export * from './types/enyo-battery-appliance.js';
71
73
  export * from './types/enyo-heatpump-appliance.js';
72
74
  export * from './types/enyo-inverter-appliance.js';
@@ -1,11 +1,56 @@
1
- import { EnyoChargingCard } from "../types/enyo-charging-card.js";
1
+ import { EnyoChargingCard, EnyoChargingCardPairingRequest } from "../types/enyo-charging-card.js";
2
2
  /**
3
3
  * Interface for managing charging cards in enyo packages.
4
- * Provides read-only operations for charging card information.
4
+ * Provides read-only operations for charging card information as well as
5
+ * RFID pairing support.
5
6
  */
6
7
  export interface EnergyAppChargingCard {
7
8
  /** Get a list of all registered charging cards */
8
9
  list: () => Promise<EnyoChargingCard[]>;
9
10
  /** Get a specific charging card by its ID */
10
11
  getById: (id: string) => Promise<EnyoChargingCard | null>;
12
+ /**
13
+ * Listen for pairing requests, i.e. the host asking this package to put its
14
+ * RFID reader into pairing mode — typically because a user started adding a
15
+ * new charging card in the app.
16
+ *
17
+ * The listener owns the whole pairing attempt: it enables pairing mode on
18
+ * the charger, waits for a card to be held against the reader and resolves
19
+ * with the RFID identifier that was read (the value stored in
20
+ * {@link EnyoChargingCard.rfid}). The host assigns it to the charging card
21
+ * named by {@link EnyoChargingCardPairingRequest.chargingCardId} and clears
22
+ * that card's {@link EnyoChargingCard.pendingRegistration} flag.
23
+ *
24
+ * Reject the returned promise when no card was presented or the charger
25
+ * refused to enter pairing mode; the host then reports the attempt as
26
+ * failed and leaves the card pending. Honour
27
+ * {@link EnyoChargingCardPairingRequest.timeoutMs} when it is set — the host
28
+ * ignores a result that arrives after the deadline.
29
+ *
30
+ * Only register a listener when the package actually drives an RFID reader.
31
+ * Requests carry an optional
32
+ * {@link EnyoChargingCardPairingRequest.applianceId}; a package managing
33
+ * several chargers should check it and reject requests for appliances it
34
+ * does not own.
35
+ *
36
+ * @param listener - Callback invoked for every pairing request, resolving
37
+ * with the RFID identifier read from the presented card
38
+ * @returns A unique listener ID that can be used to remove the listener
39
+ *
40
+ * @example
41
+ * ```typescript
42
+ * const chargingCard = energyApp.useChargingCard();
43
+ * const listenerId = chargingCard.listenForPairingStarted(async (request) => {
44
+ * const rfid = await charger.enterPairingMode(request.applianceId, request.timeoutMs);
45
+ * return rfid;
46
+ * });
47
+ * ```
48
+ */
49
+ listenForPairingStarted: (listener: (request: EnyoChargingCardPairingRequest) => Promise<string>) => string;
50
+ /**
51
+ * Removes a previously registered listener.
52
+ *
53
+ * @param listenerId - The ID returned by {@link listenForPairingStarted}
54
+ */
55
+ removeListener: (listenerId: string) => void;
11
56
  }
@@ -9,3 +9,24 @@ export interface EnyoChargingCard {
9
9
  rfid?: string;
10
10
  pendingRegistration?: boolean;
11
11
  }
12
+ /**
13
+ * Details of a pairing request handed to a
14
+ * {@link EnergyAppChargingCard.listenForPairingStarted} listener when the
15
+ * host asks a package to put its RFID reader into pairing mode.
16
+ */
17
+ export interface EnyoChargingCardPairingRequest {
18
+ /** ID of the charging card record the scanned RFID should be assigned to */
19
+ chargingCardId: string;
20
+ /**
21
+ * Appliance (charger) whose RFID reader should enter pairing mode. Omitted
22
+ * when the host does not target a specific charger — in that case the
23
+ * package decides which of its readers to use.
24
+ */
25
+ applianceId?: string;
26
+ /**
27
+ * Time budget, in milliseconds, the package has to deliver a scanned card.
28
+ * The host stops waiting once it elapses, so a listener that resolves later
29
+ * has no effect. Omitted when the host does not impose a deadline.
30
+ */
31
+ timeoutMs?: number;
32
+ }
@@ -23,6 +23,15 @@ export declare enum EnyoDataBusCommandReasonTypeEnum {
23
23
  PvSurplusAvailable = "pv-surplus-available",
24
24
  /** Command issued because PV surplus is unavailable */
25
25
  PvSurplusUnavailable = "pv-surplus-unavailable",
26
+ /**
27
+ * Command issued because PV surplus exists but is allocated to another
28
+ * appliance. Belongs to the
29
+ * {@link EnyoDataBusCommandReasonCategoryEnum.PvSurplus} category. Set
30
+ * {@link EnyoDataBusCommandReason.inFavourOfApplianceType} so the
31
+ * end-user text can name the appliance that got the surplus instead of
32
+ * saying "elsewhere".
33
+ */
34
+ PvSurplusAllocatedElsewhere = "pv-surplus-allocated-elsewhere",
26
35
  /** Command issued because battery capacity is available */
27
36
  BatteryCapacityAvailable = "battery-capacity-available",
28
37
  /** Command issued because battery capacity is unavailable */
@@ -100,6 +109,16 @@ export interface EnyoDataBusCommandReason {
100
109
  temperatureC?: number;
101
110
  /** Relevant state of charge as a percentage (battery-driven reasons) */
102
111
  socPercent?: number;
112
+ /**
113
+ * The appliance category the decision was made in favour of.
114
+ *
115
+ * Set on reasons that describe a trade-off between appliances — most
116
+ * notably
117
+ * {@link EnyoDataBusCommandReasonTypeEnum.PvSurplusAllocatedElsewhere} —
118
+ * so the end-user text can name the winning appliance (e.g. "the battery")
119
+ * rather than saying "elsewhere".
120
+ */
121
+ inFavourOfApplianceType?: EnyoApplianceTypeEnum;
103
122
  }
104
123
  /**
105
124
  * Whether a grid operator power limitation caps power drawn from the grid
@@ -12,6 +12,15 @@ export var EnyoDataBusCommandReasonTypeEnum;
12
12
  EnyoDataBusCommandReasonTypeEnum["PvSurplusAvailable"] = "pv-surplus-available";
13
13
  /** Command issued because PV surplus is unavailable */
14
14
  EnyoDataBusCommandReasonTypeEnum["PvSurplusUnavailable"] = "pv-surplus-unavailable";
15
+ /**
16
+ * Command issued because PV surplus exists but is allocated to another
17
+ * appliance. Belongs to the
18
+ * {@link EnyoDataBusCommandReasonCategoryEnum.PvSurplus} category. Set
19
+ * {@link EnyoDataBusCommandReason.inFavourOfApplianceType} so the
20
+ * end-user text can name the appliance that got the surplus instead of
21
+ * saying "elsewhere".
22
+ */
23
+ EnyoDataBusCommandReasonTypeEnum["PvSurplusAllocatedElsewhere"] = "pv-surplus-allocated-elsewhere";
15
24
  /** Command issued because battery capacity is available */
16
25
  EnyoDataBusCommandReasonTypeEnum["BatteryCapacityAvailable"] = "battery-capacity-available";
17
26
  /** Command issued because battery capacity is unavailable */
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.191";
8
+ export declare const SDK_VERSION = "0.0.192";
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.191';
8
+ export const SDK_VERSION = '0.0.192';
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.191",
3
+ "version": "0.0.192",
4
4
  "description": "enyo Energy App SDK",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",