iobroker.meter-statistics 0.0.4 → 0.1.1
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 +13 -0
- package/admin/icons/device-icon.svg +19 -0
- package/admin/icons/summary-icon.svg +19 -0
- package/admin/jsonConfig.json +69 -30
- package/admin/meter-statistics.png +0 -0
- package/admin/meter-statistics.svg +10 -10
- package/build/calculator.js +93 -0
- package/build/calculator.js.map +7 -0
- package/build/lib/typedef.js.map +1 -1
- package/build/main.js +95 -147
- package/build/main.js.map +3 -3
- package/build/period.js +61 -0
- package/build/period.js.map +7 -0
- package/build/round.js +42 -0
- package/build/round.js.map +7 -0
- package/io-package.json +28 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -103,11 +103,24 @@ The ioBroker.admin interface will then be available at http://localhost:8081/
|
|
|
103
103
|
|
|
104
104
|
Please refer to the [`dev-server` documentation](https://github.com/ioBroker/dev-server#command-line) for more details.
|
|
105
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
|
|
111
|
+
|
|
106
112
|
## Changelog
|
|
107
113
|
<!--
|
|
108
114
|
Placeholder for the next version (at the beginning of the line):
|
|
109
115
|
### **WORK IN PROGRESS**
|
|
110
116
|
-->
|
|
117
|
+
### 0.1.1 (2023-03-29)
|
|
118
|
+
* [FEATURE] Add device icons
|
|
119
|
+
|
|
120
|
+
### 0.1.0 (2023-03-18)
|
|
121
|
+
* [TASK] Code refactoring
|
|
122
|
+
* [TASK] Add test cases
|
|
123
|
+
|
|
111
124
|
### 0.0.4 (2023-03-05)
|
|
112
125
|
* [BUGFIX] Fix calculation of predicted total
|
|
113
126
|
* [TASK] Update project
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg width="400" height="400" version="1.1" viewBox="0 0 105.83 105.83" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<defs>
|
|
4
|
+
<marker id="a" overflow="visible" orient="auto">
|
|
5
|
+
<path transform="matrix(-.4 0 0 -.4 -4 0)" d="m0 0 5-5-17.5 5 17.5 5z" fill="context-stroke" fill-rule="evenodd" stroke="context-stroke" stroke-width="1pt"/>
|
|
6
|
+
</marker>
|
|
7
|
+
</defs>
|
|
8
|
+
<path x="13.761666" y="0.53250003" width="78.309998" height="104.76833" d="m16.408 0.5325h73.018a2.6458 2.6458 45 0 1 2.6458 2.6458v99.477a2.6458 2.6458 135 0 1-2.6458 2.6458h-73.018a2.6458 2.6458 45 0 1-2.6458-2.6458v-99.477a2.6458 2.6458 135 0 1 2.6458-2.6458z" fill="#ececec" stroke="#b1b1b1" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.065"/>
|
|
9
|
+
<path x="24.344997" y="12.382141" width="57.143333" height="30.68499" d="m26.991 12.382h51.852a2.6458 2.6458 45 0 1 2.6458 2.6458v25.393a2.6458 2.6458 135 0 1-2.6458 2.6458h-51.852a2.6458 2.6458 45 0 1-2.6458-2.6458v-25.393a2.6458 2.6458 135 0 1 2.6458-2.6458z" fill="#fff" stroke="#b1b1b1" stroke-linejoin="round" stroke-width="1.065"/>
|
|
10
|
+
<text transform="scale(.78891 1.2676)" x="34.916286" y="29.418192" fill="#000000" font-family="sans-serif" font-size="20.281px" letter-spacing="0px" stroke-width=".36216" word-spacing="0px" style="line-height:1.25" xml:space="preserve"><tspan x="34.916286" y="29.418192" font-family="Ani" font-size="20.281px" stroke-width=".36216">0000.0</tspan></text>
|
|
11
|
+
<g transform="translate(12.75)">
|
|
12
|
+
<text transform="scale(.98752 1.0126)" x="63.427376" y="90.78965" fill="#b1b1b1" font-family="sans-serif" font-size="14.551px" letter-spacing="0px" stroke-width=".2021" word-spacing="0px" style="line-height:1.25" xml:space="preserve"><tspan x="63.427376" y="90.78965" fill="#b1b1b1" font-family="FreeSans" font-size="14.551px" stroke-width=".2021">∑</tspan></text>
|
|
13
|
+
<text x="8.8679714" y="67.230087" fill="#b1b1b1" font-family="sans-serif" font-size="19.05px" letter-spacing="0px" stroke-width=".26458" word-spacing="0px" style="line-height:1.25" xml:space="preserve"><tspan x="8.8679714" y="67.230087" fill="#b1b1b1" font-family="FreeSans" font-size="19.05px" stroke-width=".26458">€</tspan></text>
|
|
14
|
+
<g transform="matrix(1.481 0 0 1.8284 -58.042 -106.23)" fill="none" stroke="#b1b1b1" stroke-linejoin="round" stroke-width=".97896">
|
|
15
|
+
<path d="m44.823 87.274c-8e-4 7.6096-0.0016 15.219-0.0024 22.828 14.49 1e-3 28.98 3e-3 43.47 4e-3"/>
|
|
16
|
+
<path d="m44.826 110.1c1.6195-2.6756 5.8661-9.6918 7.357-10.078 1.4909-0.38619 5.0588 4.6054 6.6312 3.8243s6.2522-9.8695 8.0363-10.492c1.784-0.62294 6.4571 5.1992 8.6176 4.9959 2.1605-0.20323 8.8205-7.0914 11.36-9.7182" marker-end="url(#a)"/>
|
|
17
|
+
</g>
|
|
18
|
+
</g>
|
|
19
|
+
</svg>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<svg width="400" height="400" version="1.1" viewBox="0 0 105.83 105.83" xmlns="http://www.w3.org/2000/svg">
|
|
3
|
+
<defs>
|
|
4
|
+
<marker id="a" overflow="visible" orient="auto">
|
|
5
|
+
<path transform="matrix(-.4 0 0 -.4 -4 0)" d="m0 0 5-5-17.5 5 17.5 5z" fill="context-stroke" fill-rule="evenodd" stroke="context-stroke" stroke-width="1pt"/>
|
|
6
|
+
</marker>
|
|
7
|
+
</defs>
|
|
8
|
+
<path x="13.761666" y="0.53250003" width="78.309998" height="104.76833" d="m16.408 0.5325h73.018a2.6458 2.6458 45 0 1 2.6458 2.6458v99.477a2.6458 2.6458 135 0 1-2.6458 2.6458h-73.018a2.6458 2.6458 45 0 1-2.6458-2.6458v-99.477a2.6458 2.6458 135 0 1 2.6458-2.6458z" fill="#ececec" stroke="#b1b1b1" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.065"/>
|
|
9
|
+
<path x="24.344997" y="12.382141" width="57.143333" height="30.68499" d="m26.991 12.382h51.852a2.6458 2.6458 45 0 1 2.6458 2.6458v25.393a2.6458 2.6458 135 0 1-2.6458 2.6458h-51.852a2.6458 2.6458 45 0 1-2.6458-2.6458v-25.393a2.6458 2.6458 135 0 1 2.6458-2.6458z" fill="#fff" stroke="#b1b1b1" stroke-linejoin="round" stroke-width="1.065"/>
|
|
10
|
+
<text transform="scale(.78891 1.2676)" x="34.916286" y="29.418192" fill="#000000" font-family="sans-serif" font-size="20.281px" letter-spacing="0px" stroke-width=".36216" word-spacing="0px" style="line-height:1.25" xml:space="preserve"><tspan x="34.916286" y="29.418192" font-family="Ani" font-size="20.281px" stroke-width=".36216">0000.0</tspan></text>
|
|
11
|
+
<g transform="translate(12.75)">
|
|
12
|
+
<text transform="scale(.98752 1.0126)" x="63.427376" y="90.78965" fill="#b1b1b1" font-family="sans-serif" font-size="14.551px" letter-spacing="0px" stroke-width=".2021" word-spacing="0px" style="line-height:1.25" xml:space="preserve"><tspan x="63.427376" y="90.78965" fill="#b1b1b1" font-family="FreeSans" font-size="14.551px" stroke-width=".2021">∑</tspan></text>
|
|
13
|
+
<text x="8.8679714" y="67.230087" fill="#b1b1b1" font-family="sans-serif" font-size="19.05px" letter-spacing="0px" stroke-width=".26458" word-spacing="0px" style="line-height:1.25" xml:space="preserve"><tspan x="8.8679714" y="67.230087" fill="#b1b1b1" font-family="FreeSans" font-size="19.05px" stroke-width=".26458">€</tspan></text>
|
|
14
|
+
<g transform="matrix(1.481 0 0 1.8284 -58.042 -106.23)" fill="none" stroke="#b1b1b1" stroke-linejoin="round" stroke-width=".97896">
|
|
15
|
+
<path d="m44.823 87.274c-8e-4 7.6096-0.0016 15.219-0.0024 22.828 14.49 1e-3 28.98 3e-3 43.47 4e-3"/>
|
|
16
|
+
<path d="m44.826 110.1c1.6195-2.6756 5.8661-9.6918 7.357-10.078 1.4909-0.38619 5.0588 4.6054 6.6312 3.8243s6.2522-9.8695 8.0363-10.492c1.784-0.62294 6.4571 5.1992 8.6176 4.9959 2.1605-0.20323 8.8205-7.0914 11.36-9.7182" marker-end="url(#a)"/>
|
|
17
|
+
</g>
|
|
18
|
+
</g>
|
|
19
|
+
</svg>
|
package/admin/jsonConfig.json
CHANGED
|
@@ -9,14 +9,24 @@
|
|
|
9
9
|
},
|
|
10
10
|
"units": {
|
|
11
11
|
"type": "panel",
|
|
12
|
+
"xs": 12,
|
|
12
13
|
"label": "units",
|
|
13
14
|
"items": {
|
|
14
15
|
"meterUnit": {
|
|
15
16
|
"type": "text",
|
|
16
|
-
"
|
|
17
|
+
"xs": 12,
|
|
18
|
+
"sm": 6,
|
|
19
|
+
"md": 4,
|
|
20
|
+
"lg": 3,
|
|
21
|
+
"label": "Unit of meter value",
|
|
22
|
+
"newLine": true
|
|
17
23
|
},
|
|
18
24
|
"paymentUnit": {
|
|
19
25
|
"type": "text",
|
|
26
|
+
"xs": 12,
|
|
27
|
+
"sm": 6,
|
|
28
|
+
"md": 4,
|
|
29
|
+
"lg": 3,
|
|
20
30
|
"label": "Unit of payment"
|
|
21
31
|
}
|
|
22
32
|
}
|
|
@@ -28,28 +38,43 @@
|
|
|
28
38
|
},
|
|
29
39
|
"payment": {
|
|
30
40
|
"type": "panel",
|
|
41
|
+
"xs": 12,
|
|
31
42
|
"label": "payment",
|
|
32
43
|
"items": {
|
|
33
44
|
"paymentValue": {
|
|
34
45
|
"type": "number",
|
|
46
|
+
"xs": 12,
|
|
47
|
+
"sm": 6,
|
|
48
|
+
"md": 4,
|
|
49
|
+
"lg": 3,
|
|
35
50
|
"label": "Payment value",
|
|
36
51
|
"newLine": true
|
|
37
52
|
},
|
|
38
53
|
"paymentCount": {
|
|
39
54
|
"type": "number",
|
|
55
|
+
"xs": 12,
|
|
56
|
+
"sm": 6,
|
|
57
|
+
"md": 4,
|
|
58
|
+
"lg": 3,
|
|
40
59
|
"label": "Payment count",
|
|
41
|
-
"min": 1
|
|
42
|
-
"newLine": true
|
|
60
|
+
"min": 1
|
|
43
61
|
},
|
|
44
62
|
"paymentBasePrice": {
|
|
45
63
|
"type": "number",
|
|
64
|
+
"xs": 12,
|
|
65
|
+
"sm": 6,
|
|
66
|
+
"md": 4,
|
|
67
|
+
"lg": 3,
|
|
46
68
|
"label": "Base price that is paid once",
|
|
47
69
|
"newLine": true
|
|
48
70
|
},
|
|
49
71
|
"paymentCorrectionOffset": {
|
|
50
72
|
"type": "number",
|
|
51
|
-
"
|
|
52
|
-
"
|
|
73
|
+
"xs": 12,
|
|
74
|
+
"sm": 6,
|
|
75
|
+
"md": 4,
|
|
76
|
+
"lg": 3,
|
|
77
|
+
"label": "Payment correction offset"
|
|
53
78
|
}
|
|
54
79
|
}
|
|
55
80
|
},
|
|
@@ -59,33 +84,47 @@
|
|
|
59
84
|
"size": 2
|
|
60
85
|
},
|
|
61
86
|
"meters": {
|
|
62
|
-
"type": "
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
|
|
72
|
-
{
|
|
73
|
-
"attr": "alias",
|
|
74
|
-
"width": "30%",
|
|
75
|
-
"title": "Meter alias",
|
|
76
|
-
"type": "text" ,
|
|
77
|
-
"validator": "!!data.alias",
|
|
78
|
-
"validatorNoSaveOnError": true
|
|
87
|
+
"type": "panel",
|
|
88
|
+
"xs": 12,
|
|
89
|
+
"label": "payment",
|
|
90
|
+
"items": {
|
|
91
|
+
"summaryName": {
|
|
92
|
+
"type": "text",
|
|
93
|
+
"xs": 12,
|
|
94
|
+
"sm": 6,
|
|
95
|
+
"label": "Name of summary node that contains sum of all meters",
|
|
96
|
+
"newLine": true
|
|
79
97
|
},
|
|
80
|
-
{
|
|
81
|
-
"
|
|
82
|
-
"
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
98
|
+
"meters": {
|
|
99
|
+
"type": "table",
|
|
100
|
+
"items": [
|
|
101
|
+
{
|
|
102
|
+
"attr": "objectId",
|
|
103
|
+
"width": "50%",
|
|
104
|
+
"title": "Object ID",
|
|
105
|
+
"type": "objectId",
|
|
106
|
+
"validator": "!!data.objectId",
|
|
107
|
+
"validatorNoSaveOnError": true
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"attr": "alias",
|
|
111
|
+
"width": "30%",
|
|
112
|
+
"title": "Meter alias",
|
|
113
|
+
"type": "text",
|
|
114
|
+
"validator": "!!data.alias",
|
|
115
|
+
"validatorNoSaveOnError": true
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"attr": "pricePerUnit",
|
|
119
|
+
"width": "20%",
|
|
120
|
+
"title": "Price per unit",
|
|
121
|
+
"type": "number",
|
|
122
|
+
"validator": "!!data.pricePerUnit",
|
|
123
|
+
"validatorNoSaveOnError": true
|
|
124
|
+
}
|
|
125
|
+
]
|
|
87
126
|
}
|
|
88
|
-
|
|
127
|
+
}
|
|
89
128
|
}
|
|
90
129
|
}
|
|
91
130
|
}
|
|
Binary file
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
2
|
<svg
|
|
3
|
-
width="
|
|
3
|
+
width="400"
|
|
4
4
|
height="400"
|
|
5
|
-
viewBox="0 0
|
|
5
|
+
viewBox="0 0 105.83333 105.83333"
|
|
6
6
|
version="1.1"
|
|
7
7
|
id="svg5"
|
|
8
8
|
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
inkscape:document-units="mm"
|
|
23
23
|
showgrid="false"
|
|
24
24
|
inkscape:zoom="1.1152113"
|
|
25
|
-
inkscape:cx="
|
|
25
|
+
inkscape:cx="43.041171"
|
|
26
26
|
inkscape:cy="171.71634"
|
|
27
27
|
inkscape:window-width="1862"
|
|
28
28
|
inkscape:window-height="1016"
|
|
@@ -156,36 +156,36 @@
|
|
|
156
156
|
id="rect31"
|
|
157
157
|
width="78.309998"
|
|
158
158
|
height="104.76833"
|
|
159
|
-
x="
|
|
159
|
+
x="13.761666"
|
|
160
160
|
y="0.53250003"
|
|
161
161
|
inkscape:path-effect="#path-effect3631"
|
|
162
|
-
d="M
|
|
162
|
+
d="M 16.4075,0.53250003 H 89.425831 A 2.6458333,2.6458333 45 0 1 92.071664,3.1783333 V 102.655 a 2.6458333,2.6458333 135 0 1 -2.645833,2.64583 H 16.4075 A 2.6458333,2.6458333 45 0 1 13.761666,102.655 V 3.1783333 A 2.6458333,2.6458333 135 0 1 16.4075,0.53250003 Z"
|
|
163
163
|
sodipodi:type="rect" />
|
|
164
164
|
<path
|
|
165
165
|
style="fill:#ffffff;fill-opacity:1;stroke:#b1b1b1;stroke-width:1.065;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
166
166
|
id="rect3114"
|
|
167
167
|
width="57.143333"
|
|
168
168
|
height="30.68499"
|
|
169
|
-
x="
|
|
169
|
+
x="24.344997"
|
|
170
170
|
y="12.382141"
|
|
171
171
|
inkscape:path-effect="#path-effect3633"
|
|
172
|
-
d="m
|
|
172
|
+
d="m 26.990831,12.382141 h 51.851667 a 2.6458333,2.6458333 45 0 1 2.645833,2.645833 v 25.393324 a 2.6458333,2.6458333 135 0 1 -2.645833,2.645833 H 26.990831 A 2.6458333,2.6458333 45 0 1 24.344997,40.421298 V 15.027974 a 2.6458333,2.6458333 135 0 1 2.645834,-2.645833 z"
|
|
173
173
|
sodipodi:type="rect" />
|
|
174
174
|
<text
|
|
175
175
|
xml:space="preserve"
|
|
176
176
|
style="font-style:normal;font-weight:normal;font-size:20.2809px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.362157"
|
|
177
|
-
x="
|
|
177
|
+
x="34.916286"
|
|
178
178
|
y="29.418192"
|
|
179
179
|
id="text1838"
|
|
180
180
|
transform="scale(0.78891107,1.26757)"><tspan
|
|
181
181
|
sodipodi:role="line"
|
|
182
182
|
id="tspan1836"
|
|
183
183
|
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:20.2809px;font-family:Ani;-inkscape-font-specification:Ani;stroke-width:0.362157"
|
|
184
|
-
x="
|
|
184
|
+
x="34.916286"
|
|
185
185
|
y="29.418192">0000.0</tspan></text>
|
|
186
186
|
<g
|
|
187
187
|
id="g59969"
|
|
188
|
-
transform="translate(
|
|
188
|
+
transform="translate(12.749672)">
|
|
189
189
|
<text
|
|
190
190
|
xml:space="preserve"
|
|
191
191
|
style="font-style:normal;font-weight:normal;font-size:14.5511px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#b1b1b1;fill-opacity:1;stroke:none;stroke-width:0.202098"
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
25
|
+
var calculator_exports = {};
|
|
26
|
+
__export(calculator_exports, {
|
|
27
|
+
default: () => Calculator
|
|
28
|
+
});
|
|
29
|
+
module.exports = __toCommonJS(calculator_exports);
|
|
30
|
+
var import_period = __toESM(require("./period"));
|
|
31
|
+
class Calculator {
|
|
32
|
+
constructor(config) {
|
|
33
|
+
this.period = new import_period.default();
|
|
34
|
+
this.config = config;
|
|
35
|
+
this.summaryName = config.summaryName;
|
|
36
|
+
}
|
|
37
|
+
initMeterInfo() {
|
|
38
|
+
return {
|
|
39
|
+
balance: 0,
|
|
40
|
+
consumptionAverage: 0,
|
|
41
|
+
consumptionPredictedTotal: 0,
|
|
42
|
+
consumptionTotal: 0,
|
|
43
|
+
costs: 0,
|
|
44
|
+
paid: 0,
|
|
45
|
+
recommendedPayment: 0
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
calculateMeterInfos(meterStates) {
|
|
49
|
+
const summary = this.initMeterInfo();
|
|
50
|
+
const collection = {
|
|
51
|
+
[this.summaryName]: summary
|
|
52
|
+
};
|
|
53
|
+
const meters = [];
|
|
54
|
+
for (const state of meterStates) {
|
|
55
|
+
const info = this.initMeterInfo();
|
|
56
|
+
const definition = state.meter;
|
|
57
|
+
collection[definition.alias] = info;
|
|
58
|
+
meters.push({ info, state, definition });
|
|
59
|
+
}
|
|
60
|
+
for (const { info, state } of meters) {
|
|
61
|
+
info.consumptionTotal = state.consumption;
|
|
62
|
+
info.consumptionAverage = this.period.calculateValuePerDay(state.consumption);
|
|
63
|
+
info.consumptionPredictedTotal = this.period.calculateExtrapolateValueForPeriod(state.consumption);
|
|
64
|
+
summary.consumptionTotal += info.consumptionTotal;
|
|
65
|
+
summary.consumptionAverage += info.consumptionAverage;
|
|
66
|
+
summary.consumptionPredictedTotal += info.consumptionPredictedTotal;
|
|
67
|
+
}
|
|
68
|
+
const basePrice = this.period.calculateElapsedAmountInPeriod(this.config.paymentBasePrice);
|
|
69
|
+
const paid = this.calculatePaid();
|
|
70
|
+
for (const { info, state, definition } of meters) {
|
|
71
|
+
const factor = info.consumptionTotal / summary.consumptionTotal;
|
|
72
|
+
info.costs = state.consumption * definition.pricePerUnit + basePrice * factor;
|
|
73
|
+
info.paid = paid * factor;
|
|
74
|
+
info.balance = info.paid - info.costs;
|
|
75
|
+
info.recommendedPayment = this.calculateRecommendation(info.costs);
|
|
76
|
+
summary.costs += info.costs;
|
|
77
|
+
summary.paid += info.paid;
|
|
78
|
+
summary.balance += info.balance;
|
|
79
|
+
summary.recommendedPayment += info.recommendedPayment;
|
|
80
|
+
}
|
|
81
|
+
return collection;
|
|
82
|
+
}
|
|
83
|
+
calculatePaid() {
|
|
84
|
+
const config = this.config;
|
|
85
|
+
return config.paymentCorrectionOffset + this.period.calculateElapsedAmountInPeriod(config.paymentValue * config.paymentCount);
|
|
86
|
+
}
|
|
87
|
+
calculateRecommendation(costs) {
|
|
88
|
+
return this.period.calculateExtrapolateValueForPeriod(costs) / this.config.paymentCount;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
92
|
+
0 && (module.exports = {});
|
|
93
|
+
//# sourceMappingURL=calculator.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/calculator.ts"],
|
|
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: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KAAK,mBAAmB,QAAQ;AAE/C,WAAK,QAAQ,MAAM,cAAc,WAAW,eAAe,YAAY;AACvE,WAAK,OAAO,OAAO;AACnB,WAAK,UAAU,KAAK,OAAO,KAAK;AAChC,WAAK,qBAAqB,KAAK,wBAAwB,KAAK,KAAK;AAEjE,cAAQ,SAAS,KAAK;AACtB,cAAQ,QAAQ,KAAK;AACrB,cAAQ,WAAW,KAAK;AACxB,cAAQ,sBAAsB,KAAK;AAAA,IACvC;AAEA,WAAO;AAAA,EACX;AAAA,EAGQ,gBAAwB;AAC5B,UAAM,SAAS,KAAK;AACpB,WAAO,OAAO,0BAA0B,KAAK,OAAO,+BAA+B,OAAO,eAAe,OAAO,YAAY;AAAA,EAChI;AAAA,EAEQ,wBAAwB,OAAuB;AACnD,WAAO,KAAK,OAAO,mCAAmC,KAAK,IAAI,KAAK,OAAO;AAAA,EAC/E;AAEJ;",
|
|
6
|
+
"names": ["Period"]
|
|
7
|
+
}
|
package/build/lib/typedef.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/lib/typedef.ts"],
|
|
4
|
-
"sourcesContent": ["export interface MeterState {\n meter: MeterDefinition;\n startValue: number;\n currentValue: number;\n consumption: number;\n}\n\nexport interface MeterDefinition {\n objectId: string;\n alias: string;\n pricePerUnit: number;\n}\n\nexport interface MeterConsumption {\n total: number;\n average: number;\n predicted: number;\n}\n\nexport interface DayInfo {\n firstDayOfYear: Date;\n daysInYear: number;\n daysSinceStartOfYear: number;\n}\n"],
|
|
4
|
+
"sourcesContent": ["export interface MeterState {\n meter: MeterDefinition;\n startValue: number;\n startValueDateTime: Date|null;\n currentValue: number;\n consumption: number;\n}\n\nexport interface MeterDefinition {\n objectId: string;\n alias: string;\n pricePerUnit: number;\n}\n\nexport interface CalculatorConfig {\n paymentValue: number;\n paymentCount: number;\n paymentCorrectionOffset: number;\n paymentBasePrice: number;\n summaryName: string;\n}\n\nexport interface MeterConsumption {\n total: number;\n average: number;\n predicted: number;\n}\n\nexport interface MeterInfo {\n balance: number;\n consumptionAverage: number;\n consumptionPredictedTotal: number;\n consumptionTotal: number;\n costs: number;\n paid: number;\n recommendedPayment: number;\n}\n\nexport interface MeterInfoCollection {\n [key: string]: MeterInfo\n}\n\nexport interface DayInfo {\n firstDayOfYear: Date;\n daysInYear: number;\n daysSinceStartOfYear: number;\n}\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/main.js
CHANGED
|
@@ -18,6 +18,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
18
18
|
mod
|
|
19
19
|
));
|
|
20
20
|
var utils = __toESM(require("@iobroker/adapter-core"));
|
|
21
|
+
var import_calculator = __toESM(require("./calculator"));
|
|
22
|
+
var import_round = __toESM(require("./round"));
|
|
21
23
|
class MeterStatistics extends utils.Adapter {
|
|
22
24
|
constructor(options = {}) {
|
|
23
25
|
super({
|
|
@@ -31,84 +33,27 @@ class MeterStatistics extends utils.Adapter {
|
|
|
31
33
|
}
|
|
32
34
|
async onReady() {
|
|
33
35
|
await this.assertObjectsExist();
|
|
34
|
-
const dayInfo = this.getDayInfo();
|
|
35
36
|
const meterStates = await this.getMeterStates();
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
this.
|
|
39
|
-
this.writeState("summary.consumptionPredictedTotal", this.roundConsumption(predicted));
|
|
40
|
-
const costs = this.calculateCosts(meterStates, dayInfo);
|
|
41
|
-
this.writeState("summary.costs", this.roundCosts(costs));
|
|
42
|
-
const paid = this.calculatePaid(dayInfo);
|
|
43
|
-
this.writeState("summary.paid", this.roundCosts(paid));
|
|
44
|
-
const current = paid - costs;
|
|
45
|
-
this.writeState("summary.balance", this.roundCosts(current));
|
|
46
|
-
const recommendedPayment = this.calculateRecommendation(costs, dayInfo);
|
|
47
|
-
this.writeState("summary.recommendedPayment", this.roundCosts(recommendedPayment));
|
|
37
|
+
const calculator = new import_calculator.default(this.config);
|
|
38
|
+
const meterInfos = calculator.calculateMeterInfos(meterStates);
|
|
39
|
+
this.writeMeterInfos(meterInfos);
|
|
48
40
|
this.end();
|
|
49
41
|
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
this.writeState(`
|
|
58
|
-
this.writeState(`
|
|
59
|
-
this.writeState(`
|
|
60
|
-
totalConsumption += meterState.consumption;
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
total: totalConsumption,
|
|
64
|
-
average: totalConsumption / dayInfo.daysSinceStartOfYear,
|
|
65
|
-
predicted: totalConsumption / dayInfo.daysSinceStartOfYear * dayInfo.daysInYear
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
calculateCosts(meterStates, dayInfo) {
|
|
69
|
-
let usedCosts = 0;
|
|
70
|
-
const basePricePerDay = this.config.paymentBasePrice / dayInfo.daysInYear;
|
|
71
|
-
usedCosts += basePricePerDay * dayInfo.daysSinceStartOfYear;
|
|
72
|
-
for (const meterState of meterStates) {
|
|
73
|
-
const meter = meterState.meter;
|
|
74
|
-
this.writeState(`meter.${meter.alias}.costs`, this.roundCosts(meterState.consumption * meterState.meter.pricePerUnit));
|
|
75
|
-
usedCosts += meterState.consumption * meterState.meter.pricePerUnit;
|
|
42
|
+
writeMeterInfos(meterInfos) {
|
|
43
|
+
for (const meterName in meterInfos) {
|
|
44
|
+
const meterInfo = meterInfos[meterName];
|
|
45
|
+
this.writeState(`meters.${meterName}.balance`, import_round.default.costs(meterInfo.balance));
|
|
46
|
+
this.writeState(`meters.${meterName}.consumptionAverage`, import_round.default.consumption(meterInfo.consumptionAverage));
|
|
47
|
+
this.writeState(`meters.${meterName}.consumptionPredictedTotal`, import_round.default.consumption(meterInfo.consumptionPredictedTotal));
|
|
48
|
+
this.writeState(`meters.${meterName}.consumptionTotal`, import_round.default.consumption(meterInfo.consumptionTotal));
|
|
49
|
+
this.writeState(`meters.${meterName}.costs`, import_round.default.costs(meterInfo.costs));
|
|
50
|
+
this.writeState(`meters.${meterName}.paid`, import_round.default.costs(meterInfo.paid));
|
|
51
|
+
this.writeState(`meters.${meterName}.recommendedPayment`, import_round.default.costs(meterInfo.recommendedPayment));
|
|
76
52
|
}
|
|
77
|
-
return usedCosts;
|
|
78
|
-
}
|
|
79
|
-
calculatePaid(dayInfo) {
|
|
80
|
-
let paid = this.config.paymentCorrectionOffset;
|
|
81
|
-
const paymentPerDay = this.config.paymentValue * this.config.paymentCount / dayInfo.daysInYear;
|
|
82
|
-
paid += paymentPerDay * dayInfo.daysSinceStartOfYear;
|
|
83
|
-
return paid;
|
|
84
|
-
}
|
|
85
|
-
calculateRecommendation(costs, dayInfo) {
|
|
86
|
-
return this.roundCosts(costs / dayInfo.daysSinceStartOfYear * dayInfo.daysInYear / this.config.paymentCount);
|
|
87
|
-
}
|
|
88
|
-
roundCosts(costs) {
|
|
89
|
-
return Math.round(costs * 100) / 100;
|
|
90
|
-
}
|
|
91
|
-
roundConsumption(consumption) {
|
|
92
|
-
return Math.round(consumption * 1e3) / 1e3;
|
|
93
|
-
}
|
|
94
|
-
getDaysInYear() {
|
|
95
|
-
return 365;
|
|
96
|
-
}
|
|
97
|
-
getDaysSince(start) {
|
|
98
|
-
const now = new Date();
|
|
99
|
-
const diff = now.valueOf() - start.valueOf();
|
|
100
|
-
const oneDay = 1e3 * 60 * 60 * 24;
|
|
101
|
-
return Math.floor(diff / oneDay);
|
|
102
53
|
}
|
|
103
54
|
writeState(id, value) {
|
|
104
|
-
this.
|
|
105
|
-
|
|
106
|
-
async getMeterStates() {
|
|
107
|
-
const meterStates = [];
|
|
108
|
-
for (const meter of this.config.meters) {
|
|
109
|
-
meterStates.push(await this.getMeterState(meter));
|
|
110
|
-
}
|
|
111
|
-
return meterStates;
|
|
55
|
+
const promise = this.setStateAsync(id, { val: value, ack: false });
|
|
56
|
+
this.pendingPromises.push(promise);
|
|
112
57
|
}
|
|
113
58
|
getNumericStateValue(state, onErrorMessage) {
|
|
114
59
|
const stateValue = state == null ? void 0 : state.val;
|
|
@@ -117,31 +62,69 @@ class MeterStatistics extends utils.Adapter {
|
|
|
117
62
|
}
|
|
118
63
|
throw new Error(onErrorMessage);
|
|
119
64
|
}
|
|
65
|
+
async getMeterStates() {
|
|
66
|
+
const meterStates = [];
|
|
67
|
+
for (const meter of this.config.meters) {
|
|
68
|
+
meterStates.push(await this.getMeterState(meter));
|
|
69
|
+
}
|
|
70
|
+
return meterStates;
|
|
71
|
+
}
|
|
120
72
|
async getMeterState(meter) {
|
|
73
|
+
var _a;
|
|
74
|
+
const meterName = meter.alias;
|
|
75
|
+
const currentValueState = await this.getForeignStateAsync(meter.objectId);
|
|
121
76
|
const currentValue = this.getNumericStateValue(
|
|
122
|
-
|
|
123
|
-
`Could not read meter "${
|
|
124
|
-
);
|
|
77
|
+
currentValueState,
|
|
78
|
+
`Could not read meter "${meterName}" with id: ${meter.objectId}`
|
|
79
|
+
) || 0;
|
|
80
|
+
const startValueState = await this.getStateAsync(`configuration.${meterName}.startValue`);
|
|
81
|
+
let startValueDateTime = null;
|
|
82
|
+
if (!startValueState) {
|
|
83
|
+
await this.setStateAsync(`configuration.${meterName}.startValue`, { val: currentValue, ack: true });
|
|
84
|
+
startValueDateTime = new Date(import_round.default.precise((currentValueState == null ? void 0 : currentValueState.ts) || Date.now(), -3));
|
|
85
|
+
await this.setStateAsync(`configuration.${meterName}.readingDateTime`, { val: startValueDateTime.toISOString(), ack: true });
|
|
86
|
+
}
|
|
125
87
|
const startValue = this.getNumericStateValue(
|
|
126
|
-
await this.getStateAsync(`
|
|
127
|
-
`Could not read start value for meter "${
|
|
88
|
+
startValueState || await this.getStateAsync(`configuration.${meterName}.startValue`),
|
|
89
|
+
`Could not read start value for meter "${meterName}".`
|
|
128
90
|
);
|
|
91
|
+
if (!startValueDateTime) {
|
|
92
|
+
const startValueDateTimeValue = (_a = await this.getStateAsync(`configuration.${meterName}.readingDateTime`)) == null ? void 0 : _a.val;
|
|
93
|
+
if (typeof startValueDateTimeValue === "string") {
|
|
94
|
+
try {
|
|
95
|
+
startValueDateTime = new Date(Date.parse(startValueDateTimeValue));
|
|
96
|
+
} catch (e) {
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
129
100
|
return {
|
|
130
101
|
meter,
|
|
131
102
|
currentValue,
|
|
132
103
|
startValue,
|
|
104
|
+
startValueDateTime,
|
|
133
105
|
consumption: currentValue - startValue
|
|
134
106
|
};
|
|
135
107
|
}
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
const daysInYear = this.getDaysInYear();
|
|
139
|
-
const daysSinceStartOfYear = this.getDaysSince(firstDayOfYear);
|
|
140
|
-
return { firstDayOfYear, daysInYear, daysSinceStartOfYear };
|
|
141
|
-
}
|
|
142
|
-
async assertObjectsExist() {
|
|
108
|
+
assertObjectsExist() {
|
|
109
|
+
const promises = [];
|
|
143
110
|
for (const meter of this.config.meters) {
|
|
144
|
-
|
|
111
|
+
promises.push(...this.assertMeterObjectsExist(meter.alias));
|
|
112
|
+
}
|
|
113
|
+
promises.push(...this.assertMeterObjectsExist(this.config.summaryName, false));
|
|
114
|
+
return Promise.allSettled(promises);
|
|
115
|
+
}
|
|
116
|
+
assertMeterObjectsExist(meterName, hasStartValue = true) {
|
|
117
|
+
const promises = [];
|
|
118
|
+
promises.push(this.setObjectNotExistsAsync(`configuration.${meterName}`, {
|
|
119
|
+
type: "device",
|
|
120
|
+
common: {
|
|
121
|
+
name: `configuration.${meterName}`,
|
|
122
|
+
icon: `/icons/${hasStartValue ? "device" : "summary"}-icon.svg`
|
|
123
|
+
},
|
|
124
|
+
native: {}
|
|
125
|
+
}));
|
|
126
|
+
if (hasStartValue) {
|
|
127
|
+
promises.push(this.setObjectNotExistsAsync(`configuration.${meterName}.startValue`, {
|
|
145
128
|
type: "state",
|
|
146
129
|
common: {
|
|
147
130
|
name: "Start value",
|
|
@@ -152,60 +135,24 @@ class MeterStatistics extends utils.Adapter {
|
|
|
152
135
|
unit: this.config.meterUnit
|
|
153
136
|
},
|
|
154
137
|
native: {}
|
|
155
|
-
});
|
|
156
|
-
|
|
138
|
+
}));
|
|
139
|
+
promises.push(this.setObjectNotExistsAsync(`configuration.${meterName}.readingDateTime`, {
|
|
157
140
|
type: "state",
|
|
158
141
|
common: {
|
|
159
|
-
name: "
|
|
160
|
-
|
|
142
|
+
name: "Timestamp of reading start value",
|
|
143
|
+
desc: "ONLY INFORMATION: Does not affect any calculation yet.",
|
|
144
|
+
type: "string",
|
|
161
145
|
role: "state",
|
|
162
146
|
read: true,
|
|
163
|
-
write:
|
|
164
|
-
unit: this.config.meterUnit
|
|
147
|
+
write: true
|
|
165
148
|
},
|
|
166
149
|
native: {}
|
|
167
|
-
});
|
|
168
|
-
await this.setObjectNotExistsAsync(`meter.${meter.alias}.consumptionTotal`, {
|
|
169
|
-
type: "state",
|
|
170
|
-
common: {
|
|
171
|
-
name: "Total consumption in period",
|
|
172
|
-
type: "number",
|
|
173
|
-
role: "state",
|
|
174
|
-
read: true,
|
|
175
|
-
write: false,
|
|
176
|
-
unit: this.config.meterUnit
|
|
177
|
-
},
|
|
178
|
-
native: {}
|
|
179
|
-
});
|
|
180
|
-
await this.setObjectNotExistsAsync(`meter.${meter.alias}.consumptionPredictedTotal`, {
|
|
181
|
-
type: "state",
|
|
182
|
-
common: {
|
|
183
|
-
name: "Total predicted consumption in period",
|
|
184
|
-
type: "number",
|
|
185
|
-
role: "state",
|
|
186
|
-
read: true,
|
|
187
|
-
write: false,
|
|
188
|
-
unit: this.config.meterUnit
|
|
189
|
-
},
|
|
190
|
-
native: {}
|
|
191
|
-
});
|
|
192
|
-
await this.setObjectNotExistsAsync(`meter.${meter.alias}.costs`, {
|
|
193
|
-
type: "state",
|
|
194
|
-
common: {
|
|
195
|
-
name: "Total costs",
|
|
196
|
-
type: "number",
|
|
197
|
-
role: "state",
|
|
198
|
-
read: true,
|
|
199
|
-
write: false,
|
|
200
|
-
unit: this.config.paymentUnit
|
|
201
|
-
},
|
|
202
|
-
native: {}
|
|
203
|
-
});
|
|
150
|
+
}));
|
|
204
151
|
}
|
|
205
|
-
|
|
152
|
+
promises.push(this.setObjectNotExistsAsync(`meters.${meterName}.consumptionAverage`, {
|
|
206
153
|
type: "state",
|
|
207
154
|
common: {
|
|
208
|
-
name: "
|
|
155
|
+
name: "Average consumption in period",
|
|
209
156
|
type: "number",
|
|
210
157
|
role: "state",
|
|
211
158
|
read: true,
|
|
@@ -213,11 +160,11 @@ class MeterStatistics extends utils.Adapter {
|
|
|
213
160
|
unit: this.config.meterUnit
|
|
214
161
|
},
|
|
215
162
|
native: {}
|
|
216
|
-
});
|
|
217
|
-
|
|
163
|
+
}));
|
|
164
|
+
promises.push(this.setObjectNotExistsAsync(`meters.${meterName}.consumptionTotal`, {
|
|
218
165
|
type: "state",
|
|
219
166
|
common: {
|
|
220
|
-
name: "Total
|
|
167
|
+
name: "Total consumption in period",
|
|
221
168
|
type: "number",
|
|
222
169
|
role: "state",
|
|
223
170
|
read: true,
|
|
@@ -225,11 +172,11 @@ class MeterStatistics extends utils.Adapter {
|
|
|
225
172
|
unit: this.config.meterUnit
|
|
226
173
|
},
|
|
227
174
|
native: {}
|
|
228
|
-
});
|
|
229
|
-
|
|
175
|
+
}));
|
|
176
|
+
promises.push(this.setObjectNotExistsAsync(`meters.${meterName}.consumptionPredictedTotal`, {
|
|
230
177
|
type: "state",
|
|
231
178
|
common: {
|
|
232
|
-
name: "
|
|
179
|
+
name: "Total predicted consumption in period",
|
|
233
180
|
type: "number",
|
|
234
181
|
role: "state",
|
|
235
182
|
read: true,
|
|
@@ -237,11 +184,11 @@ class MeterStatistics extends utils.Adapter {
|
|
|
237
184
|
unit: this.config.meterUnit
|
|
238
185
|
},
|
|
239
186
|
native: {}
|
|
240
|
-
});
|
|
241
|
-
|
|
187
|
+
}));
|
|
188
|
+
promises.push(this.setObjectNotExistsAsync(`meters.${meterName}.costs`, {
|
|
242
189
|
type: "state",
|
|
243
190
|
common: {
|
|
244
|
-
name: "Total
|
|
191
|
+
name: "Total costs",
|
|
245
192
|
type: "number",
|
|
246
193
|
role: "state",
|
|
247
194
|
read: true,
|
|
@@ -249,11 +196,11 @@ class MeterStatistics extends utils.Adapter {
|
|
|
249
196
|
unit: this.config.paymentUnit
|
|
250
197
|
},
|
|
251
198
|
native: {}
|
|
252
|
-
});
|
|
253
|
-
|
|
199
|
+
}));
|
|
200
|
+
promises.push(this.setObjectNotExistsAsync(`meters.${meterName}.paid`, {
|
|
254
201
|
type: "state",
|
|
255
202
|
common: {
|
|
256
|
-
name: "Total
|
|
203
|
+
name: "Total paid value",
|
|
257
204
|
type: "number",
|
|
258
205
|
role: "state",
|
|
259
206
|
read: true,
|
|
@@ -261,8 +208,8 @@ class MeterStatistics extends utils.Adapter {
|
|
|
261
208
|
unit: this.config.paymentUnit
|
|
262
209
|
},
|
|
263
210
|
native: {}
|
|
264
|
-
});
|
|
265
|
-
|
|
211
|
+
}));
|
|
212
|
+
promises.push(this.setObjectNotExistsAsync(`meters.${meterName}.balance`, {
|
|
266
213
|
type: "state",
|
|
267
214
|
common: {
|
|
268
215
|
name: "Current balance",
|
|
@@ -273,8 +220,8 @@ class MeterStatistics extends utils.Adapter {
|
|
|
273
220
|
unit: this.config.paymentUnit
|
|
274
221
|
},
|
|
275
222
|
native: {}
|
|
276
|
-
});
|
|
277
|
-
|
|
223
|
+
}));
|
|
224
|
+
promises.push(this.setObjectNotExistsAsync(`meters.${meterName}.recommendedPayment`, {
|
|
278
225
|
type: "state",
|
|
279
226
|
common: {
|
|
280
227
|
name: "Recommended payment per payment interval",
|
|
@@ -285,7 +232,8 @@ class MeterStatistics extends utils.Adapter {
|
|
|
285
232
|
unit: this.config.paymentUnit
|
|
286
233
|
},
|
|
287
234
|
native: {}
|
|
288
|
-
});
|
|
235
|
+
}));
|
|
236
|
+
return promises;
|
|
289
237
|
}
|
|
290
238
|
end() {
|
|
291
239
|
if (this.unloaded)
|
package/build/main.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/main.ts"],
|
|
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 {DayInfo, MeterConsumption, MeterDefinition, MeterState} from './lib/typedef';\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 dayInfo = this.getDayInfo();\n const meterStates = await this.getMeterStates();\n\n const {total, average, predicted} = this.calculateMeterConsumption(meterStates, dayInfo);\n this.writeState('summary.consumptionTotal', this.roundConsumption(total));\n this.writeState('summary.consumptionAverage', this.roundConsumption(average));\n this.writeState('summary.consumptionPredictedTotal', this.roundConsumption(predicted));\n\n const costs = this.calculateCosts(meterStates, dayInfo);\n this.writeState('summary.costs', this.roundCosts(costs));\n\n const paid = this.calculatePaid(dayInfo);\n this.writeState('summary.paid', this.roundCosts(paid));\n\n const current = paid - costs;\n this.writeState('summary.balance', this.roundCosts(current));\n\n const recommendedPayment = this.calculateRecommendation(costs, dayInfo);\n this.writeState('summary.recommendedPayment', this.roundCosts(recommendedPayment));\n\n this.end();\n }\n\n private addPendingPromise(promise: Promise<any>): void {\n this.pendingPromises.push(promise);\n }\n\n private calculateMeterConsumption(meterStates: MeterState[], dayInfo: DayInfo): MeterConsumption {\n\n let totalConsumption = 0;\n\n for (const meterState of meterStates) {\n const meter = meterState.meter;\n this.writeState(`meter.${meter.alias}.consumptionTotal`, this.roundConsumption(meterState.consumption));\n this.writeState(`meter.${meter.alias}.consumptionAverage`, this.roundConsumption(meterState.consumption / dayInfo.daysSinceStartOfYear));\n this.writeState(`meter.${meter.alias}.consumptionPredictedTotal`, this.roundConsumption(meterState.consumption / dayInfo.daysSinceStartOfYear * dayInfo.daysInYear));\n totalConsumption += meterState.consumption;\n }\n\n return {\n total: totalConsumption,\n average: totalConsumption / dayInfo.daysSinceStartOfYear,\n predicted: totalConsumption / dayInfo.daysSinceStartOfYear * dayInfo.daysInYear,\n };\n }\n\n private calculateCosts(meterStates: MeterState[], dayInfo: DayInfo): number {\n\n let usedCosts = 0;\n\n const basePricePerDay = this.config.paymentBasePrice / dayInfo.daysInYear;\n usedCosts += basePricePerDay * dayInfo.daysSinceStartOfYear;\n\n for (const meterState of meterStates) {\n const meter = meterState.meter;\n this.writeState(`meter.${meter.alias}.costs`, this.roundCosts(meterState.consumption * meterState.meter.pricePerUnit));\n usedCosts += meterState.consumption * meterState.meter.pricePerUnit;\n }\n\n return usedCosts;\n }\n\n private calculatePaid(dayInfo: DayInfo): number {\n\n let paid = this.config.paymentCorrectionOffset;\n\n const paymentPerDay = this.config.paymentValue * this.config.paymentCount / dayInfo.daysInYear;\n paid += paymentPerDay * dayInfo.daysSinceStartOfYear;\n\n return paid;\n }\n\n private calculateRecommendation(costs: number, dayInfo: DayInfo): number {\n return this.roundCosts(costs / dayInfo.daysSinceStartOfYear * dayInfo.daysInYear / this.config.paymentCount);\n }\n\n\n public roundCosts(costs: number): number {\n return Math.round(costs * 100) / 100;\n }\n\n public roundConsumption(consumption: number): number {\n return Math.round(consumption * 1000) / 1000;\n }\n\n public getDaysInYear(): number {\n return 365;\n }\n\n public getDaysSince(start: Date): number {\n const now = new Date();\n const diff = now.valueOf() - start.valueOf();\n const oneDay = 1000 * 60 * 60 * 24;\n return Math.floor(diff / oneDay);\n }\n\n private writeState(id: string, value: any): void {\n this.addPendingPromise(this.setStateAsync(id, {val: value, ack: true}));\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 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 getMeterState(meter: MeterDefinition): Promise<MeterState> {\n\n const currentValue = this.getNumericStateValue(\n await this.getForeignStateAsync(meter.objectId),\n `Could not read meter \"${meter.alias}\" with id: ${meter.objectId}`\n );\n const startValue = this.getNumericStateValue(\n await this.getStateAsync(`meter.${meter.alias}.startValue`),\n `Could not read start value for meter \"${meter.alias}\".`\n );\n\n return {\n meter,\n currentValue,\n startValue,\n consumption: currentValue - startValue,\n };\n }\n\n private getDayInfo(): DayInfo {\n\n const firstDayOfYear = new Date((new Date()).getFullYear(), 0, 0);\n const daysInYear = this.getDaysInYear();\n const daysSinceStartOfYear = this.getDaysSince(firstDayOfYear);\n\n return {firstDayOfYear, daysInYear, daysSinceStartOfYear};\n }\n\n private async assertObjectsExist(): Promise<void> {\n\n for (const meter of this.config.meters) {\n\n await this.setObjectNotExistsAsync(`meter.${meter.alias}.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 await this.setObjectNotExistsAsync(`meter.${meter.alias}.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 await this.setObjectNotExistsAsync(`meter.${meter.alias}.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 await this.setObjectNotExistsAsync(`meter.${meter.alias}.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 await this.setObjectNotExistsAsync(`meter.${meter.alias}.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\n }\n\n await this.setObjectNotExistsAsync(`summary.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\n await this.setObjectNotExistsAsync(`summary.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\n await this.setObjectNotExistsAsync(`summary.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\n await this.setObjectNotExistsAsync(`summary.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\n await this.setObjectNotExistsAsync(`summary.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\n await this.setObjectNotExistsAsync(`summary.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\n await this.setObjectNotExistsAsync(`summary.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\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": ";;;;;;;;;;;;;;;;;;;AAMA,YAAuB;
|
|
6
|
-
"names": []
|
|
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": ";;;;;;;;;;;;;;;;;;;AAMA,YAAuB;AAEvB,wBAAuB;AACvB,mBAAkB;AAKlB,MAAM,wBAAwB,MAAM,QAAQ;AAAA,EAMjC,YAAY,UAAyC,CA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;AAAA,MACA,QAAQ,CAAC;AAAA,IACb,CAAC,CAAC;AACF,aAAS,KAAK,KAAK,wBAAwB,UAAU,qBAAqB;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,gCAAgC;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;AAAU;AACnB,YAAQ,WAAW,KAAK,eAAe,EAAE,QAAQ,MAAM;AACnD,UAAI,KAAK,MAAM;AACX,aAAK,KAAK;AAAA,MACd;AAAA,IACJ,CAAC;AAAA,EACL;AAAA,EAKQ,SAAS,UAA4B;AACzC,SAAK,WAAW;AAChB,QAAI;AAEA,eAAS;AAAA,IACb,SAAS,GAAP;AACE,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
|
+
"names": ["Calculator", "Round"]
|
|
7
7
|
}
|
package/build/period.js
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var period_exports = {};
|
|
20
|
+
__export(period_exports, {
|
|
21
|
+
default: () => Period
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(period_exports);
|
|
24
|
+
class Period {
|
|
25
|
+
constructor(startOfPeriod = null) {
|
|
26
|
+
const now = this.now;
|
|
27
|
+
const periodStartDateTime = startOfPeriod || new Date(now.getFullYear(), 0, 0);
|
|
28
|
+
const periodEndDateTime = this.incrementDatetimeByOneYear(periodStartDateTime);
|
|
29
|
+
const periodStartTimestamp = periodStartDateTime.valueOf();
|
|
30
|
+
const periodEndTimestamp = periodEndDateTime.valueOf();
|
|
31
|
+
const unitsPerDay = new Date("1900-01-02T00:00:00").valueOf() - new Date("1900-01-01T00:00:00").valueOf();
|
|
32
|
+
const unitsInPeriod = periodEndTimestamp - periodStartTimestamp;
|
|
33
|
+
const elapsedUnitsInPeriod = now.valueOf() - periodStartTimestamp;
|
|
34
|
+
this.perDayFactor = 1 / elapsedUnitsInPeriod * unitsPerDay;
|
|
35
|
+
this.extrapolatePerPeriodFactor = 1 / elapsedUnitsInPeriod * unitsInPeriod;
|
|
36
|
+
this.elapsedInPeriodFactor = 1 / unitsInPeriod * elapsedUnitsInPeriod;
|
|
37
|
+
}
|
|
38
|
+
get now() {
|
|
39
|
+
if (!Period.now) {
|
|
40
|
+
Period.now = new Date();
|
|
41
|
+
}
|
|
42
|
+
return Period.now;
|
|
43
|
+
}
|
|
44
|
+
incrementDatetimeByOneYear(date) {
|
|
45
|
+
const newDate = new Date(date);
|
|
46
|
+
newDate.setFullYear(date.getFullYear() + 1);
|
|
47
|
+
return newDate;
|
|
48
|
+
}
|
|
49
|
+
calculateValuePerDay(amountInPeriod) {
|
|
50
|
+
return amountInPeriod * this.perDayFactor;
|
|
51
|
+
}
|
|
52
|
+
calculateExtrapolateValueForPeriod(amountInPeriod) {
|
|
53
|
+
return amountInPeriod * this.extrapolatePerPeriodFactor;
|
|
54
|
+
}
|
|
55
|
+
calculateElapsedAmountInPeriod(totalAmountInYear) {
|
|
56
|
+
return totalAmountInYear * this.elapsedInPeriodFactor;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
60
|
+
0 && (module.exports = {});
|
|
61
|
+
//# sourceMappingURL=period.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/period.ts"],
|
|
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,EAOxB,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,cAAe,IAAI,KAAK,qBAAqB,EAAG,QAAQ,IAAK,IAAI,KAAK,qBAAqB,EAAG,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,IAAI,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
|
+
"names": []
|
|
7
|
+
}
|
package/build/round.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var round_exports = {};
|
|
20
|
+
__export(round_exports, {
|
|
21
|
+
default: () => round_default
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(round_exports);
|
|
24
|
+
class Round {
|
|
25
|
+
costs(costs) {
|
|
26
|
+
return this.precise(costs, 2);
|
|
27
|
+
}
|
|
28
|
+
consumption(consumption) {
|
|
29
|
+
return this.precise(consumption, 3);
|
|
30
|
+
}
|
|
31
|
+
precise(value, scale) {
|
|
32
|
+
if (null === value) {
|
|
33
|
+
return value;
|
|
34
|
+
}
|
|
35
|
+
const factor = Math.pow(10, scale);
|
|
36
|
+
return Math.round(value * factor) / factor;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
var round_default = new Round();
|
|
40
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
+
0 && (module.exports = {});
|
|
42
|
+
//# sourceMappingURL=round.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/round.ts"],
|
|
4
|
+
"sourcesContent": ["class Round {\n\n public costs(costs: number): number {\n return this.precise(costs, 2);\n }\n\n public consumption(consumption: number): number {\n return this.precise(consumption, 3);\n }\n\n public precise(value: number, scale: number): number {\n if (null === value) {\n return value;\n }\n const factor = Math.pow(10, scale);\n return Math.round(value * factor) / factor;\n }\n\n}\n\nexport default new Round();\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,MAAM,MAAM;AAAA,EAED,MAAM,OAAuB;AAChC,WAAO,KAAK,QAAQ,OAAO,CAAC;AAAA,EAChC;AAAA,EAEO,YAAY,aAA6B;AAC5C,WAAO,KAAK,QAAQ,aAAa,CAAC;AAAA,EACtC;AAAA,EAEO,QAAQ,OAAe,OAAuB;AACjD,QAAI,SAAS,OAAO;AAChB,aAAO;AAAA,IACX;AACA,UAAM,SAAS,KAAK,IAAI,IAAI,KAAK;AACjC,WAAO,KAAK,MAAM,QAAQ,MAAM,IAAI;AAAA,EACxC;AAEJ;AAEA,IAAO,gBAAQ,IAAI,MAAM;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/io-package.json
CHANGED
|
@@ -1,8 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"common": {
|
|
3
3
|
"name": "meter-statistics",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.1.1",
|
|
5
5
|
"news": {
|
|
6
|
+
"0.1.1": {
|
|
7
|
+
"en": "[FEATURE] Add device icons",
|
|
8
|
+
"de": "(STÖHNT) Gerätesymbole hinzufügen",
|
|
9
|
+
"ru": "[Фекция] Добавьте иконки устройства",
|
|
10
|
+
"pt": "[FEATURE] Adicionar ícones do dispositivo",
|
|
11
|
+
"nl": "[FEATURE] Voeg apparatuur toe",
|
|
12
|
+
"fr": "[FEATURE] Ajouter les icônes de périphérique",
|
|
13
|
+
"it": "[FEATURE] Aggiungi icone del dispositivo",
|
|
14
|
+
"es": "[Feria] Añadir iconos de dispositivo",
|
|
15
|
+
"pl": "(FEATURE) Addd device ikon",
|
|
16
|
+
"uk": "[Життя] Додавання іконок пристрою",
|
|
17
|
+
"zh-cn": "[签字] 添加装置"
|
|
18
|
+
},
|
|
19
|
+
"0.1.0": {
|
|
20
|
+
"en": "[TASK] Code refactoring\n[TASK] Add test cases",
|
|
21
|
+
"de": "[TASK] Code-Refactoring\n(TASK) Testfälle hinzufügen",
|
|
22
|
+
"ru": "[TASK] Код рефакторинг\n[ТАСК] Добавить тестовые случаи",
|
|
23
|
+
"pt": "[TASK] Refactoring de código\n[TASK] Adicionar casos de teste",
|
|
24
|
+
"nl": "Code refactoring\n[TASK] Voeg testzaken toe",
|
|
25
|
+
"fr": "[TASK] Code refactoring\n[TASK] Ajouter les cas d ' essai",
|
|
26
|
+
"it": "[TASK] Refactoring del codice\n[TASK] Aggiungere i casi di test",
|
|
27
|
+
"es": "[TASK] Code refactoring\n[TASK] Agregar casos de prueba",
|
|
28
|
+
"pl": "(TASK) Code refactoring (ang.)\n(TASK) (ang.). Addd test case",
|
|
29
|
+
"uk": "[TASK] Рефакторинг коду\n[ТАСК] Додавання тестових випадків",
|
|
30
|
+
"zh-cn": "[TASK]守则\n[TASK] 增加试验案件"
|
|
31
|
+
},
|
|
6
32
|
"0.0.4": {
|
|
7
33
|
"en": "[BUGFIX] Fix calculation of predicted total\n[TASK] Update project",
|
|
8
34
|
"de": "[BUGFIX] Berechnung der prognostizierten Summe festsetzen\n[TASK] Projekt aktualisieren",
|
|
@@ -126,6 +152,7 @@
|
|
|
126
152
|
"paymentCount": 0,
|
|
127
153
|
"paymentCorrectionOffset": 0,
|
|
128
154
|
"paymentBasePrice": 0,
|
|
155
|
+
"summaryName": "summary",
|
|
129
156
|
"meters": []
|
|
130
157
|
},
|
|
131
158
|
"objects": [],
|