@enyo-energy/energy-app-sdk 1.0.0 → 1.2.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 +40 -8
- package/dist/cjs/implementations/onboarding-v2/onboarding-v2-provider-validators.cjs +20 -2
- package/dist/cjs/implementations/onboarding-v2/onboarding-v2-validators.cjs +59 -0
- package/dist/cjs/index.cjs +2 -0
- package/dist/cjs/index.d.cts +2 -0
- package/dist/cjs/packages/energy-app-charge.d.cts +86 -2
- package/dist/cjs/packages/energy-app-onboarding-v2.d.cts +140 -0
- package/dist/cjs/types/enyo-charge.d.cts +112 -3
- package/dist/cjs/types/enyo-onboarding-v2.d.cts +51 -0
- package/dist/cjs/version.cjs +1 -1
- package/dist/cjs/version.d.cts +1 -1
- package/dist/implementations/onboarding-v2/onboarding-v2-provider-validators.js +20 -2
- package/dist/implementations/onboarding-v2/onboarding-v2-validators.js +59 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/packages/energy-app-charge.d.ts +86 -2
- package/dist/packages/energy-app-onboarding-v2.d.ts +140 -0
- package/dist/types/enyo-charge.d.ts +112 -3
- package/dist/types/enyo-onboarding-v2.d.ts +51 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -712,20 +712,52 @@ Manage charging sessions:
|
|
|
712
712
|
```typescript
|
|
713
713
|
const charging = energyApp.useCharge();
|
|
714
714
|
|
|
715
|
-
//
|
|
716
|
-
const
|
|
717
|
-
|
|
715
|
+
// Open a session when the charger reports a StartTransaction
|
|
716
|
+
const charge = await charging.startCharge({
|
|
717
|
+
applianceId: 'appliance-42',
|
|
718
|
+
transactionId: 'tx-1',
|
|
719
|
+
meterStartValueWh: 1_204_000,
|
|
718
720
|
connectorId: 1,
|
|
719
|
-
maxPowerKw: 22
|
|
720
721
|
});
|
|
721
722
|
|
|
722
|
-
//
|
|
723
|
-
const
|
|
723
|
+
// Close it when the charger reports a StopTransaction
|
|
724
|
+
const finished = await charging.stopCharge(charge.id, {
|
|
725
|
+
meterEndValueWh: 1_215_500,
|
|
726
|
+
energyDeliveredWh: 11_500,
|
|
727
|
+
});
|
|
728
|
+
console.log(`${finished.totalEnergyKwh} kWh for ${finished.paidPriceEuroCent} ct`);
|
|
729
|
+
|
|
730
|
+
// The session a charger is running right now, if any
|
|
731
|
+
const active = await charging.findActiveCharge('appliance-42');
|
|
724
732
|
|
|
725
|
-
//
|
|
726
|
-
await charging.
|
|
733
|
+
// A session that spans several OCPP transactions (reconnect, re-authorization)
|
|
734
|
+
await charging.addTransactionIdToActiveCharge('appliance-42', 'tx-2');
|
|
735
|
+
|
|
736
|
+
// Read the history
|
|
737
|
+
const completed = await charging.list({
|
|
738
|
+
applianceId: 'appliance-42',
|
|
739
|
+
status: EnyoChargeStatus.Completed,
|
|
740
|
+
});
|
|
727
741
|
```
|
|
728
742
|
|
|
743
|
+
**Energy and cost totals are the host's to compute, never the app's.**
|
|
744
|
+
`stopCharge()` derives `totalEnergyKwh` and `paidPriceEuroCent` from the
|
|
745
|
+
session's meter readings and the electricity tariff in force while the energy
|
|
746
|
+
flowed. Pass readings — `meterEndValueWh`, and `energyDeliveredWh` when the
|
|
747
|
+
charger reports it — and let the host price them. An app that computes its own
|
|
748
|
+
totals makes the customer's bill depend on which app closed the session.
|
|
749
|
+
|
|
750
|
+
The same division applies to the samples in `meterValues`: leave `pricePerKwh`
|
|
751
|
+
and `chargingCostEuro` unset and the host resolves the tariff for each sample's
|
|
752
|
+
15-minute slot itself. `powerW` and `voltageL1..L3` are optional — write them
|
|
753
|
+
when the charger reports them; when omitted the host keeps whatever it already
|
|
754
|
+
recorded for that timestamp.
|
|
755
|
+
|
|
756
|
+
`startCharge()` is idempotent on `applianceId` + `transactionId`, so a repeated
|
|
757
|
+
StartTransaction returns the running session instead of opening a second one.
|
|
758
|
+
`save()` remains a whole-object update for a session that already exists; it
|
|
759
|
+
offers no uniqueness guarantee, so do not open sessions with it.
|
|
760
|
+
|
|
729
761
|
React to charging sessions as they happen:
|
|
730
762
|
|
|
731
763
|
```typescript
|
|
@@ -47,14 +47,18 @@ const ANY_MODEL = '*';
|
|
|
47
47
|
/**
|
|
48
48
|
* A short human-readable label for a guide, for use in messages.
|
|
49
49
|
*
|
|
50
|
-
* Prefers
|
|
51
|
-
*
|
|
50
|
+
* Prefers {@link EnyoOnboardingV2Guide.name} — it is the handle the author will
|
|
51
|
+
* search for — then the first translated title, then the start variant, so a
|
|
52
|
+
* guide with neither a name nor a title is still identifiable.
|
|
52
53
|
*
|
|
53
54
|
* @param guide - The guide to label.
|
|
54
55
|
* @param index - Its position in the answer's `guides` array.
|
|
55
56
|
* @returns A message prefix such as ``guides[2] ("Wallbox über OCPP")``.
|
|
56
57
|
*/
|
|
57
58
|
function guideLabel(guide, index) {
|
|
59
|
+
const name = guide.name?.trim();
|
|
60
|
+
if (name)
|
|
61
|
+
return `guides[${index}] ("${name}")`;
|
|
58
62
|
const title = guide.title?.[0]?.value;
|
|
59
63
|
return `guides[${index}] (${title ? `"${title}"` : (guide.startVariant ?? '?')})`;
|
|
60
64
|
}
|
|
@@ -122,6 +126,9 @@ function validateOnboardingV2GuidesResult(result, context) {
|
|
|
122
126
|
}
|
|
123
127
|
// Which guide(s) claimed each binding, so a collision can name both sides.
|
|
124
128
|
const claimedBy = new Map();
|
|
129
|
+
// Same, for the explicit `name` handles — a duplicate makes an app unable to
|
|
130
|
+
// say which of the two it means.
|
|
131
|
+
const namedBy = new Map();
|
|
125
132
|
for (const [i, guide] of result.guides.entries()) {
|
|
126
133
|
const at = guideLabel(guide, i);
|
|
127
134
|
const guideResult = (0, onboarding_v2_validators_js_1.validateOnboardingGuideV2)(guide, context);
|
|
@@ -134,6 +141,17 @@ function validateOnboardingV2GuidesResult(result, context) {
|
|
|
134
141
|
else if (!guide.modelIds?.length) {
|
|
135
142
|
warnings.push(`${at}: no modelIds — this guide applies to every model of "${guide.vendorId}".`);
|
|
136
143
|
}
|
|
144
|
+
const name = guide.name?.trim();
|
|
145
|
+
if (name) {
|
|
146
|
+
const previouslyNamed = namedBy.get(name);
|
|
147
|
+
if (previouslyNamed) {
|
|
148
|
+
errors.push(`${at}: name "${name}" is already used by ${previouslyNamed} — ` +
|
|
149
|
+
'a name is how an app addresses one specific guide, so two guides cannot share one.');
|
|
150
|
+
}
|
|
151
|
+
else {
|
|
152
|
+
namedBy.set(name, at);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
137
155
|
for (const key of bindingKeys(guide)) {
|
|
138
156
|
const previous = claimedBy.get(key);
|
|
139
157
|
if (previous) {
|
|
@@ -148,6 +148,8 @@ function validateOnboardingGuideV2(guide, context) {
|
|
|
148
148
|
}
|
|
149
149
|
validateNetworkScanFlag(guide, warnings);
|
|
150
150
|
validateApplianceBinding(guide, errors, warnings);
|
|
151
|
+
validateUserNotification(guide, warnings);
|
|
152
|
+
validateGuideName(guide, errors, warnings);
|
|
151
153
|
return { ok: errors.length === 0, errors, warnings };
|
|
152
154
|
}
|
|
153
155
|
/**
|
|
@@ -681,6 +683,63 @@ function validateApplianceBinding(guide, errors, warnings) {
|
|
|
681
683
|
'` guide binds an existing appliance.');
|
|
682
684
|
}
|
|
683
685
|
}
|
|
686
|
+
/**
|
|
687
|
+
* Checks {@link EnyoOnboardingV2Guide.name} is usable as a handle.
|
|
688
|
+
*
|
|
689
|
+
* The property is optional — a guide that never needs to be addressed does not
|
|
690
|
+
* need one, and the host falls back to a name derived from the guide's
|
|
691
|
+
* bindings. But a name that is *present* and blank is worse than absent: it
|
|
692
|
+
* looks like a handle at the call site and matches nothing, so
|
|
693
|
+
* `removeOnboardingGuide('')` would silently do nothing. That is an error.
|
|
694
|
+
*
|
|
695
|
+
* Whitespace around a name is trimmed by the host before it is compared, so
|
|
696
|
+
* `" setup "` and `"setup"` are the same handle; a name carrying padding is
|
|
697
|
+
* only warned about, since it works but will not look like what the author
|
|
698
|
+
* typed in a log line.
|
|
699
|
+
*
|
|
700
|
+
* @param guide - The guide being validated.
|
|
701
|
+
* @param errors - Collector for blocking problems.
|
|
702
|
+
* @param warnings - Collector for advisory problems.
|
|
703
|
+
*/
|
|
704
|
+
function validateGuideName(guide, errors, warnings) {
|
|
705
|
+
if (guide.name === undefined)
|
|
706
|
+
return;
|
|
707
|
+
if (typeof guide.name !== 'string' || guide.name.trim() === '') {
|
|
708
|
+
errors.push('`name` is present but blank — a guide either carries a handle an app can address ' +
|
|
709
|
+
'it by or omits the property entirely; an empty name matches nothing.');
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
if (guide.name !== guide.name.trim()) {
|
|
713
|
+
warnings.push(`\`name\` "${guide.name}" has leading or trailing whitespace, which the host trims — ` +
|
|
714
|
+
'the guide is addressed as `' + guide.name.trim() + '`.');
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* Checks {@link EnyoOnboardingV2Guide.notifyUser} against the guide's
|
|
719
|
+
* {@link EnyoOnboardingV2Guide.startVariant}.
|
|
720
|
+
*
|
|
721
|
+
* The flag asks the host to tell the end customer that a maintenance run is
|
|
722
|
+
* happening on their appliance, so it only means anything on
|
|
723
|
+
* {@link EnyoOnboardingV2StartVariant.Maintenance}. An installation guide has
|
|
724
|
+
* nobody to notify — the appliance does not exist yet and the installer is
|
|
725
|
+
* standing in front of the device — so setting it there is a warning, not an
|
|
726
|
+
* error: the host ignores the value, but it is a sign the wrong variant was
|
|
727
|
+
* chosen. Leaving it unset is always fine; it defaults to `false`.
|
|
728
|
+
*
|
|
729
|
+
* @param guide - The guide being validated.
|
|
730
|
+
* @param warnings - Collector for advisory problems.
|
|
731
|
+
*/
|
|
732
|
+
function validateUserNotification(guide, warnings) {
|
|
733
|
+
if (guide.notifyUser === undefined)
|
|
734
|
+
return;
|
|
735
|
+
if (guide.startVariant === enyo_onboarding_v2_js_1.EnyoOnboardingV2StartVariant.Maintenance)
|
|
736
|
+
return;
|
|
737
|
+
warnings.push('`notifyUser` is set on a `' +
|
|
738
|
+
`${guide.startVariant}` +
|
|
739
|
+
'` guide and is ignored — only a `' +
|
|
740
|
+
`${enyo_onboarding_v2_js_1.EnyoOnboardingV2StartVariant.Maintenance}` +
|
|
741
|
+
'` guide notifies the end customer about the run.');
|
|
742
|
+
}
|
|
684
743
|
/**
|
|
685
744
|
* Checks {@link EnyoOnboardingV2Guide.requiresNetworkScan} against what the guide
|
|
686
745
|
* actually does.
|
package/dist/cjs/index.cjs
CHANGED
|
@@ -88,6 +88,8 @@ __exportStar(require("./types/enyo-heating-rod-appliance.cjs"), exports);
|
|
|
88
88
|
__exportStar(require("./types/enyo-charger-appliance.cjs"), exports);
|
|
89
89
|
__exportStar(require("./types/enyo-charging-card.cjs"), exports);
|
|
90
90
|
__exportStar(require("./packages/energy-app-charging-card.cjs"), exports);
|
|
91
|
+
__exportStar(require("./types/enyo-charge.cjs"), exports);
|
|
92
|
+
__exportStar(require("./packages/energy-app-charge.cjs"), exports);
|
|
91
93
|
__exportStar(require("./types/enyo-battery-appliance.cjs"), exports);
|
|
92
94
|
__exportStar(require("./types/enyo-heatpump-appliance.cjs"), exports);
|
|
93
95
|
__exportStar(require("./types/enyo-inverter-appliance.cjs"), exports);
|
package/dist/cjs/index.d.cts
CHANGED
|
@@ -72,6 +72,8 @@ export * from './types/enyo-heating-rod-appliance.cjs';
|
|
|
72
72
|
export * from './types/enyo-charger-appliance.cjs';
|
|
73
73
|
export * from './types/enyo-charging-card.cjs';
|
|
74
74
|
export * from './packages/energy-app-charging-card.cjs';
|
|
75
|
+
export * from './types/enyo-charge.cjs';
|
|
76
|
+
export * from './packages/energy-app-charge.cjs';
|
|
75
77
|
export * from './types/enyo-battery-appliance.cjs';
|
|
76
78
|
export * from './types/enyo-heatpump-appliance.cjs';
|
|
77
79
|
export * from './types/enyo-inverter-appliance.cjs';
|
|
@@ -1,10 +1,94 @@
|
|
|
1
|
-
import { EnyoCharge, EnyoChargeFilter, EnyoDefaultChargeMode } from "../types/enyo-charge.cjs";
|
|
1
|
+
import { EnyoCharge, EnyoChargeFilter, EnyoDefaultChargeMode, EnyoStartChargeRequest, EnyoStopChargeRequest } from "../types/enyo-charge.cjs";
|
|
2
2
|
/**
|
|
3
3
|
* Interface for managing charging sessions in enyo packages.
|
|
4
4
|
* Provides operations for charge session tracking and management.
|
|
5
5
|
*/
|
|
6
6
|
export interface EnergyAppCharge {
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Opens a charging session for an appliance and returns it.
|
|
9
|
+
*
|
|
10
|
+
* Use this to start a session — not {@link save}. `save` writes whatever
|
|
11
|
+
* object it is given and offers no uniqueness guarantee, so two
|
|
12
|
+
* StartTransactions arriving a few milliseconds apart both pass an app-side
|
|
13
|
+
* "is one already active?" check and create two sessions for one plug-in.
|
|
14
|
+
* This call is handled by the host, which holds the invariant that an
|
|
15
|
+
* appliance has at most one active charge.
|
|
16
|
+
*
|
|
17
|
+
* **Idempotent.** When a session is already active for the same
|
|
18
|
+
* `applianceId` + `transactionId`, that session is returned unchanged
|
|
19
|
+
* rather than a second one being created — a repeated StartTransaction is
|
|
20
|
+
* safe. A session that is active on the appliance under a *different*
|
|
21
|
+
* transaction ID is treated as over: the host finalises it with best-effort
|
|
22
|
+
* end values before opening this one. If it is really the same physical
|
|
23
|
+
* session continuing under a new transaction ID (a reconnect, a
|
|
24
|
+
* re-authorization), use {@link addTransactionIdToActiveCharge} instead.
|
|
25
|
+
*
|
|
26
|
+
* The returned charge carries its `id`, so the session can be updated and
|
|
27
|
+
* later stopped without a {@link findActiveCharge} round-trip first.
|
|
28
|
+
*
|
|
29
|
+
* **Required permission:** `Charge`.
|
|
30
|
+
*
|
|
31
|
+
* @param request - What is known at plug-in time.
|
|
32
|
+
* @returns Promise resolving to the started session — or the session that
|
|
33
|
+
* was already running for this appliance and transaction.
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ```typescript
|
|
37
|
+
* const charge = await energyApp.useCharge().startCharge({
|
|
38
|
+
* applianceId,
|
|
39
|
+
* transactionId: ocppTransactionId,
|
|
40
|
+
* meterStartValueWh: meterValue,
|
|
41
|
+
* connectorId: 1,
|
|
42
|
+
* });
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
startCharge: (request: EnyoStartChargeRequest) => Promise<EnyoCharge>;
|
|
46
|
+
/**
|
|
47
|
+
* Closes a charging session and returns the final record.
|
|
48
|
+
*
|
|
49
|
+
* The host does the arithmetic, and that is the point of this call: it
|
|
50
|
+
* derives {@link EnyoCharge.totalEnergyKwh} and
|
|
51
|
+
* {@link EnyoCharge.paidPriceEuroCent} from the session's meter readings
|
|
52
|
+
* and the electricity tariff in force while the energy flowed, then moves
|
|
53
|
+
* the session to a terminal status and notifies
|
|
54
|
+
* {@link listenForChargeStopped}. An app must not price a session itself —
|
|
55
|
+
* totals computed app-side would differ between apps, and a customer's bill
|
|
56
|
+
* would depend on which app happened to close the charge.
|
|
57
|
+
*
|
|
58
|
+
* Supply readings, not totals: `meterEndValueWh` and, when the charger
|
|
59
|
+
* reports it, `energyDeliveredWh`. Anything an app writes into
|
|
60
|
+
* `paidPriceEuroCent` via {@link save} is overwritten here.
|
|
61
|
+
*
|
|
62
|
+
* Stopping a session that is already in a terminal status is a no-op and
|
|
63
|
+
* returns the stored record — a duplicate StopTransaction will not re-price
|
|
64
|
+
* a finished charge.
|
|
65
|
+
*
|
|
66
|
+
* **Required permission:** `Charge`.
|
|
67
|
+
*
|
|
68
|
+
* @param chargeId - The session to close, as returned by
|
|
69
|
+
* {@link startCharge} or {@link findActiveCharge}.
|
|
70
|
+
* @param request - How the session ended.
|
|
71
|
+
* @returns Promise resolving to the final charge record, totals included.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```typescript
|
|
75
|
+
* const finished = await energyApp.useCharge().stopCharge(charge.id, {
|
|
76
|
+
* meterEndValueWh: meterValue,
|
|
77
|
+
* energyDeliveredWh: stopTransaction.energyWh,
|
|
78
|
+
* });
|
|
79
|
+
* console.log(`${finished.totalEnergyKwh} kWh for ${finished.paidPriceEuroCent} ct`);
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
stopCharge: (chargeId: string, request: EnyoStopChargeRequest) => Promise<EnyoCharge>;
|
|
83
|
+
/**
|
|
84
|
+
* Save or update a charging session in the system.
|
|
85
|
+
*
|
|
86
|
+
* This is a whole-object write for a session that already exists — a
|
|
87
|
+
* changed vehicle, a corrected reading. Use {@link startCharge} to open a
|
|
88
|
+
* session and {@link stopCharge} to close one: calling this without a
|
|
89
|
+
* `chargeId` creates a row with no uniqueness guarantee, and writing
|
|
90
|
+
* terminal values by hand skips the host's energy and cost calculation.
|
|
91
|
+
*/
|
|
8
92
|
save: (charge: Omit<EnyoCharge, 'id'>, chargeId?: string) => Promise<void>;
|
|
9
93
|
/** Get a list of charging sessions with optional filtering */
|
|
10
94
|
list: (filter?: EnyoChargeFilter) => Promise<EnyoCharge[]>;
|
|
@@ -1,6 +1,28 @@
|
|
|
1
1
|
import type { EnyoOnboardingV2GuidesRequest, EnyoOnboardingV2GuidesResult } from '../types/enyo-onboarding-v2-provider.cjs';
|
|
2
2
|
import type { EnyoOnboardingV2DynamicRequest, EnyoOnboardingV2DynamicResult } from '../types/enyo-onboarding-v2-dynamic.cjs';
|
|
3
3
|
import type { EnyoOnboardingV2AdditionalSetupRequest, EnyoOnboardingV2AdditionalSetupResult } from '../types/enyo-onboarding-v2-additional-setup.cjs';
|
|
4
|
+
/**
|
|
5
|
+
* Which run of a named guide an app means.
|
|
6
|
+
*
|
|
7
|
+
* A guide name identifies the *flow*; this narrows it to one walk of that flow
|
|
8
|
+
* when more than one can be open at a time. A maintenance guide is bound to an
|
|
9
|
+
* appliance and its runs live in a lane of their own — one per appliance — so
|
|
10
|
+
* that is the only distinction the host needs.
|
|
11
|
+
*
|
|
12
|
+
* Omit it entirely for a guide that has one open run, which is every
|
|
13
|
+
* installation variant.
|
|
14
|
+
*/
|
|
15
|
+
export interface EnyoOnboardingV2RunSelector {
|
|
16
|
+
/**
|
|
17
|
+
* The appliance whose run is meant, for a guide bound to one
|
|
18
|
+
* ({@link EnyoOnboardingV2StartVariant.Maintenance}).
|
|
19
|
+
*
|
|
20
|
+
* Omitted on a maintenance guide, the call addresses that guide's single
|
|
21
|
+
* open run when there is exactly one and is rejected when there are
|
|
22
|
+
* several — an ambiguous "complete the run" must not close an arbitrary one.
|
|
23
|
+
*/
|
|
24
|
+
applianceId?: string;
|
|
25
|
+
}
|
|
4
26
|
/**
|
|
5
27
|
* Handler the host calls to collect every onboarding guide (v2) an app ships.
|
|
6
28
|
*
|
|
@@ -196,6 +218,124 @@ export interface EnergyAppOnboardingV2 {
|
|
|
196
218
|
* @returns Promise that resolves once the host has taken the new answer.
|
|
197
219
|
*/
|
|
198
220
|
refreshOnboardingGuides(): Promise<void>;
|
|
221
|
+
/**
|
|
222
|
+
* Retires one guide by name, without the app restating its whole set.
|
|
223
|
+
*
|
|
224
|
+
* The ordinary way to retire a guide is to leave it out of the next
|
|
225
|
+
* {@link EnyoOnboardingV2GuidesHandler} answer, and that remains the right
|
|
226
|
+
* choice when the app's guide set is a static list in its source. This is
|
|
227
|
+
* for the case that answer cannot express: a guide the app decided to
|
|
228
|
+
* withdraw *now* — a vendor account was unlinked, an appliance it was bound
|
|
229
|
+
* to is gone — where waiting for the host's next pull means an installer
|
|
230
|
+
* can still start a flow the app can no longer serve.
|
|
231
|
+
*
|
|
232
|
+
* Names the guide by its {@link EnyoOnboardingV2Guide.name}, so only a
|
|
233
|
+
* guide that carries one can be retired this way. A guide without a name is
|
|
234
|
+
* addressable only as part of the complete answer.
|
|
235
|
+
*
|
|
236
|
+
* **The handler is still the source of truth.** This drops the guide from
|
|
237
|
+
* the host's cache; it does not stop the app from offering it again. If the
|
|
238
|
+
* handler keeps returning the guide, the next pull brings it back — so
|
|
239
|
+
* remove it from what the handler builds as well, or the retirement lasts
|
|
240
|
+
* only until the next sync.
|
|
241
|
+
*
|
|
242
|
+
* Runs already walking the guide are not touched: a guide is retired for the
|
|
243
|
+
* *next* installer, and pulling a flow out from under one already inside it
|
|
244
|
+
* would strand them mid-installation. Use {@link removeOnboardingRun} to end
|
|
245
|
+
* a run.
|
|
246
|
+
*
|
|
247
|
+
* Removing a guide the host does not know — wrong name, already retired — is
|
|
248
|
+
* a no-op rather than an error.
|
|
249
|
+
*
|
|
250
|
+
* This API is available to every app — it is not permission-gated.
|
|
251
|
+
*
|
|
252
|
+
* @param name - The {@link EnyoOnboardingV2Guide.name} of the guide to retire.
|
|
253
|
+
* @returns Promise that resolves once the host has dropped the guide.
|
|
254
|
+
*
|
|
255
|
+
* @example
|
|
256
|
+
* ```typescript
|
|
257
|
+
* await energyApp.useOnboardingV2().removeOnboardingGuide('vendor-cloud-setup');
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
removeOnboardingGuide(name: string): Promise<void>;
|
|
261
|
+
/**
|
|
262
|
+
* Marks the run walking a named guide as **completed**.
|
|
263
|
+
*
|
|
264
|
+
* For the flow that finished somewhere other than on the installer's
|
|
265
|
+
* screen. A guide normally completes when the walk reaches a success
|
|
266
|
+
* target — the installer taps through to the end. But an app sometimes
|
|
267
|
+
* learns the goal was met by another route: the wallbox connected over OCPP
|
|
268
|
+
* by itself, the vendor cloud confirmed the pairing, the appliance the
|
|
269
|
+
* maintenance run was servicing reported healthy. Leaving that run open
|
|
270
|
+
* shows the customer an installation still in progress that nobody intends
|
|
271
|
+
* to continue.
|
|
272
|
+
*
|
|
273
|
+
* The run is closed as a **success**: it leaves the "open" set, stops being
|
|
274
|
+
* offered for resumption, and counts as a finished installation. Use
|
|
275
|
+
* {@link removeOnboardingRun} for a flow that ended without achieving
|
|
276
|
+
* anything — the two are not interchangeable, and reporting an abandoned
|
|
277
|
+
* setup as completed is how a broken installation looks fine on a dashboard.
|
|
278
|
+
*
|
|
279
|
+
* Completing a run that is already finished — completed or removed — is a
|
|
280
|
+
* no-op: the first outcome stands, and a late confirmation does not reopen
|
|
281
|
+
* or re-close a run. So is naming a guide with no open run at all.
|
|
282
|
+
*
|
|
283
|
+
* Not permission-gated, like the rest of this API: a guide name is resolved
|
|
284
|
+
* within the calling package, so an app can only reach runs of guides it
|
|
285
|
+
* ships itself.
|
|
286
|
+
*
|
|
287
|
+
* @param name - The {@link EnyoOnboardingV2Guide.name} of the guide whose run
|
|
288
|
+
* should be completed.
|
|
289
|
+
* @param selector - Which run, when the guide can have more than one open.
|
|
290
|
+
* @returns Promise that resolves once the host has closed the run.
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* ```typescript
|
|
294
|
+
* // The wallbox connected on its own — the installer never reached the last step.
|
|
295
|
+
* ocpp.onChargePointConnect(async () => {
|
|
296
|
+
* await energyApp.useOnboardingV2().completeOnboardingRun('wallbox-ocpp-setup');
|
|
297
|
+
* });
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
completeOnboardingRun(name: string, selector?: EnyoOnboardingV2RunSelector): Promise<void>;
|
|
301
|
+
/**
|
|
302
|
+
* Ends the run walking a named guide **without** completing it.
|
|
303
|
+
*
|
|
304
|
+
* The counterpart to {@link completeOnboardingRun}, for a flow that is over
|
|
305
|
+
* but achieved nothing: the device it was setting up was removed, the
|
|
306
|
+
* appliance a maintenance run was servicing no longer exists, the app can no
|
|
307
|
+
* longer serve the guide the run is walking. The run leaves the open set as
|
|
308
|
+
* abandoned rather than successful, so it stops being offered for resumption
|
|
309
|
+
* and is not counted as a finished installation.
|
|
310
|
+
*
|
|
311
|
+
* This ends a *run*, not a guide. The guide stays available and a new run
|
|
312
|
+
* can start on it immediately — that is the point when a stuck run is
|
|
313
|
+
* blocking a fresh attempt, since a device can have only one open run per
|
|
314
|
+
* flow. Use {@link removeOnboardingGuide} to withdraw the flow itself.
|
|
315
|
+
*
|
|
316
|
+
* An installer may be looking at the run when it is removed. Do this because
|
|
317
|
+
* the run genuinely cannot continue, not to tidy up: the screen ends the
|
|
318
|
+
* setup under them, and nothing explains why.
|
|
319
|
+
*
|
|
320
|
+
* Removing a run that is already finished, or naming a guide with no open
|
|
321
|
+
* run, is a no-op.
|
|
322
|
+
*
|
|
323
|
+
* Not permission-gated, like the rest of this API: a guide name is resolved
|
|
324
|
+
* within the calling package, so an app can only reach runs of guides it
|
|
325
|
+
* ships itself.
|
|
326
|
+
*
|
|
327
|
+
* @param name - The {@link EnyoOnboardingV2Guide.name} of the guide whose run
|
|
328
|
+
* should be removed.
|
|
329
|
+
* @param selector - Which run, when the guide can have more than one open.
|
|
330
|
+
* @returns Promise that resolves once the host has ended the run.
|
|
331
|
+
*
|
|
332
|
+
* @example
|
|
333
|
+
* ```typescript
|
|
334
|
+
* // The appliance this maintenance flow services was deleted.
|
|
335
|
+
* await energyApp.useOnboardingV2().removeOnboardingRun('wallbox-service', {applianceId});
|
|
336
|
+
* ```
|
|
337
|
+
*/
|
|
338
|
+
removeOnboardingRun(name: string, selector?: EnyoOnboardingV2RunSelector): Promise<void>;
|
|
199
339
|
/**
|
|
200
340
|
* Registers the handler the host calls to resolve dynamic block values
|
|
201
341
|
* (`ocpp-url`, `device-ip`) while a step is rendered.
|
|
@@ -11,16 +11,37 @@ export declare enum EnyoChargeStatus {
|
|
|
11
11
|
Failed = "Failed"
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
*
|
|
14
|
+
* A single sample recorded during a charging session — the charger's meter
|
|
15
|
+
* reading at one instant, plus whatever electrical detail it reported with it.
|
|
16
|
+
*
|
|
17
|
+
* `timestamp` and `valueWh` are the load-bearing pair: every energy total and
|
|
18
|
+
* every cost in a charge is a delta between two samples' `valueWh`, walked in
|
|
19
|
+
* timestamp order (see `calculateChargeCost()`). The rest is detail the charger
|
|
20
|
+
* may or may not report.
|
|
21
|
+
*
|
|
22
|
+
* **Pricing fields are normally filled in by the host, not the app.** Leave
|
|
23
|
+
* {@link pricePerKwh} and {@link chargingCostEuro} unset and the host resolves
|
|
24
|
+
* the tariff for the sample's 15-minute slot and derives the incremental cost
|
|
25
|
+
* itself; set them and your values are kept. Deriving them app-side means
|
|
26
|
+
* reimplementing the tariff lookup, and getting the cent-native unit of
|
|
27
|
+
* `pricePerKwh` wrong there is a silent factor-100 error in the customer's bill.
|
|
15
28
|
*/
|
|
16
29
|
export interface ChargeMeterValue {
|
|
17
30
|
/** Timestamp when the value was recorded */
|
|
18
31
|
timestamp: Date;
|
|
19
32
|
/** Energy value in Watt hours */
|
|
20
33
|
valueWh: number;
|
|
21
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Price per kWh at the time of measurement, in **Euro cents** (ct/kWh) —
|
|
36
|
+
* not Euro. Usually left unset for the host to resolve from the appliance's
|
|
37
|
+
* electricity tariff; see the note on {@link ChargeMeterValue}.
|
|
38
|
+
*/
|
|
22
39
|
pricePerKwh?: number;
|
|
23
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* Incremental charging cost in **Euro** for this sample — the energy
|
|
42
|
+
* delivered since the previous sample priced at {@link pricePerKwh}, not a
|
|
43
|
+
* running total. Usually left unset for the host to derive.
|
|
44
|
+
*/
|
|
24
45
|
chargingCostEuro?: number;
|
|
25
46
|
/** Current on phase 1 in Amperes */
|
|
26
47
|
currentPhase1: number;
|
|
@@ -28,6 +49,23 @@ export interface ChargeMeterValue {
|
|
|
28
49
|
currentPhase2?: number;
|
|
29
50
|
/** Current on phase 3 in Amperes */
|
|
30
51
|
currentPhase3?: number;
|
|
52
|
+
/**
|
|
53
|
+
* Active charging power in Watt at the moment of the sample.
|
|
54
|
+
*
|
|
55
|
+
* Optional because not every charger reports it and it is derivable from
|
|
56
|
+
* the `valueWh` deltas — but only coarsely, at the sampling interval, which
|
|
57
|
+
* is why a charger that does report it should write it here. When omitted,
|
|
58
|
+
* the host keeps whatever power it already recorded for a sample with this
|
|
59
|
+
* timestamp (its own meter-value stream may have seen one) rather than
|
|
60
|
+
* overwriting it with a zero.
|
|
61
|
+
*/
|
|
62
|
+
powerW?: number;
|
|
63
|
+
/** Voltage on phase 1 in Volt, when the charger reports it. */
|
|
64
|
+
voltageL1?: number;
|
|
65
|
+
/** Voltage on phase 2 in Volt, when the charger reports it. */
|
|
66
|
+
voltageL2?: number;
|
|
67
|
+
/** Voltage on phase 3 in Volt, when the charger reports it. */
|
|
68
|
+
voltageL3?: number;
|
|
31
69
|
}
|
|
32
70
|
/**
|
|
33
71
|
* Represents a charging session in the enyo system.
|
|
@@ -80,6 +118,77 @@ export interface EnyoCharge {
|
|
|
80
118
|
/** Target completion time for the charging session as an ISO 8601 timestamp */
|
|
81
119
|
completeAtIsoTimestamp?: string;
|
|
82
120
|
}
|
|
121
|
+
/**
|
|
122
|
+
* What is known when a charging session opens — the input to
|
|
123
|
+
* {@link EnergyAppCharge.startCharge}.
|
|
124
|
+
*
|
|
125
|
+
* Everything here is fact at plug-in time. The totals a session is judged by
|
|
126
|
+
* ({@link EnyoCharge.totalEnergyKwh}, {@link EnyoCharge.paidPriceEuroCent}) are
|
|
127
|
+
* absent on purpose: they are the host's to compute when the session ends, from
|
|
128
|
+
* the meter readings and the tariff in force while the energy flowed.
|
|
129
|
+
*/
|
|
130
|
+
export interface EnyoStartChargeRequest {
|
|
131
|
+
/** The appliance (charger) running the session. */
|
|
132
|
+
applianceId: string;
|
|
133
|
+
/**
|
|
134
|
+
* The charger's transaction ID for this session (OCPP `transactionId` or
|
|
135
|
+
* the protocol's equivalent).
|
|
136
|
+
*
|
|
137
|
+
* Together with `applianceId` this identifies the session: two chargers may
|
|
138
|
+
* independently issue the same transaction ID, so it is unique per
|
|
139
|
+
* appliance, not globally. It is also the idempotency key —
|
|
140
|
+
* {@link EnergyAppCharge.startCharge} returns the existing session rather
|
|
141
|
+
* than opening a second one when this pair is already active.
|
|
142
|
+
*/
|
|
143
|
+
transactionId: string;
|
|
144
|
+
/** When charging started. Defaults to the moment the host handles the call. */
|
|
145
|
+
startTime?: Date;
|
|
146
|
+
/** The charger's meter reading at session start, in Watt hours. */
|
|
147
|
+
meterStartValueWh?: number;
|
|
148
|
+
/** Connector on the charge point the vehicle is plugged into. */
|
|
149
|
+
connectorId?: number;
|
|
150
|
+
/** The charging card that authorized the session, if any. */
|
|
151
|
+
chargingCardId?: string;
|
|
152
|
+
/** The vehicle being charged, if known. */
|
|
153
|
+
vehicleId?: string;
|
|
154
|
+
/** Number of phases charging over. Defaults to 3. */
|
|
155
|
+
numberOfPhases?: number;
|
|
156
|
+
/** Charging mode to apply. Defaults to the appliance's configured default. */
|
|
157
|
+
chargeMode?: EnyoChargeModeEnum;
|
|
158
|
+
/** Target completion time as an ISO 8601 timestamp, for optimized modes. */
|
|
159
|
+
completeAtIsoTimestamp?: string;
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* How a charging session ended — the input to
|
|
163
|
+
* {@link EnergyAppCharge.stopCharge}.
|
|
164
|
+
*
|
|
165
|
+
* Meter readings, not totals: give the host what the charger reported and it
|
|
166
|
+
* derives the delivered energy and the price. See
|
|
167
|
+
* {@link EnergyAppCharge.stopCharge}.
|
|
168
|
+
*/
|
|
169
|
+
export interface EnyoStopChargeRequest {
|
|
170
|
+
/** When charging ended. Defaults to the moment the host handles the call. */
|
|
171
|
+
endTime?: Date;
|
|
172
|
+
/** The charger's meter reading at session end, in Watt hours. */
|
|
173
|
+
meterEndValueWh?: number;
|
|
174
|
+
/**
|
|
175
|
+
* Energy delivered over the session in Watt hours, when the charger reports
|
|
176
|
+
* it directly (OCPP `StopTransaction`).
|
|
177
|
+
*
|
|
178
|
+
* Preferred over the meter delta when present — a charger that meters its
|
|
179
|
+
* own session knows better than a subtraction across two readings that may
|
|
180
|
+
* span a meter reset.
|
|
181
|
+
*/
|
|
182
|
+
energyDeliveredWh?: number;
|
|
183
|
+
/**
|
|
184
|
+
* How the session ended. Defaults to {@link EnyoChargeStatus.Completed};
|
|
185
|
+
* pass {@link EnyoChargeStatus.Failed} for a session cut short by a fault.
|
|
186
|
+
*
|
|
187
|
+
* Both are terminal and both fire the stopped listener — a handler that
|
|
188
|
+
* assumes success will mis-report faulted sessions.
|
|
189
|
+
*/
|
|
190
|
+
status?: EnyoChargeStatus;
|
|
191
|
+
}
|
|
83
192
|
/**
|
|
84
193
|
* Represents a single entry in a charging schedule.
|
|
85
194
|
* Defines a time-bound current limit for smart charging.
|
|
@@ -851,6 +851,35 @@ export interface EnyoOnboardingV2Step {
|
|
|
851
851
|
* usually bound at registration/publish time and may be omitted here.
|
|
852
852
|
*/
|
|
853
853
|
export interface EnyoOnboardingV2Guide {
|
|
854
|
+
/**
|
|
855
|
+
* Stable handle for this guide — the name the app calls it by when it wants
|
|
856
|
+
* to act on it later.
|
|
857
|
+
*
|
|
858
|
+
* A guide is normally never addressed: guides are pulled, the app's answer
|
|
859
|
+
* is the complete set, and a guide is retired by leaving it out. This exists
|
|
860
|
+
* for the cases where an app has to say something *about one specific
|
|
861
|
+
* guide* instead of restating the whole set — retiring it with
|
|
862
|
+
* {@link EnergyAppOnboardingV2.removeOnboardingGuide}, or completing or
|
|
863
|
+
* removing the run walking it
|
|
864
|
+
* ({@link EnergyAppOnboardingV2.completeOnboardingRun},
|
|
865
|
+
* {@link EnergyAppOnboardingV2.removeOnboardingRun}).
|
|
866
|
+
*
|
|
867
|
+
* **Stable once shipped, like a step's `name`.** A run in progress is
|
|
868
|
+
* anchored to it, so renaming a guide between two package versions strands
|
|
869
|
+
* whatever was paused inside it. Choose a kebab-case slug that describes the
|
|
870
|
+
* flow rather than the hardware it currently applies to
|
|
871
|
+
* (`wallbox-ocpp-setup`, not `acme-ac22`), and keep it when the bindings
|
|
872
|
+
* change.
|
|
873
|
+
*
|
|
874
|
+
* Unique within the app's answer — two guides sharing a name cannot be told
|
|
875
|
+
* apart, and {@link validateOnboardingV2GuidesResult} rejects the answer.
|
|
876
|
+
*
|
|
877
|
+
* Optional. Omit it and the host files the guide under a name derived from
|
|
878
|
+
* what it binds to (vendor, models, start variant, and the appliance on a
|
|
879
|
+
* maintenance guide) exactly as before — that keeps working, it just cannot
|
|
880
|
+
* be named by an app that never chose a name.
|
|
881
|
+
*/
|
|
882
|
+
name?: string;
|
|
854
883
|
/** Translated display title (de/en). */
|
|
855
884
|
title: EnyoOnboardingTranslatedContent[];
|
|
856
885
|
/** Which start situation this guide covers. */
|
|
@@ -903,6 +932,28 @@ export interface EnyoOnboardingV2Guide {
|
|
|
903
932
|
* {@link validateOnboardingGuideV2} instead of by the compiler.
|
|
904
933
|
*/
|
|
905
934
|
applianceId?: string;
|
|
935
|
+
/**
|
|
936
|
+
* Whether the end customer is told about this maintenance run — **only
|
|
937
|
+
* meaningful on** {@link EnyoOnboardingV2StartVariant.Maintenance}, and
|
|
938
|
+
* ignored on every other variant.
|
|
939
|
+
*
|
|
940
|
+
* A maintenance run touches an appliance the customer already lives with:
|
|
941
|
+
* it may take the wallbox offline for a few minutes, change how the
|
|
942
|
+
* inverter behaves, or simply happen while nobody is watching. Set this to
|
|
943
|
+
* `true` when the customer should hear about it — the host sends them a
|
|
944
|
+
* notification for the run — and leave it unset when the work is invisible
|
|
945
|
+
* to them and a message would only be noise.
|
|
946
|
+
*
|
|
947
|
+
* Defaults to `false`: a guide says nothing unless it asks to. The
|
|
948
|
+
* installation variants have no customer to notify — there is no appliance
|
|
949
|
+
* yet, and the installer is standing in front of the device — so a guide
|
|
950
|
+
* that sets this anyway is warned about and the value ignored.
|
|
951
|
+
*
|
|
952
|
+
* Optional in the type because one interface serves all four variants; the
|
|
953
|
+
* variant-dependent meaning is enforced by
|
|
954
|
+
* {@link validateOnboardingGuideV2} instead of by the compiler.
|
|
955
|
+
*/
|
|
956
|
+
notifyUser?: boolean;
|
|
906
957
|
/** Optional vendor binding (catalog id). Usually set at publish time. */
|
|
907
958
|
vendorId?: string;
|
|
908
959
|
/** Optional model bindings (catalog ids). Usually set at publish time. */
|
package/dist/cjs/version.cjs
CHANGED