iobroker.meter-statistics 0.1.1 → 0.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/LICENSE +4 -4
- package/README.md +86 -96
- package/build/calculator.js +7 -2
- package/build/calculator.js.map +1 -1
- package/build/main.js +13 -4
- package/build/main.js.map +1 -1
- package/build/period.js +6 -4
- package/build/period.js.map +1 -1
- package/build/round.js +0 -2
- package/io-package.json +22 -5
- package/package.json +32 -29
package/LICENSE
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
GNU GENERAL PUBLIC LICENSE
|
|
2
2
|
Version 3, 29 June 2007
|
|
3
3
|
|
|
4
|
-
Copyright (C)
|
|
4
|
+
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
|
5
5
|
Everyone is permitted to copy and distribute verbatim copies
|
|
6
6
|
of this license document, but changing it is not allowed.
|
|
7
7
|
|
|
@@ -631,8 +631,8 @@ to attach them to the start of each source file to most effectively
|
|
|
631
631
|
state the exclusion of warranty; and each file should have at least
|
|
632
632
|
the "copyright" line and a pointer to where the full notice is found.
|
|
633
633
|
|
|
634
|
-
|
|
635
|
-
Copyright (C)
|
|
634
|
+
ioBroker.meter-statistics - Calculate statistics from any smart meter
|
|
635
|
+
Copyright (C) 2023-2026 jb-io
|
|
636
636
|
|
|
637
637
|
This program is free software: you can redistribute it and/or modify
|
|
638
638
|
it under the terms of the GNU General Public License as published by
|
|
@@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
|
|
|
652
652
|
If the program does terminal interaction, make it output a short
|
|
653
653
|
notice like this when it starts in an interactive mode:
|
|
654
654
|
|
|
655
|
-
|
|
655
|
+
ioBroker.meter-statistics Copyright (C) 2023-2026 jb-io
|
|
656
656
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
|
657
657
|
This is free software, and you are welcome to redistribute it
|
|
658
658
|
under certain conditions; type `show c' for details.
|
package/README.md
CHANGED
|
@@ -13,107 +13,97 @@
|
|
|
13
13
|
|
|
14
14
|
## meter-statistics adapter for ioBroker
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
`
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
Since you set up `dev-server`, you can use it to run, test and debug your adapter.
|
|
96
|
-
|
|
97
|
-
You may start `dev-server` by calling from your dev directory:
|
|
98
|
-
```bash
|
|
99
|
-
dev-server watch
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
The ioBroker.admin interface will then be available at http://localhost:8081/
|
|
103
|
-
|
|
104
|
-
Please refer to the [`dev-server` documentation](https://github.com/ioBroker/dev-server#command-line) for more details.
|
|
105
|
-
|
|
106
|
-
## Open Tasks
|
|
107
|
-
* [TODO] Insert Translation
|
|
108
|
-
* [TODO] Create README
|
|
109
|
-
* [TODO] Respect start value date
|
|
110
|
-
* [TODO] Automated update of startvalue on year change
|
|
16
|
+
Calculates consumption and cost statistics for the current year from any meter reading
|
|
17
|
+
(electricity, gas, water, ...): consumption so far, average per day, predicted consumption for
|
|
18
|
+
the year, costs, paid advance payments, balance and a recommended advance payment.
|
|
19
|
+
|
|
20
|
+
## Requirements
|
|
21
|
+
|
|
22
|
+
- One or more states with a numeric meter reading (e.g. from a smart meter adapter)
|
|
23
|
+
- Node.js >= 22
|
|
24
|
+
- js-controller >= 6.0.11, admin >= 7.6.20
|
|
25
|
+
|
|
26
|
+
The adapter is a schedule adapter: it runs once a day at midnight (`0 0 * * *`), writes the
|
|
27
|
+
results and stops.
|
|
28
|
+
|
|
29
|
+
## Configuration
|
|
30
|
+
|
|
31
|
+
### Units
|
|
32
|
+
|
|
33
|
+
#### Unit of meter value
|
|
34
|
+
|
|
35
|
+
Unit of the meter readings, e.g. `kWh` (default) or `m³`.
|
|
36
|
+
|
|
37
|
+
#### Unit of payment
|
|
38
|
+
|
|
39
|
+
Currency, e.g. `€` (default).
|
|
40
|
+
|
|
41
|
+
### Payment
|
|
42
|
+
|
|
43
|
+
#### Payment value
|
|
44
|
+
|
|
45
|
+
Amount of a single advance payment.
|
|
46
|
+
|
|
47
|
+
#### Payment count
|
|
48
|
+
|
|
49
|
+
Number of advance payments per year, e.g. `12` for monthly payments.
|
|
50
|
+
|
|
51
|
+
#### Base price that is paid once
|
|
52
|
+
|
|
53
|
+
Base price per year. It is distributed to the meters in proportion to their consumption.
|
|
54
|
+
|
|
55
|
+
#### Payment correction offset
|
|
56
|
+
|
|
57
|
+
Amount that is added to the paid sum, e.g. a credit carried over from the last bill.
|
|
58
|
+
|
|
59
|
+
### Meters
|
|
60
|
+
|
|
61
|
+
#### Name of summary node
|
|
62
|
+
|
|
63
|
+
Name of the node with the sum of all meters, default `summary`.
|
|
64
|
+
|
|
65
|
+
#### Meter table
|
|
66
|
+
|
|
67
|
+
| Column | Description |
|
|
68
|
+
|---|---|
|
|
69
|
+
| Object ID | State with the meter reading |
|
|
70
|
+
| Meter alias | Name of the meter in the object tree |
|
|
71
|
+
| Price per unit | Price per unit of the meter value |
|
|
72
|
+
|
|
73
|
+
## States
|
|
74
|
+
|
|
75
|
+
| State | Description |
|
|
76
|
+
|---|---|
|
|
77
|
+
| `configuration.<alias>.startValue` | Meter reading at the start of the period (writable). Set automatically to the current reading on the first run. |
|
|
78
|
+
| `configuration.<alias>.readingDateTime` | Time of the start value reading (information only, not used in the calculation) |
|
|
79
|
+
| `meters.<alias>.consumptionTotal` | Consumption since the start value |
|
|
80
|
+
| `meters.<alias>.consumptionAverage` | Average consumption per day |
|
|
81
|
+
| `meters.<alias>.consumptionPredictedTotal` | Predicted consumption for the whole year |
|
|
82
|
+
| `meters.<alias>.costs` | Costs so far (consumption × price per unit + share of the base price) |
|
|
83
|
+
| `meters.<alias>.paid` | Share of the advance payments paid so far |
|
|
84
|
+
| `meters.<alias>.balance` | `paid - costs` |
|
|
85
|
+
| `meters.<alias>.recommendedPayment` | Recommended advance payment per payment interval |
|
|
86
|
+
| `meters.<summary>.*` | Sum of all meters (same states as above) |
|
|
87
|
+
|
|
88
|
+
## Behaviour worth knowing
|
|
89
|
+
|
|
90
|
+
- The period is the current calendar year. Paid advance payments and the base price are
|
|
91
|
+
counted pro rata for the elapsed part of the year.
|
|
92
|
+
- Set `startValue` to the meter reading at the start of the billing year; on the first run it
|
|
93
|
+
is initialized with the current reading.
|
|
94
|
+
- Base price and paid sum are split between the meters in proportion to their consumption.
|
|
111
95
|
|
|
112
96
|
## Changelog
|
|
113
97
|
<!--
|
|
114
98
|
Placeholder for the next version (at the beginning of the line):
|
|
115
99
|
### **WORK IN PROGRESS**
|
|
116
100
|
-->
|
|
101
|
+
### 0.2.0 (2026-11-28)
|
|
102
|
+
* [TASK] Harmonize project structure, tooling and tests
|
|
103
|
+
* [TASK] Require @iobroker/adapter-core ^2.6.8 (previously merged on GitHub by Dependabot)
|
|
104
|
+
* [TASK] Require js-controller >= 6.0.11 and admin >= 7.6.20
|
|
105
|
+
* [TASK] Test on Node.js 22.x, 24.x and 26.x, publish to npm via trusted publishing and update the Dependabot configuration
|
|
106
|
+
|
|
117
107
|
### 0.1.1 (2023-03-29)
|
|
118
108
|
* [FEATURE] Add device icons
|
|
119
109
|
|
|
@@ -136,4 +126,4 @@ Please refer to the [`dev-server` documentation](https://github.com/ioBroker/dev
|
|
|
136
126
|
|
|
137
127
|
## License
|
|
138
128
|
|
|
139
|
-
[Licensed under GPLv3](LICENSE) Copyright (c) 2023 jb-io
|
|
129
|
+
[Licensed under GPLv3](LICENSE) Copyright (c) 2023-2026 jb-io
|
package/build/calculator.js
CHANGED
|
@@ -18,6 +18,10 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
return to;
|
|
19
19
|
};
|
|
20
20
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
25
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
26
|
mod
|
|
23
27
|
));
|
|
@@ -29,6 +33,9 @@ __export(calculator_exports, {
|
|
|
29
33
|
module.exports = __toCommonJS(calculator_exports);
|
|
30
34
|
var import_period = __toESM(require("./period"));
|
|
31
35
|
class Calculator {
|
|
36
|
+
summaryName;
|
|
37
|
+
config;
|
|
38
|
+
period;
|
|
32
39
|
constructor(config) {
|
|
33
40
|
this.period = new import_period.default();
|
|
34
41
|
this.config = config;
|
|
@@ -88,6 +95,4 @@ class Calculator {
|
|
|
88
95
|
return this.period.calculateExtrapolateValueForPeriod(costs) / this.config.paymentCount;
|
|
89
96
|
}
|
|
90
97
|
}
|
|
91
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
-
0 && (module.exports = {});
|
|
93
98
|
//# sourceMappingURL=calculator.js.map
|
package/build/calculator.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/calculator.ts"],
|
|
4
4
|
"sourcesContent": ["import {CalculatorConfig, MeterDefinition, MeterInfo, MeterInfoCollection, MeterState} from './lib/typedef';\nimport Period from './period';\n\nexport default class Calculator {\n\n private readonly summaryName: string;\n\n private readonly config: CalculatorConfig;\n private readonly period: Period;\n\n constructor(config: CalculatorConfig) {\n this.period = new Period();\n this.config = config;\n this.summaryName = config.summaryName;\n }\n\n private initMeterInfo(): MeterInfo {\n return {\n balance: 0,\n consumptionAverage: 0,\n consumptionPredictedTotal: 0,\n consumptionTotal: 0,\n costs: 0,\n paid: 0,\n recommendedPayment: 0,\n };\n }\n public calculateMeterInfos(meterStates: MeterState[]): MeterInfoCollection\n {\n const summary = this.initMeterInfo();\n const collection: MeterInfoCollection = {\n [this.summaryName]: summary,\n };\n\n const meters: Array<{info: MeterInfo, state: MeterState, definition: MeterDefinition}> = [];\n\n for (const state of meterStates) {\n const info = this.initMeterInfo();\n\n const definition = state.meter;\n collection[definition.alias] = info;\n\n meters.push({info, state, definition});\n }\n\n for (const {info, state} of meters) {\n // TODO use period depending on state.startValueDateTime\n // const startValueDateTime = state.startValueDateTime;\n info.consumptionTotal = state.consumption;\n info.consumptionAverage = this.period.calculateValuePerDay(state.consumption);\n info.consumptionPredictedTotal = this.period.calculateExtrapolateValueForPeriod(state.consumption);\n\n summary.consumptionTotal += info.consumptionTotal;\n summary.consumptionAverage += info.consumptionAverage;\n summary.consumptionPredictedTotal += info.consumptionPredictedTotal;\n }\n\n const basePrice = this.period.calculateElapsedAmountInPeriod(this.config.paymentBasePrice);\n const paid = this.calculatePaid();\n for (const {info, state, definition} of meters) {\n const factor = info.consumptionTotal / summary.consumptionTotal;\n\n info.costs = state.consumption * definition.pricePerUnit + basePrice * factor;\n info.paid = paid * factor;\n info.balance = info.paid - info.costs;\n info.recommendedPayment = this.calculateRecommendation(info.costs);\n\n summary.costs += info.costs;\n summary.paid += info.paid;\n summary.balance += info.balance;\n summary.recommendedPayment += info.recommendedPayment;\n }\n\n return collection;\n }\n\n\n private calculatePaid(): number {\n const config = this.config;\n return config.paymentCorrectionOffset + this.period.calculateElapsedAmountInPeriod(config.paymentValue * config.paymentCount);\n }\n\n private calculateRecommendation(costs: number): number {\n return this.period.calculateExtrapolateValueForPeriod(costs) / this.config.paymentCount;\n }\n\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,oBAAmB;AAEnB,MAAO,WAAyB;AAAA,EAEX;AAAA,EAEA;AAAA,EACA;AAAA,EAEjB,YAAY,QAA0B;AAClC,SAAK,SAAS,IAAI,cAAAA,QAAO;AACzB,SAAK,SAAS;AACd,SAAK,cAAc,OAAO;AAAA,EAC9B;AAAA,EAEQ,gBAA2B;AAC/B,WAAO;AAAA,MACH,SAAS;AAAA,MACT,oBAAoB;AAAA,MACpB,2BAA2B;AAAA,MAC3B,kBAAkB;AAAA,MAClB,OAAO;AAAA,MACP,MAAM;AAAA,MACN,oBAAoB;AAAA,IACxB;AAAA,EACJ;AAAA,EACO,oBAAoB,aAC3B;AACI,UAAM,UAAU,KAAK,cAAc;AACnC,UAAM,aAAkC;AAAA,MACpC,CAAC,KAAK,WAAW,GAAG;AAAA,IACxB;AAEA,UAAM,SAAmF,CAAC;AAE1F,eAAW,SAAS,aAAa;AAC7B,YAAM,OAAO,KAAK,cAAc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;
|
|
15
15
|
};
|
|
16
16
|
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
17
21
|
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
18
22
|
mod
|
|
19
23
|
));
|
|
@@ -21,16 +25,19 @@ var utils = __toESM(require("@iobroker/adapter-core"));
|
|
|
21
25
|
var import_calculator = __toESM(require("./calculator"));
|
|
22
26
|
var import_round = __toESM(require("./round"));
|
|
23
27
|
class MeterStatistics extends utils.Adapter {
|
|
28
|
+
unloaded = false;
|
|
29
|
+
pendingPromises = [];
|
|
24
30
|
constructor(options = {}) {
|
|
25
31
|
super({
|
|
26
32
|
...options,
|
|
27
33
|
name: "meter-statistics"
|
|
28
34
|
});
|
|
29
|
-
this.unloaded = false;
|
|
30
|
-
this.pendingPromises = [];
|
|
31
35
|
this.on("ready", this.onReady.bind(this));
|
|
32
36
|
this.on("unload", this.onUnload.bind(this));
|
|
33
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Is called when databases are connected and adapter received configuration.
|
|
40
|
+
*/
|
|
34
41
|
async onReady() {
|
|
35
42
|
await this.assertObjectsExist();
|
|
36
43
|
const meterStates = await this.getMeterStates();
|
|
@@ -236,14 +243,16 @@ class MeterStatistics extends utils.Adapter {
|
|
|
236
243
|
return promises;
|
|
237
244
|
}
|
|
238
245
|
end() {
|
|
239
|
-
if (this.unloaded)
|
|
240
|
-
return;
|
|
246
|
+
if (this.unloaded) return;
|
|
241
247
|
Promise.allSettled(this.pendingPromises).finally(() => {
|
|
242
248
|
if (this.stop) {
|
|
243
249
|
this.stop();
|
|
244
250
|
}
|
|
245
251
|
});
|
|
246
252
|
}
|
|
253
|
+
/**
|
|
254
|
+
* Is called when adapter shuts down - callback has to be called under any circumstances!
|
|
255
|
+
*/
|
|
247
256
|
onUnload(callback) {
|
|
248
257
|
this.unloaded = true;
|
|
249
258
|
try {
|
package/build/main.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/main.ts"],
|
|
4
4
|
"sourcesContent": ["/*\n * Created with @iobroker/create-adapter v2.3.0\n */\n\n// The adapter-core module gives you access to the core ioBroker functions\n// you need to create an adapter\nimport * as utils from '@iobroker/adapter-core';\nimport {MeterDefinition, MeterInfoCollection, MeterState} from './lib/typedef';\nimport Calculator from './calculator';\nimport Round from './round';\n\n// Load your modules here, e.g.:\n// import * as fs from \"fs\";\n\nclass MeterStatistics extends utils.Adapter {\n\n private unloaded = false;\n\n private pendingPromises: Array<Promise<any>> = [];\n\n public constructor(options: Partial<utils.AdapterOptions> = {}) {\n super({\n ...options,\n name: 'meter-statistics',\n });\n this.on('ready', this.onReady.bind(this));\n this.on('unload', this.onUnload.bind(this));\n }\n\n /**\n * Is called when databases are connected and adapter received configuration.\n */\n private async onReady(): Promise<void> {\n\n await this.assertObjectsExist();\n\n const meterStates = await this.getMeterStates();\n\n const calculator = new Calculator(this.config);\n\n const meterInfos = calculator.calculateMeterInfos(meterStates);\n\n this.writeMeterInfos(meterInfos);\n\n this.end();\n }\n\n private writeMeterInfos(meterInfos: MeterInfoCollection): void {\n for (const meterName in meterInfos) {\n const meterInfo = meterInfos[meterName];\n\n this.writeState(`meters.${meterName}.balance`, Round.costs(meterInfo.balance));\n this.writeState(`meters.${meterName}.consumptionAverage`, Round.consumption(meterInfo.consumptionAverage));\n this.writeState(`meters.${meterName}.consumptionPredictedTotal`, Round.consumption(meterInfo.consumptionPredictedTotal));\n this.writeState(`meters.${meterName}.consumptionTotal`, Round.consumption(meterInfo.consumptionTotal));\n this.writeState(`meters.${meterName}.costs`, Round.costs(meterInfo.costs));\n this.writeState(`meters.${meterName}.paid`, Round.costs(meterInfo.paid));\n this.writeState(`meters.${meterName}.recommendedPayment`, Round.costs(meterInfo.recommendedPayment));\n }\n }\n\n\n private writeState(id: string, value: any): void {\n const promise = this.setStateAsync(id, {val: value, ack: false});\n this.pendingPromises.push(promise);\n }\n\n private getNumericStateValue(state: null|undefined|ioBroker.State, onErrorMessage: string): number {\n const stateValue = state?.val;\n if (typeof stateValue === 'number') {\n return stateValue;\n }\n throw new Error(onErrorMessage);\n }\n\n private async getMeterStates(): Promise<MeterState[]> {\n\n const meterStates = [];\n\n for (const meter of this.config.meters) {\n meterStates.push(await this.getMeterState(meter));\n }\n\n return meterStates;\n }\n\n private async getMeterState(meter: MeterDefinition): Promise<MeterState> {\n\n const meterName = meter.alias;\n const currentValueState = await this.getForeignStateAsync(meter.objectId);\n const currentValue = this.getNumericStateValue(\n currentValueState,\n `Could not read meter \"${meterName}\" with id: ${meter.objectId}`\n ) || 0;\n\n const startValueState = await this.getStateAsync(`configuration.${meterName}.startValue`);\n let startValueDateTime: Date|null = null;\n if (!startValueState) {\n await this.setStateAsync(`configuration.${meterName}.startValue`, {val: currentValue, ack: true});\n startValueDateTime = new Date(Round.precise(currentValueState?.ts || Date.now(), -3));\n await this.setStateAsync(`configuration.${meterName}.readingDateTime`, {val: startValueDateTime.toISOString(), ack: true});\n }\n const startValue = this.getNumericStateValue(\n startValueState || await this.getStateAsync(`configuration.${meterName}.startValue`),\n `Could not read start value for meter \"${meterName}\".`\n );\n if (!startValueDateTime) {\n const startValueDateTimeValue = (await this.getStateAsync(`configuration.${meterName}.readingDateTime`))?.val;\n if (typeof startValueDateTimeValue === 'string') {\n try {\n startValueDateTime = new Date(Date.parse(startValueDateTimeValue));\n } catch (e) {}\n }\n }\n\n return {\n meter,\n currentValue,\n startValue,\n startValueDateTime,\n consumption: currentValue - startValue,\n };\n }\n\n private assertObjectsExist(): Promise<any> {\n const promises = [];\n\n for (const meter of this.config.meters) {\n promises.push(...this.assertMeterObjectsExist(meter.alias));\n }\n promises.push(...this.assertMeterObjectsExist(this.config.summaryName, false));\n\n return Promise.allSettled(promises);\n }\n\n private assertMeterObjectsExist(meterName: string, hasStartValue = true): ioBroker.SetObjectPromise[] {\n const promises = [];\n\n promises.push(this.setObjectNotExistsAsync(`configuration.${meterName}`, {\n type: 'device',\n common: {\n name: `configuration.${meterName}`,\n icon: `/icons/${hasStartValue ? 'device' : 'summary'}-icon.svg`,\n },\n native: {},\n }));\n\n if (hasStartValue) {\n promises.push(this.setObjectNotExistsAsync(`configuration.${meterName}.startValue`, {\n type: 'state',\n common: {\n name: 'Start value',\n type: 'number',\n role: 'state',\n read: true,\n write: true,\n unit: this.config.meterUnit,\n },\n native: {\n },\n }));\n promises.push(this.setObjectNotExistsAsync(`configuration.${meterName}.readingDateTime`, {\n type: 'state',\n common: {\n name: 'Timestamp of reading start value',\n desc: 'ONLY INFORMATION: Does not affect any calculation yet.',\n type: 'string',\n role: 'state',\n read: true,\n write: true,\n },\n native: {},\n }));\n }\n promises.push(this.setObjectNotExistsAsync(`meters.${meterName}.consumptionAverage`, {\n type: 'state',\n common: {\n name: 'Average consumption in period',\n type: 'number',\n role: 'state',\n read: true,\n write: false,\n unit: this.config.meterUnit,\n },\n native: {},\n }));\n promises.push(this.setObjectNotExistsAsync(`meters.${meterName}.consumptionTotal`, {\n type: 'state',\n common: {\n name: 'Total consumption in period',\n type: 'number',\n role: 'state',\n read: true,\n write: false,\n unit: this.config.meterUnit,\n },\n native: {},\n }));\n promises.push(this.setObjectNotExistsAsync(`meters.${meterName}.consumptionPredictedTotal`, {\n type: 'state',\n common: {\n name: 'Total predicted consumption in period',\n type: 'number',\n role: 'state',\n read: true,\n write: false,\n unit: this.config.meterUnit,\n },\n native: {},\n }));\n promises.push(this.setObjectNotExistsAsync(`meters.${meterName}.costs`, {\n type: 'state',\n common: {\n name: 'Total costs',\n type: 'number',\n role: 'state',\n read: true,\n write: false,\n unit: this.config.paymentUnit,\n },\n native: {},\n }));\n promises.push(this.setObjectNotExistsAsync(`meters.${meterName}.paid`, {\n type: 'state',\n common: {\n name: 'Total paid value',\n type: 'number',\n role: 'state',\n read: true,\n write: false,\n unit: this.config.paymentUnit,\n },\n native: {},\n }));\n promises.push(this.setObjectNotExistsAsync(`meters.${meterName}.balance`, {\n type: 'state',\n common: {\n name: 'Current balance',\n type: 'number',\n role: 'state',\n read: true,\n write: false,\n unit: this.config.paymentUnit,\n },\n native: {},\n }));\n promises.push(this.setObjectNotExistsAsync(`meters.${meterName}.recommendedPayment`, {\n type: 'state',\n common: {\n name: 'Recommended payment per payment interval',\n type: 'number',\n role: 'state',\n read: true,\n write: false,\n unit: this.config.paymentUnit,\n },\n native: {},\n }));\n\n return promises;\n }\n\n end(): void {\n if (this.unloaded) return;\n Promise.allSettled(this.pendingPromises).finally(() => {\n if (this.stop) {\n this.stop();\n }\n });\n }\n\n /**\n * Is called when adapter shuts down - callback has to be called under any circumstances!\n */\n private onUnload(callback: () => void): void {\n this.unloaded = true;\n try {\n // Here you must clear all timeouts or intervals that may still be active\n callback();\n } catch (e) {\n callback();\n }\n }\n\n}\n\nif (require.main !== module) {\n // Export the constructor in compact mode\n module.exports = (options: Partial<utils.AdapterOptions> | undefined) => new MeterStatistics(options);\n} else {\n // otherwise start the instance directly\n (() => new MeterStatistics())();\n}\n"],
|
|
5
|
-
"mappings": "
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;AAMA,YAAuB;AAEvB,wBAAuB;AACvB,mBAAkB;AAKlB,MAAM,wBAAwB,MAAM,QAAQ;AAAA,EAEhC,WAAW;AAAA,EAEX,kBAAuC,CAAC;AAAA,EAEzC,YAAY,UAAyC,CAAC,GAAG;AAC5D,UAAM;AAAA,MACF,GAAG;AAAA,MACH,MAAM;AAAA,IACV,CAAC;AACD,SAAK,GAAG,SAAS,KAAK,QAAQ,KAAK,IAAI,CAAC;AACxC,SAAK,GAAG,UAAU,KAAK,SAAS,KAAK,IAAI,CAAC;AAAA,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SAAS,YAAY;AAAA,MACtE,MAAM;AAAA,MACN,QAAQ;AAAA,QACJ,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN,OAAO;AAAA,QACP,MAAM,KAAK,OAAO;AAAA,MACtB;AAAA,MACA,QAAQ,CAAC;AAAA,IACb,CAAC,CAAC;AACF,aAAS,KAAK,KAAK,wBAAwB,UAAU,SAAS,uBAAuB;AAAA,MACjF,MAAM;AAAA,MACN,QAAQ;AAAA,QACJ,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN,MAAM;AAAA,QACN,OAAO;AAAA,QACP,MAAM,KAAK,OAAO;AAAA,MACtB;AAAA,MACA,QAAQ,CAAC;AAAA,IACb,CAAC,CAAC;AAEF,WAAO;AAAA,EACX;AAAA,EAEA,MAAY;AACR,QAAI,KAAK,SAAU;AACnB,YAAQ,WAAW,KAAK,eAAe,EAAE,QAAQ,MAAM;AACnD,UAAI,KAAK,MAAM;AACX,aAAK,KAAK;AAAA,MACd;AAAA,IACJ,CAAC;AAAA,EACL;AAAA;AAAA;AAAA;AAAA,EAKQ,SAAS,UAA4B;AACzC,SAAK,WAAW;AAChB,QAAI;AAEA,eAAS;AAAA,IACb,SAAS,GAAG;AACR,eAAS;AAAA,IACb;AAAA,EACJ;AAEJ;AAEA,IAAI,QAAQ,SAAS,QAAQ;AAEzB,SAAO,UAAU,CAAC,YAAuD,IAAI,gBAAgB,OAAO;AACxG,OAAO;AAEH,GAAC,MAAM,IAAI,gBAAgB,GAAG;AAClC;",
|
|
6
6
|
"names": ["Calculator", "Round"]
|
|
7
7
|
}
|
package/build/period.js
CHANGED
|
@@ -22,13 +22,17 @@ __export(period_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(period_exports);
|
|
24
24
|
class Period {
|
|
25
|
+
static now;
|
|
26
|
+
perDayFactor;
|
|
27
|
+
extrapolatePerPeriodFactor;
|
|
28
|
+
elapsedInPeriodFactor;
|
|
25
29
|
constructor(startOfPeriod = null) {
|
|
26
30
|
const now = this.now;
|
|
27
31
|
const periodStartDateTime = startOfPeriod || new Date(now.getFullYear(), 0, 0);
|
|
28
32
|
const periodEndDateTime = this.incrementDatetimeByOneYear(periodStartDateTime);
|
|
29
33
|
const periodStartTimestamp = periodStartDateTime.valueOf();
|
|
30
34
|
const periodEndTimestamp = periodEndDateTime.valueOf();
|
|
31
|
-
const unitsPerDay = new Date("1900-01-02T00:00:00").valueOf() - new Date("1900-01-01T00:00:00").valueOf();
|
|
35
|
+
const unitsPerDay = (/* @__PURE__ */ new Date("1900-01-02T00:00:00")).valueOf() - (/* @__PURE__ */ new Date("1900-01-01T00:00:00")).valueOf();
|
|
32
36
|
const unitsInPeriod = periodEndTimestamp - periodStartTimestamp;
|
|
33
37
|
const elapsedUnitsInPeriod = now.valueOf() - periodStartTimestamp;
|
|
34
38
|
this.perDayFactor = 1 / elapsedUnitsInPeriod * unitsPerDay;
|
|
@@ -37,7 +41,7 @@ class Period {
|
|
|
37
41
|
}
|
|
38
42
|
get now() {
|
|
39
43
|
if (!Period.now) {
|
|
40
|
-
Period.now = new Date();
|
|
44
|
+
Period.now = /* @__PURE__ */ new Date();
|
|
41
45
|
}
|
|
42
46
|
return Period.now;
|
|
43
47
|
}
|
|
@@ -56,6 +60,4 @@ class Period {
|
|
|
56
60
|
return totalAmountInYear * this.elapsedInPeriodFactor;
|
|
57
61
|
}
|
|
58
62
|
}
|
|
59
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
-
0 && (module.exports = {});
|
|
61
63
|
//# sourceMappingURL=period.js.map
|
package/build/period.js.map
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/period.ts"],
|
|
4
4
|
"sourcesContent": ["export default class Period {\n\n private static now: null|Date;\n private readonly perDayFactor: number;\n private readonly extrapolatePerPeriodFactor: number;\n private readonly elapsedInPeriodFactor: number;\n\n constructor(startOfPeriod: Date|null = null) {\n const now = this.now;\n\n const periodStartDateTime = startOfPeriod || new Date(now.getFullYear(), 0, 0);\n const periodEndDateTime = this.incrementDatetimeByOneYear(periodStartDateTime);\n\n const periodStartTimestamp = periodStartDateTime.valueOf();\n const periodEndTimestamp = periodEndDateTime.valueOf();\n\n const unitsPerDay = (new Date('1900-01-02T00:00:00')).valueOf() - (new Date('1900-01-01T00:00:00')).valueOf();\n const unitsInPeriod = periodEndTimestamp - periodStartTimestamp;\n const elapsedUnitsInPeriod = now.valueOf() - periodStartTimestamp;\n\n this.perDayFactor = 1 / elapsedUnitsInPeriod * unitsPerDay;\n this.extrapolatePerPeriodFactor = 1 / elapsedUnitsInPeriod * unitsInPeriod;\n this.elapsedInPeriodFactor = 1 / unitsInPeriod * elapsedUnitsInPeriod;\n }\n\n private get now(): Date {\n if (!Period.now) {\n Period.now = new Date();\n }\n return Period.now;\n }\n\n private incrementDatetimeByOneYear(date: Date): Date {\n const newDate = new Date(date);\n newDate.setFullYear(date.getFullYear() + 1);\n return newDate;\n }\n\n public calculateValuePerDay(amountInPeriod: number): number {\n return amountInPeriod * this.perDayFactor;\n }\n\n public calculateExtrapolateValueForPeriod(amountInPeriod: number): number {\n return amountInPeriod * this.extrapolatePerPeriodFactor;\n }\n\n public calculateElapsedAmountInPeriod(totalAmountInYear: number): number {\n return totalAmountInYear * this.elapsedInPeriodFactor;\n }\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAO,OAAqB;AAAA,
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAO,OAAqB;AAAA,EAExB,OAAe;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EAEjB,YAAY,gBAA2B,MAAM;AACzC,UAAM,MAAM,KAAK;AAEjB,UAAM,sBAAsB,iBAAiB,IAAI,KAAK,IAAI,YAAY,GAAG,GAAG,CAAC;AAC7E,UAAM,oBAAoB,KAAK,2BAA2B,mBAAmB;AAE7E,UAAM,uBAAuB,oBAAoB,QAAQ;AACzD,UAAM,qBAAqB,kBAAkB,QAAQ;AAErD,UAAM,eAAe,oBAAI,KAAK,qBAAqB,GAAG,QAAQ,KAAK,oBAAI,KAAK,qBAAqB,GAAG,QAAQ;AAC5G,UAAM,gBAAgB,qBAAqB;AAC3C,UAAM,uBAAuB,IAAI,QAAQ,IAAI;AAE7C,SAAK,eAAe,IAAI,uBAAuB;AAC/C,SAAK,6BAA6B,IAAI,uBAAuB;AAC7D,SAAK,wBAAwB,IAAI,gBAAgB;AAAA,EACrD;AAAA,EAEA,IAAY,MAAY;AACpB,QAAI,CAAC,OAAO,KAAK;AACb,aAAO,MAAM,oBAAI,KAAK;AAAA,IAC1B;AACA,WAAO,OAAO;AAAA,EAClB;AAAA,EAEQ,2BAA2B,MAAkB;AACjD,UAAM,UAAU,IAAI,KAAK,IAAI;AAC7B,YAAQ,YAAY,KAAK,YAAY,IAAI,CAAC;AAC1C,WAAO;AAAA,EACX;AAAA,EAEO,qBAAqB,gBAAgC;AACxD,WAAO,iBAAiB,KAAK;AAAA,EACjC;AAAA,EAEO,mCAAmC,gBAAgC;AACtE,WAAO,iBAAiB,KAAK;AAAA,EACjC;AAAA,EAEO,+BAA+B,mBAAmC;AACrE,WAAO,oBAAoB,KAAK;AAAA,EACpC;AACJ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/round.js
CHANGED
package/io-package.json
CHANGED
|
@@ -1,8 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "meter-statistics",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.2.0",
|
|
5
5
|
"news": {
|
|
6
|
+
"0.2.0": {
|
|
7
|
+
"en": "[TASK] Harmonize project structure, tooling and tests\n[TASK] Require @iobroker/adapter-core ^2.6.8 (previously merged on GitHub by Dependabot)\n[TASK] Require js-controller >= 6.0.11 and admin >= 7.6.20\n[TASK] Test on Node.js 22.x, 24.x and 26.x, publish to npm via trusted publishing and update the Dependabot configuration",
|
|
8
|
+
"de": "[TASK] Projektstruktur, Tools und Tests harmonisieren\n[TASK] Require @iobroker /adapter-core ^2.6.8 (zuvor von Dependabot auf GitHub vereint)\n[TASK] JS-Controller >= 6.0.11 und Admin >= 7.6.20\n[TASK] Testen Sie auf Node.js 22.x, 24.x und 26.x, veröffentlichen Sie auf NPM und aktualisieren Sie Dependabot",
|
|
9
|
+
"ru": "[TASK] Согласование структуры проекта, инструментов и тестов\n[TASK] Требуется @iobroker /adapter-core ^2.6.8 (ранее Dependabot объединил его в GitHub)\n[TASK] Требуется js-контроллер >= 6.0.11 и администратор >= 7.6.20\n[TASK] Протестируйте Node.js 22.x, 24.x и 26.x, опубликуйте в npm с помощью доверенной публикации и обновите конфигурацию Dependabot",
|
|
10
|
+
"pt": "[TASK] Harmonize projetos, ferramentas e testes\n[TASK] Exigir @iobroker /adapter-core ^2.6.8 (antes mesclado no GitHub por Dependabot)\n[TASK] Exigir js-controller >= 6.0.11 e admin >= 7.6.20\n[TASK] Teste no Node.js 22.x, 24.x e 26.x, publique no npm via Trusted Publishing e atualize o Dependabot",
|
|
11
|
+
"nl": "[TASK] De projectstructuur, tools en tests harmoniseren\n[TASK] @iobroker /adapter-core ^2.6.8 vereist (eerder samengevoegd op GitHub door Dependabot)\n[TASK] Vereist een js-controller >= 6.0.11 en admin >= 7.6.20\n[TASK] Test op Node.js 22.x, 24.x en 26.x, publiceer naar npm via Trusted Publishing en werk de Dependabot-configuratie bij",
|
|
12
|
+
"fr": "[TASK] Harmoniser le projet, l'outillage et les tests\n[TASK] Exige @iobroker /adapter-core ^2.6.8 (déjà fusionné sur GitHub par Dependabot)\n[TASK] Exige js-Controller version 6.0.11 et admin version 7.6.20\n[TASK] Testez Node.js 22.x, 24.x et 26.x, publiez sur npm via Trusted Publishing et mettez à jour la configuration Dependabot",
|
|
13
|
+
"it": "[TASK] Armonizzare struttura, strumenti e test\n[TASK] Richiede @iobroker /adapter-core ^2.6.8 (già unito su GitHub da Dependabot)\n[TASK] Richiede js-controller >= 6.0.11 e admin >= 7.6.20\n[TASK] Test su Node.js 22.x, 24.x e 26.x, pubblica su npm tramite Trusted Publishing e aggiorna la configurazione Dependabot",
|
|
14
|
+
"es": "[TASK] Armonizar la estructura, herramientas y pruebas del proyecto\n[TASK] Requiere @iobroker /adapter-core ^2.6.8 (Dependabot lo fusionó anteriormente en GitHub)\n[TASK] Necesita js-controller >= 6.0.11 y admin >= 7.6.20\n[TASK] Probar en Node.js 22.x, 24.x y 26.x, publicar en npm mediante Trusted Publishing y actualizar la configuración del Dependabot",
|
|
15
|
+
"pl": "[TASK] Zharmonizuj strukturę projektu, oprzyrządowanie i testy\n[TASK] Wymagaj @iobroker /adapter-core ^2.6.8 (wcześniej scalony na GitHub przez Dependabot)\n[TASK] Wymagaj js-controller >= 6.0.11 i admin >= 7.6.20\n[TASK] Przetestuj na Node.js 22.x, 24.x i 26.x, opublikuj do npm poprzez zaufane publikowanie i zaktualizuj konfigurację Dependabot",
|
|
16
|
+
"uk": "[TASK] Гармонізувати структуру проекту, інструменти та тести\n[TASK] Вимагається @iobroker /адаптер-ядро ^ 2.6.8 (раніше об'єднано на GitHub Dependabot)\n[TASK] Потрібен js-контролер >= 6.0.11 і адміністратор> = 7.6.20\n[TASK] Тест на Node.js 22.x, 24.x та 26.x, публікуйте в npm через довірену публікацію та оновіть конфігурацію Dependabot",
|
|
17
|
+
"zh-cn": "[TASK] 协调项目结构、工具和测试\n[TASK] 需要 @iobroker /adapter-core ^2.6.8(之前由 Dependabot 在 GitHub 上合并)\n[TASK] 需要 js-controller >= 6.0.11 和管理员 >= 7.6.20\n[TASK] 在 Node.js 22.x、24.x 和 26.x 上测试,通过可信发布到 npm 并更新 Dependabot 配置"
|
|
18
|
+
},
|
|
6
19
|
"0.1.1": {
|
|
7
20
|
"en": "[FEATURE] Add device icons",
|
|
8
21
|
"de": "(STÖHNT) Gerätesymbole hinzufügen",
|
|
@@ -117,7 +130,10 @@
|
|
|
117
130
|
"statistics",
|
|
118
131
|
"calculate"
|
|
119
132
|
],
|
|
120
|
-
"
|
|
133
|
+
"licenseInformation": {
|
|
134
|
+
"type": "free",
|
|
135
|
+
"license": "GPL-3.0-or-later"
|
|
136
|
+
},
|
|
121
137
|
"platform": "Javascript/Node.js",
|
|
122
138
|
"main": "build/main.js",
|
|
123
139
|
"icon": "meter-statistics.png",
|
|
@@ -136,14 +152,15 @@
|
|
|
136
152
|
},
|
|
137
153
|
"dependencies": [
|
|
138
154
|
{
|
|
139
|
-
"js-controller": ">=
|
|
155
|
+
"js-controller": ">=6.0.11"
|
|
140
156
|
}
|
|
141
157
|
],
|
|
142
158
|
"globalDependencies": [
|
|
143
159
|
{
|
|
144
|
-
"admin": ">=
|
|
160
|
+
"admin": ">=7.6.20"
|
|
145
161
|
}
|
|
146
|
-
]
|
|
162
|
+
],
|
|
163
|
+
"tier": 3
|
|
147
164
|
},
|
|
148
165
|
"native": {
|
|
149
166
|
"meterUnit": "kWh",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.meter-statistics",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Calculate statistics from any smart meter",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "jb-io",
|
|
@@ -19,38 +19,39 @@
|
|
|
19
19
|
"url": "git@github.com:jb-io/ioBroker.meter-statistics.git"
|
|
20
20
|
},
|
|
21
21
|
"engines": {
|
|
22
|
-
"node": ">=
|
|
22
|
+
"node": ">= 22"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@iobroker/adapter-core": "^2.6.
|
|
25
|
+
"@iobroker/adapter-core": "^2.6.8"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@alcalzone/release-script": "^
|
|
29
|
-
"@alcalzone/release-script-plugin-iobroker": "^
|
|
30
|
-
"@alcalzone/release-script-plugin-license": "^
|
|
31
|
-
"@
|
|
32
|
-
"@iobroker/
|
|
33
|
-
"@
|
|
34
|
-
"@
|
|
35
|
-
"@
|
|
36
|
-
"@types/
|
|
37
|
-
"@types/
|
|
38
|
-
"@types/
|
|
39
|
-
"@types/
|
|
40
|
-
"@types/
|
|
41
|
-
"@
|
|
42
|
-
"@
|
|
43
|
-
"chai": "^4.
|
|
44
|
-
"chai-as-promised": "^7.1.
|
|
45
|
-
"eslint": "^
|
|
46
|
-
"mocha": "^
|
|
28
|
+
"@alcalzone/release-script": "^5.2.1",
|
|
29
|
+
"@alcalzone/release-script-plugin-iobroker": "^5.2.0",
|
|
30
|
+
"@alcalzone/release-script-plugin-license": "^5.2.2",
|
|
31
|
+
"@alcalzone/release-script-plugin-manual-review": "^5.2.0",
|
|
32
|
+
"@iobroker/adapter-dev": "^1.5.0",
|
|
33
|
+
"@iobroker/eslint-config": "^2.3.4",
|
|
34
|
+
"@iobroker/testing": "^5.3.0",
|
|
35
|
+
"@tsconfig/node22": "^22.0.7",
|
|
36
|
+
"@types/chai": "^4.3.16",
|
|
37
|
+
"@types/chai-as-promised": "^7.1.8",
|
|
38
|
+
"@types/mocha": "^10.0.10",
|
|
39
|
+
"@types/node": "^22.20.7",
|
|
40
|
+
"@types/proxyquire": "^1.3.31",
|
|
41
|
+
"@types/sinon": "^22.0.0",
|
|
42
|
+
"@types/sinon-chai": "^3.2.12",
|
|
43
|
+
"chai": "^4.4.1",
|
|
44
|
+
"chai-as-promised": "^7.1.2",
|
|
45
|
+
"eslint": "^9.39.5",
|
|
46
|
+
"mocha": "^11.8.0",
|
|
47
|
+
"prettier": "^3.9.6",
|
|
47
48
|
"proxyquire": "^2.1.3",
|
|
48
|
-
"rimraf": "^
|
|
49
|
-
"sinon": "^
|
|
49
|
+
"rimraf": "^6.1.3",
|
|
50
|
+
"sinon": "^22.1.0",
|
|
50
51
|
"sinon-chai": "^3.7.0",
|
|
51
52
|
"source-map-support": "^0.5.21",
|
|
52
|
-
"ts-node": "^10.9.
|
|
53
|
-
"typescript": "~
|
|
53
|
+
"ts-node": "^10.9.2",
|
|
54
|
+
"typescript": "~5.9.3"
|
|
54
55
|
},
|
|
55
56
|
"main": "build/main.js",
|
|
56
57
|
"files": [
|
|
@@ -68,12 +69,14 @@
|
|
|
68
69
|
"prebuild:ts": "rimraf build",
|
|
69
70
|
"build:ts": "build-adapter ts",
|
|
70
71
|
"watch:ts": "build-adapter ts --watch",
|
|
71
|
-
"test:ts": "mocha --config test/mocharc.custom.json
|
|
72
|
+
"test:ts": "mocha --config test/mocharc.custom.json",
|
|
72
73
|
"test:package": "mocha test/package --exit",
|
|
73
|
-
"test:integration": "mocha test/integration --exit",
|
|
74
|
+
"test:integration": "mocha test/integration.js --exit",
|
|
74
75
|
"test": "npm run test:ts && npm run test:package",
|
|
75
76
|
"check": "tsc --noEmit",
|
|
76
|
-
"lint": "eslint
|
|
77
|
+
"lint": "eslint .",
|
|
78
|
+
"lint:fix": "eslint . --fix",
|
|
79
|
+
"format": "prettier --write .",
|
|
77
80
|
"translate": "translate-adapter",
|
|
78
81
|
"release": "release-script"
|
|
79
82
|
},
|