iobroker.meter-statistics 0.0.1 → 0.0.3
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 +1 -1
- package/README.md +8 -5
- package/admin/jsonConfig.json +10 -13
- package/admin/meter-statistics.png +0 -0
- package/admin/meter-statistics.svg +232 -0
- package/build/lib/typedef.js.map +1 -1
- package/build/main.js +106 -31
- package/build/main.js.map +2 -2
- package/io-package.json +116 -89
- package/package.json +1 -1
- package/build/lib/accounting-helper.js +0 -28
- package/build/lib/accounting-helper.js.map +0 -7
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) 2023 jb-io
|
|
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
|
|
package/README.md
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
[](https://www.npmjs.com/package/iobroker.meter-statistics)
|
|
6
6
|

|
|
7
7
|

|
|
8
|
+
[](https://www.gnu.org/licenses/gpl-3.0)
|
|
9
|
+
|
|
8
10
|
|
|
9
11
|
[](https://nodei.co/npm/iobroker.meter-statistics/)
|
|
10
12
|
|
|
@@ -107,14 +109,15 @@ Please refer to the [`dev-server` documentation](https://github.com/ioBroker/dev
|
|
|
107
109
|
Placeholder for the next version (at the beginning of the line):
|
|
108
110
|
### **WORK IN PROGRESS**
|
|
109
111
|
-->
|
|
112
|
+
### 0.0.3 (2023-03-04)
|
|
113
|
+
* Add predicted consumption
|
|
110
114
|
|
|
111
|
-
###
|
|
112
|
-
|
|
115
|
+
### 0.0.2 (2023-03-04)
|
|
116
|
+
* Change Logo
|
|
113
117
|
|
|
114
118
|
### 0.0.1 (2023-03-01)
|
|
115
119
|
* (jb-io) initial release
|
|
116
120
|
|
|
117
|
-
##
|
|
118
|
-
[Licensed under GPLv3 or later](LICENSE)
|
|
121
|
+
## License
|
|
119
122
|
|
|
120
|
-
Copyright (c) 2023 jb-io
|
|
123
|
+
[Licensed under GPLv3](LICENSE) Copyright (c) 2023 jb-io
|
package/admin/jsonConfig.json
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"type": "text",
|
|
20
20
|
"label": "Unit of payment"
|
|
21
21
|
}
|
|
22
|
-
}
|
|
22
|
+
}
|
|
23
23
|
},
|
|
24
24
|
"headerPayment": {
|
|
25
25
|
"type": "header",
|
|
@@ -41,12 +41,17 @@
|
|
|
41
41
|
"min": 1,
|
|
42
42
|
"newLine": true
|
|
43
43
|
},
|
|
44
|
+
"paymentBasePrice": {
|
|
45
|
+
"type": "number",
|
|
46
|
+
"label": "Base price that is paid once",
|
|
47
|
+
"newLine": true
|
|
48
|
+
},
|
|
44
49
|
"paymentCorrectionOffset": {
|
|
45
50
|
"type": "number",
|
|
46
51
|
"label": "Payment correction offset",
|
|
47
52
|
"newLine": true
|
|
48
53
|
}
|
|
49
|
-
}
|
|
54
|
+
}
|
|
50
55
|
},
|
|
51
56
|
"headerMeters": {
|
|
52
57
|
"type": "header",
|
|
@@ -58,7 +63,7 @@
|
|
|
58
63
|
"items": [
|
|
59
64
|
{
|
|
60
65
|
"attr": "objectId",
|
|
61
|
-
"width": "
|
|
66
|
+
"width": "50%",
|
|
62
67
|
"title": "Object ID",
|
|
63
68
|
"type": "objectId",
|
|
64
69
|
"validator": "!!data.objectId",
|
|
@@ -74,21 +79,13 @@
|
|
|
74
79
|
},
|
|
75
80
|
{
|
|
76
81
|
"attr": "pricePerUnit",
|
|
77
|
-
"width": "
|
|
82
|
+
"width": "20%",
|
|
78
83
|
"title": "Price per unit",
|
|
79
84
|
"type": "number",
|
|
80
85
|
"validator": "!!data.pricePerUnit",
|
|
81
86
|
"validatorNoSaveOnError": true
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
"attr": "basePrice",
|
|
85
|
-
"width": "15%",
|
|
86
|
-
"title": "Base price",
|
|
87
|
-
"type": "number",
|
|
88
|
-
"validator": "!!data.basePrice",
|
|
89
|
-
"validatorNoSaveOnError": true
|
|
90
87
|
}
|
|
91
88
|
]
|
|
92
89
|
}
|
|
93
90
|
}
|
|
94
|
-
}
|
|
91
|
+
}
|
|
Binary file
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
|
2
|
+
<svg
|
|
3
|
+
width="300"
|
|
4
|
+
height="400"
|
|
5
|
+
viewBox="0 0 79.374998 105.83333"
|
|
6
|
+
version="1.1"
|
|
7
|
+
id="svg5"
|
|
8
|
+
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
|
|
9
|
+
sodipodi:docname="meter-statistics.svg"
|
|
10
|
+
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
11
|
+
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
12
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
13
|
+
xmlns:svg="http://www.w3.org/2000/svg">
|
|
14
|
+
<sodipodi:namedview
|
|
15
|
+
id="namedview7"
|
|
16
|
+
pagecolor="#ffffff"
|
|
17
|
+
bordercolor="#666666"
|
|
18
|
+
borderopacity="1.0"
|
|
19
|
+
inkscape:pageshadow="2"
|
|
20
|
+
inkscape:pageopacity="0.0"
|
|
21
|
+
inkscape:pagecheckerboard="0"
|
|
22
|
+
inkscape:document-units="mm"
|
|
23
|
+
showgrid="false"
|
|
24
|
+
inkscape:zoom="1.1152113"
|
|
25
|
+
inkscape:cx="42.14448"
|
|
26
|
+
inkscape:cy="171.71634"
|
|
27
|
+
inkscape:window-width="1862"
|
|
28
|
+
inkscape:window-height="1016"
|
|
29
|
+
inkscape:window-x="58"
|
|
30
|
+
inkscape:window-y="27"
|
|
31
|
+
inkscape:window-maximized="1"
|
|
32
|
+
inkscape:current-layer="layer1"
|
|
33
|
+
width="80mm"
|
|
34
|
+
units="px" />
|
|
35
|
+
<defs
|
|
36
|
+
id="defs2">
|
|
37
|
+
<marker
|
|
38
|
+
style="overflow:visible"
|
|
39
|
+
id="Arrow1Mend"
|
|
40
|
+
refX="0"
|
|
41
|
+
refY="0"
|
|
42
|
+
orient="auto"
|
|
43
|
+
inkscape:stockid="Arrow1Mend"
|
|
44
|
+
inkscape:isstock="true">
|
|
45
|
+
<path
|
|
46
|
+
transform="matrix(-0.4,0,0,-0.4,-4,0)"
|
|
47
|
+
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
|
|
48
|
+
d="M 0,0 5,-5 -12.5,0 5,5 Z"
|
|
49
|
+
id="path49142" />
|
|
50
|
+
</marker>
|
|
51
|
+
<marker
|
|
52
|
+
style="overflow:visible"
|
|
53
|
+
id="marker59097"
|
|
54
|
+
refX="0"
|
|
55
|
+
refY="0"
|
|
56
|
+
orient="auto"
|
|
57
|
+
inkscape:stockid="Arrow2Lend"
|
|
58
|
+
inkscape:isstock="true">
|
|
59
|
+
<path
|
|
60
|
+
transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
|
|
61
|
+
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
|
|
62
|
+
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:0.625;stroke-linejoin:round"
|
|
63
|
+
id="path59095" />
|
|
64
|
+
</marker>
|
|
65
|
+
<marker
|
|
66
|
+
style="overflow:visible"
|
|
67
|
+
id="DotL"
|
|
68
|
+
refX="0"
|
|
69
|
+
refY="0"
|
|
70
|
+
orient="auto"
|
|
71
|
+
inkscape:stockid="DotL"
|
|
72
|
+
inkscape:isstock="true">
|
|
73
|
+
<path
|
|
74
|
+
transform="matrix(0.8,0,0,0.8,5.92,0.8)"
|
|
75
|
+
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:1pt"
|
|
76
|
+
d="m -2.5,-1 c 0,2.76 -2.24,5 -5,5 -2.76,0 -5,-2.24 -5,-5 0,-2.76 2.24,-5 5,-5 2.76,0 5,2.24 5,5 z"
|
|
77
|
+
id="path49194" />
|
|
78
|
+
</marker>
|
|
79
|
+
<marker
|
|
80
|
+
style="overflow:visible"
|
|
81
|
+
id="Arrow2Lend"
|
|
82
|
+
refX="0"
|
|
83
|
+
refY="0"
|
|
84
|
+
orient="auto"
|
|
85
|
+
inkscape:stockid="Arrow2Lend"
|
|
86
|
+
inkscape:isstock="true">
|
|
87
|
+
<path
|
|
88
|
+
transform="matrix(-1.1,0,0,-1.1,-1.1,0)"
|
|
89
|
+
d="M 8.7185878,4.0337352 -2.2072895,0.01601326 8.7185884,-4.0017078 c -1.7454984,2.3720609 -1.7354408,5.6174519 -6e-7,8.035443 z"
|
|
90
|
+
style="fill:context-stroke;fill-rule:evenodd;stroke:context-stroke;stroke-width:0.625;stroke-linejoin:round"
|
|
91
|
+
id="path49154" />
|
|
92
|
+
</marker>
|
|
93
|
+
<inkscape:path-effect
|
|
94
|
+
effect="bspline"
|
|
95
|
+
id="path-effect29051"
|
|
96
|
+
is_visible="true"
|
|
97
|
+
lpeversion="1"
|
|
98
|
+
weight="21.6333"
|
|
99
|
+
steps="2"
|
|
100
|
+
helper_size="0"
|
|
101
|
+
apply_no_weight="true"
|
|
102
|
+
apply_with_weight="true"
|
|
103
|
+
only_selected="false" />
|
|
104
|
+
<inkscape:path-effect
|
|
105
|
+
effect="bspline"
|
|
106
|
+
id="path-effect29047"
|
|
107
|
+
is_visible="true"
|
|
108
|
+
lpeversion="1"
|
|
109
|
+
weight="33.333333"
|
|
110
|
+
steps="2"
|
|
111
|
+
helper_size="0"
|
|
112
|
+
apply_no_weight="true"
|
|
113
|
+
apply_with_weight="true"
|
|
114
|
+
only_selected="false" />
|
|
115
|
+
<inkscape:path-effect
|
|
116
|
+
effect="fillet_chamfer"
|
|
117
|
+
id="path-effect3633"
|
|
118
|
+
is_visible="true"
|
|
119
|
+
lpeversion="1"
|
|
120
|
+
satellites_param="F,0,0,1,0,2.6458333,0,1 @ F,0,0,1,0,2.6458333,0,1 @ F,0,0,1,0,2.6458333,0,1 @ F,0,0,1,0,2.6458333,0,1"
|
|
121
|
+
unit="px"
|
|
122
|
+
method="auto"
|
|
123
|
+
mode="F"
|
|
124
|
+
radius="10"
|
|
125
|
+
chamfer_steps="1"
|
|
126
|
+
flexible="false"
|
|
127
|
+
use_knot_distance="true"
|
|
128
|
+
apply_no_radius="true"
|
|
129
|
+
apply_with_radius="true"
|
|
130
|
+
only_selected="false"
|
|
131
|
+
hide_knots="false" />
|
|
132
|
+
<inkscape:path-effect
|
|
133
|
+
effect="fillet_chamfer"
|
|
134
|
+
id="path-effect3631"
|
|
135
|
+
is_visible="true"
|
|
136
|
+
lpeversion="1"
|
|
137
|
+
satellites_param="F,0,0,1,0,2.6458333,0,1 @ F,0,0,1,0,2.6458333,0,1 @ F,0,0,1,0,2.6458333,0,1 @ F,0,0,1,0,2.6458333,0,1"
|
|
138
|
+
unit="px"
|
|
139
|
+
method="auto"
|
|
140
|
+
mode="F"
|
|
141
|
+
radius="10"
|
|
142
|
+
chamfer_steps="1"
|
|
143
|
+
flexible="false"
|
|
144
|
+
use_knot_distance="true"
|
|
145
|
+
apply_no_radius="true"
|
|
146
|
+
apply_with_radius="true"
|
|
147
|
+
only_selected="false"
|
|
148
|
+
hide_knots="false" />
|
|
149
|
+
</defs>
|
|
150
|
+
<g
|
|
151
|
+
inkscape:label="Ebene 1"
|
|
152
|
+
inkscape:groupmode="layer"
|
|
153
|
+
id="layer1">
|
|
154
|
+
<path
|
|
155
|
+
style="fill:#ececec;fill-opacity:1;stroke:#b1b1b1;stroke-width:1.065;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1"
|
|
156
|
+
id="rect31"
|
|
157
|
+
width="78.309998"
|
|
158
|
+
height="104.76833"
|
|
159
|
+
x="0.53250003"
|
|
160
|
+
y="0.53250003"
|
|
161
|
+
inkscape:path-effect="#path-effect3631"
|
|
162
|
+
d="M 3.1783333,0.53250003 H 76.196664 A 2.6458333,2.6458333 45 0 1 78.842498,3.1783333 V 102.655 a 2.6458333,2.6458333 135 0 1 -2.645834,2.64583 H 3.1783333 A 2.6458333,2.6458333 45 0 1 0.53250003,102.655 V 3.1783333 A 2.6458333,2.6458333 135 0 1 3.1783333,0.53250003 Z"
|
|
163
|
+
sodipodi:type="rect" />
|
|
164
|
+
<path
|
|
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
|
+
id="rect3114"
|
|
167
|
+
width="57.143333"
|
|
168
|
+
height="30.68499"
|
|
169
|
+
x="11.115832"
|
|
170
|
+
y="12.382141"
|
|
171
|
+
inkscape:path-effect="#path-effect3633"
|
|
172
|
+
d="m 13.761666,12.382141 h 51.851666 a 2.6458333,2.6458333 45 0 1 2.645834,2.645833 v 25.393324 a 2.6458333,2.6458333 135 0 1 -2.645834,2.645833 H 13.761666 A 2.6458333,2.6458333 45 0 1 11.115832,40.421298 V 15.027974 a 2.6458333,2.6458333 135 0 1 2.645834,-2.645833 z"
|
|
173
|
+
sodipodi:type="rect" />
|
|
174
|
+
<text
|
|
175
|
+
xml:space="preserve"
|
|
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="18.147394"
|
|
178
|
+
y="29.418192"
|
|
179
|
+
id="text1838"
|
|
180
|
+
transform="scale(0.78891107,1.26757)"><tspan
|
|
181
|
+
sodipodi:role="line"
|
|
182
|
+
id="tspan1836"
|
|
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="18.147394"
|
|
185
|
+
y="29.418192">0000.0</tspan></text>
|
|
186
|
+
<g
|
|
187
|
+
id="g59969"
|
|
188
|
+
transform="translate(-0.47949313)">
|
|
189
|
+
<text
|
|
190
|
+
xml:space="preserve"
|
|
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"
|
|
192
|
+
x="63.427376"
|
|
193
|
+
y="90.78965"
|
|
194
|
+
id="text10616-9"
|
|
195
|
+
transform="scale(0.98752295,1.0126347)"><tspan
|
|
196
|
+
sodipodi:role="line"
|
|
197
|
+
id="tspan10614-5"
|
|
198
|
+
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:14.5511px;font-family:FreeSans;-inkscape-font-specification:FreeSans;fill:#b1b1b1;fill-opacity:1;stroke-width:0.202098"
|
|
199
|
+
x="63.427376"
|
|
200
|
+
y="90.78965">∑</tspan></text>
|
|
201
|
+
<text
|
|
202
|
+
xml:space="preserve"
|
|
203
|
+
style="font-style:normal;font-weight:normal;font-size:19.05px;line-height:1.25;font-family:sans-serif;letter-spacing:0px;word-spacing:0px;fill:#b1b1b1;fill-opacity:1;stroke:none;stroke-width:0.264583"
|
|
204
|
+
x="8.8679714"
|
|
205
|
+
y="67.230087"
|
|
206
|
+
id="text10616-6"><tspan
|
|
207
|
+
sodipodi:role="line"
|
|
208
|
+
id="tspan10614-4"
|
|
209
|
+
style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:19.05px;font-family:FreeSans;-inkscape-font-specification:FreeSans;fill:#b1b1b1;fill-opacity:1;stroke-width:0.264583"
|
|
210
|
+
x="8.8679714"
|
|
211
|
+
y="67.230087">€</tspan></text>
|
|
212
|
+
<g
|
|
213
|
+
id="g49493"
|
|
214
|
+
transform="matrix(1.4810432,0,0,1.8283748,-58.041646,-106.22555)">
|
|
215
|
+
<path
|
|
216
|
+
style="fill:none;stroke:#b1b1b1;stroke-width:0.978958;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
|
217
|
+
d="m 44.822754,87.273844 c -8e-4,7.609622 -0.0016,15.218706 -0.0024,22.828056 14.489878,0.001 28.980021,0.003 43.469633,0.004"
|
|
218
|
+
id="path29045"
|
|
219
|
+
inkscape:path-effect="#path-effect29047"
|
|
220
|
+
inkscape:original-d="m 44.822754,87.273844 c -6.21e-4,7.609622 -0.0024,22.828056 -0.0024,22.828056 0,0 28.980021,0.003 43.469633,0.004"
|
|
221
|
+
sodipodi:nodetypes="ccc" />
|
|
222
|
+
<path
|
|
223
|
+
style="fill:none;stroke:#b1b1b1;stroke-width:0.978958;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1;marker-end:url(#Arrow1Mend)"
|
|
224
|
+
d="m 44.826015,110.09774 c 1.619456,-2.67561 5.866111,-9.69178 7.356984,-10.07797 1.490873,-0.386193 5.058842,4.60537 6.631217,3.82429 1.572375,-0.78108 6.25224,-9.869532 8.03627,-10.492469 1.784029,-0.622938 6.457134,5.199165 8.617613,4.995938 2.160479,-0.203226 8.820464,-7.091358 11.360315,-9.718215"
|
|
225
|
+
id="path29049"
|
|
226
|
+
sodipodi:nodetypes="cssccc"
|
|
227
|
+
inkscape:original-d="m 44.826015,110.09774 c 1.61965,-2.67549 5.866305,-9.69166 7.486423,-12.368799 1.361484,1.9046 4.929453,6.896159 6.289778,8.799349 1.784577,-3.46521 6.464441,-12.553659 8.249496,-16.020786 1.782841,2.221119 6.455946,8.043221 8.237615,10.263036 2.539416,-2.626078 9.199401,-9.51421 11.739087,-12.141226"
|
|
228
|
+
inkscape:path-effect="#path-effect29051" />
|
|
229
|
+
</g>
|
|
230
|
+
</g>
|
|
231
|
+
</g>
|
|
232
|
+
</svg>
|
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
|
|
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"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build/main.js
CHANGED
|
@@ -33,17 +33,18 @@ class MeterStatistics extends utils.Adapter {
|
|
|
33
33
|
await this.assertObjectsExist();
|
|
34
34
|
const dayInfo = this.getDayInfo();
|
|
35
35
|
const meterStates = await this.getMeterStates();
|
|
36
|
-
const { total, average } = this.calculateMeterConsumption(meterStates, dayInfo);
|
|
37
|
-
this.writeState("
|
|
38
|
-
this.writeState("
|
|
39
|
-
|
|
40
|
-
this.
|
|
36
|
+
const { total, average, predicted } = this.calculateMeterConsumption(meterStates, dayInfo);
|
|
37
|
+
this.writeState("summary.consumptionTotal", this.roundConsumption(total));
|
|
38
|
+
this.writeState("summary.consumptionAverage", this.roundConsumption(average));
|
|
39
|
+
this.writeState("summary.consumptionPredictedTotal", this.roundConsumption(predicted));
|
|
40
|
+
const costs = this.calculateCosts(meterStates, dayInfo);
|
|
41
|
+
this.writeState("summary.costs", this.roundCosts(costs));
|
|
41
42
|
const paid = this.calculatePaid(dayInfo);
|
|
42
|
-
this.writeState("
|
|
43
|
+
this.writeState("summary.paid", this.roundCosts(paid));
|
|
43
44
|
const current = paid - costs;
|
|
44
|
-
this.writeState("
|
|
45
|
+
this.writeState("summary.balance", this.roundCosts(current));
|
|
45
46
|
const recommendedPayment = this.calculateRecommendation(costs, dayInfo);
|
|
46
|
-
this.writeState("
|
|
47
|
+
this.writeState("summary.recommendedPayment", this.roundCosts(recommendedPayment));
|
|
47
48
|
this.end();
|
|
48
49
|
}
|
|
49
50
|
addPendingPromise(promise) {
|
|
@@ -52,28 +53,37 @@ class MeterStatistics extends utils.Adapter {
|
|
|
52
53
|
calculateMeterConsumption(meterStates, dayInfo) {
|
|
53
54
|
let totalConsumption = 0;
|
|
54
55
|
for (const meterState of meterStates) {
|
|
56
|
+
const meter = meterState.meter;
|
|
57
|
+
this.writeState(`meter.${meter.alias}.consumptionTotal`, this.roundConsumption(meterState.consumption));
|
|
58
|
+
this.writeState(`meter.${meter.alias}.consumptionAverage`, this.roundConsumption(meterState.consumption / dayInfo.daysSinceStartOfYear));
|
|
59
|
+
this.writeState(`meter.${meter.alias}.consumptionPredictedTotal`, this.roundConsumption(meterState.consumption / dayInfo.daysSinceStartOfYear * dayInfo.daysInYear));
|
|
55
60
|
totalConsumption += meterState.consumption;
|
|
56
61
|
}
|
|
57
62
|
return {
|
|
58
63
|
total: totalConsumption,
|
|
59
|
-
average: totalConsumption / dayInfo.daysSinceStartOfYear
|
|
64
|
+
average: totalConsumption / dayInfo.daysSinceStartOfYear,
|
|
65
|
+
predicted: totalConsumption / dayInfo.daysSinceStartOfYear * dayInfo.daysInYear
|
|
60
66
|
};
|
|
61
67
|
}
|
|
62
|
-
calculateCosts(meterStates) {
|
|
68
|
+
calculateCosts(meterStates, dayInfo) {
|
|
63
69
|
let usedCosts = 0;
|
|
70
|
+
const basePricePerDay = this.config.paymentBasePrice / dayInfo.daysInYear;
|
|
71
|
+
usedCosts += basePricePerDay * dayInfo.daysSinceStartOfYear;
|
|
64
72
|
for (const meterState of meterStates) {
|
|
65
|
-
|
|
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;
|
|
66
76
|
}
|
|
67
77
|
return usedCosts;
|
|
68
78
|
}
|
|
69
79
|
calculatePaid(dayInfo) {
|
|
70
80
|
let paid = this.config.paymentCorrectionOffset;
|
|
71
|
-
|
|
81
|
+
const paymentPerDay = this.config.paymentValue * this.config.paymentCount / dayInfo.daysInYear;
|
|
82
|
+
paid += paymentPerDay * dayInfo.daysSinceStartOfYear;
|
|
72
83
|
return paid;
|
|
73
84
|
}
|
|
74
85
|
calculateRecommendation(costs, dayInfo) {
|
|
75
|
-
|
|
76
|
-
return suggestedPayment;
|
|
86
|
+
return this.roundCosts(costs / dayInfo.daysSinceStartOfYear * dayInfo.daysInYear / this.config.paymentCount);
|
|
77
87
|
}
|
|
78
88
|
roundCosts(costs) {
|
|
79
89
|
return Math.round(costs * 100) / 100;
|
|
@@ -100,17 +110,22 @@ class MeterStatistics extends utils.Adapter {
|
|
|
100
110
|
}
|
|
101
111
|
return meterStates;
|
|
102
112
|
}
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
throw new Error(`Could not read meter "${meter.alias}" with id: ${meter.objectId}`);
|
|
108
|
-
}
|
|
109
|
-
const startValueState = await this.getStateAsync(`meter.${meter.alias}.startValue`);
|
|
110
|
-
const startValue = startValueState == null ? void 0 : startValueState.val;
|
|
111
|
-
if (!currentValueState || typeof startValue !== "number") {
|
|
112
|
-
throw new Error(`Could not read start value for meter "${meter.alias}".`);
|
|
113
|
+
getNumericStateValue(state, onErrorMessage) {
|
|
114
|
+
const stateValue = state == null ? void 0 : state.val;
|
|
115
|
+
if (typeof stateValue === "number") {
|
|
116
|
+
return stateValue;
|
|
113
117
|
}
|
|
118
|
+
throw new Error(onErrorMessage);
|
|
119
|
+
}
|
|
120
|
+
async getMeterState(meter) {
|
|
121
|
+
const currentValue = this.getNumericStateValue(
|
|
122
|
+
await this.getForeignStateAsync(meter.objectId),
|
|
123
|
+
`Could not read meter "${meter.alias}" with id: ${meter.objectId}`
|
|
124
|
+
);
|
|
125
|
+
const startValue = this.getNumericStateValue(
|
|
126
|
+
await this.getStateAsync(`meter.${meter.alias}.startValue`),
|
|
127
|
+
`Could not read start value for meter "${meter.alias}".`
|
|
128
|
+
);
|
|
114
129
|
return {
|
|
115
130
|
meter,
|
|
116
131
|
currentValue,
|
|
@@ -138,8 +153,56 @@ class MeterStatistics extends utils.Adapter {
|
|
|
138
153
|
},
|
|
139
154
|
native: {}
|
|
140
155
|
});
|
|
156
|
+
await this.setObjectNotExistsAsync(`meter.${meter.alias}.consumptionAverage`, {
|
|
157
|
+
type: "state",
|
|
158
|
+
common: {
|
|
159
|
+
name: "Average consumption in period",
|
|
160
|
+
type: "number",
|
|
161
|
+
role: "state",
|
|
162
|
+
read: true,
|
|
163
|
+
write: false,
|
|
164
|
+
unit: this.config.meterUnit
|
|
165
|
+
},
|
|
166
|
+
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}.consumptionPredicted`, {
|
|
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
|
+
});
|
|
141
204
|
}
|
|
142
|
-
await this.setObjectNotExistsAsync(`
|
|
205
|
+
await this.setObjectNotExistsAsync(`summary.consumptionTotal`, {
|
|
143
206
|
type: "state",
|
|
144
207
|
common: {
|
|
145
208
|
name: "Total consumption in period",
|
|
@@ -151,7 +214,19 @@ class MeterStatistics extends utils.Adapter {
|
|
|
151
214
|
},
|
|
152
215
|
native: {}
|
|
153
216
|
});
|
|
154
|
-
await this.setObjectNotExistsAsync(`
|
|
217
|
+
await this.setObjectNotExistsAsync(`summary.consumptionPredictedTotal`, {
|
|
218
|
+
type: "state",
|
|
219
|
+
common: {
|
|
220
|
+
name: "Total predicted consumption in period",
|
|
221
|
+
type: "number",
|
|
222
|
+
role: "state",
|
|
223
|
+
read: true,
|
|
224
|
+
write: false,
|
|
225
|
+
unit: this.config.meterUnit
|
|
226
|
+
},
|
|
227
|
+
native: {}
|
|
228
|
+
});
|
|
229
|
+
await this.setObjectNotExistsAsync(`summary.consumptionAverage`, {
|
|
155
230
|
type: "state",
|
|
156
231
|
common: {
|
|
157
232
|
name: "Average consumption in period",
|
|
@@ -163,7 +238,7 @@ class MeterStatistics extends utils.Adapter {
|
|
|
163
238
|
},
|
|
164
239
|
native: {}
|
|
165
240
|
});
|
|
166
|
-
await this.setObjectNotExistsAsync(`
|
|
241
|
+
await this.setObjectNotExistsAsync(`summary.paid`, {
|
|
167
242
|
type: "state",
|
|
168
243
|
common: {
|
|
169
244
|
name: "Total paid value",
|
|
@@ -175,7 +250,7 @@ class MeterStatistics extends utils.Adapter {
|
|
|
175
250
|
},
|
|
176
251
|
native: {}
|
|
177
252
|
});
|
|
178
|
-
await this.setObjectNotExistsAsync(`
|
|
253
|
+
await this.setObjectNotExistsAsync(`summary.costs`, {
|
|
179
254
|
type: "state",
|
|
180
255
|
common: {
|
|
181
256
|
name: "Total costs",
|
|
@@ -187,10 +262,10 @@ class MeterStatistics extends utils.Adapter {
|
|
|
187
262
|
},
|
|
188
263
|
native: {}
|
|
189
264
|
});
|
|
190
|
-
await this.setObjectNotExistsAsync(`
|
|
265
|
+
await this.setObjectNotExistsAsync(`summary.balance`, {
|
|
191
266
|
type: "state",
|
|
192
267
|
common: {
|
|
193
|
-
name: "Current
|
|
268
|
+
name: "Current balance",
|
|
194
269
|
type: "number",
|
|
195
270
|
role: "state",
|
|
196
271
|
read: true,
|
|
@@ -199,7 +274,7 @@ class MeterStatistics extends utils.Adapter {
|
|
|
199
274
|
},
|
|
200
275
|
native: {}
|
|
201
276
|
});
|
|
202
|
-
await this.setObjectNotExistsAsync(`
|
|
277
|
+
await this.setObjectNotExistsAsync(`summary.recommendedPayment`, {
|
|
203
278
|
type: "state",
|
|
204
279
|
common: {
|
|
205
280
|
name: "Recommended payment per payment interval",
|
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.2.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 {MeterState, MeterDefinition, MeterConsumption, DayInfo} 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} = this.calculateMeterConsumption(meterStates, dayInfo);\n this.writeState('calculated.consumption.total', this.roundConsumption(total));\n this.writeState('calculated.consumption.average', this.roundConsumption(average));\n\n const costs = this.calculateCosts(meterStates);\n this.writeState('calculated.costs.used', this.roundCosts(costs));\n\n const paid = this.calculatePaid(dayInfo);\n this.writeState('calculated.costs.paid', this.roundCosts(paid));\n\n const current = paid - costs;\n this.writeState('calculated.costs.current', this.roundCosts(current));\n\n const recommendedPayment = this.calculateRecommendation(costs, dayInfo);\n this.writeState('calculated.costs.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 totalConsumption += meterState.consumption;\n }\n\n return {\n total: totalConsumption,\n average: totalConsumption / dayInfo.daysSinceStartOfYear,\n };\n }\n\n private calculateCosts(meterStates: MeterState[]): number {\n\n let usedCosts = 0;\n\n for (const meterState of meterStates) {\n usedCosts += meterState.consumption * meterState.meter.price;\n }\n\n return usedCosts;\n }\n\n private calculatePaid(dayInfo: DayInfo): number {\n\n let paid = this.config.paymentCorrectionOffset;\n\n paid += (this.config.paymentValue * this.config.paymentCount / dayInfo.daysInYear) * dayInfo.daysSinceStartOfYear;\n\n return paid;\n }\n\n private calculateRecommendation(costs: number, dayInfo: DayInfo): number {\n const suggestedPayment = this.roundCosts(costs / dayInfo.daysSinceStartOfYear * dayInfo.daysInYear / this.config.paymentCount);\n\n return suggestedPayment;\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 async getMeterState(meter: MeterDefinition): Promise<MeterState> {\n\n const currentValueState = await this.getForeignStateAsync(meter.objectId);\n const currentValue = currentValueState?.val;\n if (!currentValueState || typeof currentValue !== 'number') {\n throw new Error(`Could not read meter \"${meter.alias}\" with id: ${meter.objectId}`);\n }\n\n const startValueState = await this.getStateAsync(`meter.${meter.alias}.startValue`);\n const startValue = startValueState?.val;\n if (!currentValueState || typeof startValue !== 'number') {\n throw new Error(`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\n }\n\n await this.setObjectNotExistsAsync(`calculated.consumption.total`, {\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(`calculated.consumption.average`, {\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(`calculated.costs.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(`calculated.costs.used`, {\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(`calculated.costs.current`, {\n type: 'state',\n common: {\n name: 'Current payment 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(`calculated.costs.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}"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;AAMA,YAAuB;AAMvB,MAAM,wBAAwB,MAAM,QAAQ;AAAA,EAMjC,YAAY,UAAyC,CAAC,GAAG;AAC5D,UAAM;AAAA,MACF,GAAG;AAAA,MACH,MAAM;AAAA,IACV,CAAC;AARL,SAAQ,WAAW;AAEnB,SAAQ,kBAAuC,CAAC;AAO5C,SAAK,GAAG,SAAS,KAAK,QAAQ,KAAK,IAAI,CAAC;AACxC,SAAK,GAAG,UAAU,KAAK,SAAS,KAAK,IAAI,CAAC;AAAA,EAC9C;AAAA,EAKA,MAAc,UAAyB;AAEnC,UAAM,KAAK,mBAAmB;AAE9B,UAAM,UAAU,KAAK,WAAW;AAChC,UAAM,cAAc,MAAM,KAAK,eAAe;AAE9C,UAAM,EAAC,OAAO,
|
|
4
|
+
"sourcesContent": ["/*\n * Created with @iobroker/create-adapter v2.2.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}.consumptionPredicted`, {\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;AAMvB,MAAM,wBAAwB,MAAM,QAAQ;AAAA,EAMjC,YAAY,UAAyC,CAAC,GAAG;AAC5D,UAAM;AAAA,MACF,GAAG;AAAA,MACH,MAAM;AAAA,IACV,CAAC;AARL,SAAQ,WAAW;AAEnB,SAAQ,kBAAuC,CAAC;AAO5C,SAAK,GAAG,SAAS,KAAK,QAAQ,KAAK,IAAI,CAAC;AACxC,SAAK,GAAG,UAAU,KAAK,SAAS,KAAK,IAAI,CAAC;AAAA,EAC9C;AAAA,EAKA,MAAc,UAAyB;AAEnC,UAAM,KAAK,mBAAmB;AAE9B,UAAM,UAAU,KAAK,WAAW;AAChC,UAAM,cAAc,MAAM,KAAK,eAAe;AAE9C,UAAM,EAAC,OAAO,SAAS,UAAS,IAAI,KAAK,0BAA0B,aAAa,OAAO;AACvF,SAAK,WAAW,4BAA4B,KAAK,iBAAiB,KAAK,CAAC;AACxE,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CAAC;AAAA,EACL;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
6
|
"names": []
|
|
7
7
|
}
|
package/io-package.json
CHANGED
|
@@ -1,93 +1,120 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
-
"authors": [
|
|
47
|
-
"jb-io <96919536+jb-io@users.noreply.github.com>"
|
|
48
|
-
],
|
|
49
|
-
"keywords": [
|
|
50
|
-
"smart",
|
|
51
|
-
"meter",
|
|
52
|
-
"statistics",
|
|
53
|
-
"calculate"
|
|
54
|
-
],
|
|
55
|
-
"license": "GPL-3.0-or-later",
|
|
56
|
-
"platform": "Javascript/Node.js",
|
|
57
|
-
"main": "build/main.js",
|
|
58
|
-
"icon": "meter-statistics.png",
|
|
59
|
-
"enabled": true,
|
|
60
|
-
"extIcon": "https://raw.githubusercontent.com/jb-io/ioBroker.meter-statistics/master/admin/meter-statistics.png",
|
|
61
|
-
"readme": "https://github.com/jb-io/ioBroker.meter-statistics/blob/master/README.md",
|
|
62
|
-
"loglevel": "info",
|
|
63
|
-
"mode": "schedule",
|
|
64
|
-
"schedule": "0 0 * * *",
|
|
65
|
-
"type": "logic",
|
|
66
|
-
"compact": true,
|
|
67
|
-
"connectionType": "local",
|
|
68
|
-
"dataSource": "assumption",
|
|
69
|
-
"adminUI": {
|
|
70
|
-
"config": "json"
|
|
71
|
-
},
|
|
72
|
-
"dependencies": [
|
|
73
|
-
{
|
|
74
|
-
"js-controller": ">=3.3.22"
|
|
75
|
-
}
|
|
76
|
-
],
|
|
77
|
-
"globalDependencies": [
|
|
78
|
-
{
|
|
79
|
-
"admin": ">=5.1.13"
|
|
80
|
-
}
|
|
81
|
-
]
|
|
2
|
+
"common": {
|
|
3
|
+
"name": "meter-statistics",
|
|
4
|
+
"version": "0.0.3",
|
|
5
|
+
"news": {
|
|
6
|
+
"0.0.3": {
|
|
7
|
+
"en": "Add predicted consumption",
|
|
8
|
+
"de": "Voraussichtlicher Verbrauch hinzufügen",
|
|
9
|
+
"ru": "Добавить прогнозируемое потребление",
|
|
10
|
+
"pt": "Adicionar consumo previsto",
|
|
11
|
+
"nl": "Advertentie voorspelde consumptie",
|
|
12
|
+
"fr": "Ajouter la consommation prévue",
|
|
13
|
+
"it": "Aggiungere il consumo previsto",
|
|
14
|
+
"es": "Add predicted consumption",
|
|
15
|
+
"pl": "Przewidywania konsumpcji",
|
|
16
|
+
"uk": "Додати передбачуване споживання",
|
|
17
|
+
"zh-cn": "增加预计消费"
|
|
18
|
+
},
|
|
19
|
+
"0.0.2": {
|
|
20
|
+
"en": "Change Logo",
|
|
21
|
+
"de": "Logo ändern",
|
|
22
|
+
"ru": "Изменить логотип",
|
|
23
|
+
"pt": "Alterar o logotipo",
|
|
24
|
+
"nl": "Verander Logo",
|
|
25
|
+
"fr": "Change Logo",
|
|
26
|
+
"it": "Cambia il logo",
|
|
27
|
+
"es": "Cambio de logo",
|
|
28
|
+
"pl": "Logo",
|
|
29
|
+
"uk": "Зміна логотипу",
|
|
30
|
+
"zh-cn": "变化"
|
|
31
|
+
},
|
|
32
|
+
"0.0.1": {
|
|
33
|
+
"en": "initial release",
|
|
34
|
+
"de": "Erstveröffentlichung",
|
|
35
|
+
"ru": "Начальная версия",
|
|
36
|
+
"pt": "lançamento inicial",
|
|
37
|
+
"nl": "Eerste uitgave",
|
|
38
|
+
"fr": "Première version",
|
|
39
|
+
"it": "Versione iniziale",
|
|
40
|
+
"es": "Versión inicial",
|
|
41
|
+
"pl": "Pierwsze wydanie",
|
|
42
|
+
"zh-cn": "首次出版",
|
|
43
|
+
"uk": "початковий випуск"
|
|
44
|
+
}
|
|
82
45
|
},
|
|
83
|
-
"
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
46
|
+
"titleLang": {
|
|
47
|
+
"en": "Meter Statistics",
|
|
48
|
+
"de": "Meter-Statistiken",
|
|
49
|
+
"ru": "Статистика счетчика",
|
|
50
|
+
"pt": "Estatísticas do Medidor",
|
|
51
|
+
"nl": "Meterstatistieken",
|
|
52
|
+
"fr": "Statistiques du compteur",
|
|
53
|
+
"it": "Statistiche del contatore",
|
|
54
|
+
"es": "Estadísticas del medidor",
|
|
55
|
+
"pl": "Statystyki miernika",
|
|
56
|
+
"zh-cn": "仪表统计",
|
|
57
|
+
"uk": "Статистика вимірювача"
|
|
90
58
|
},
|
|
91
|
-
"
|
|
92
|
-
|
|
59
|
+
"desc": {
|
|
60
|
+
"en": "Calculate statistics from any smart meter",
|
|
61
|
+
"de": "Berechnen Sie Statistiken von jedem Smart Meter",
|
|
62
|
+
"ru": "Рассчитать статистику с любого умного счетчика",
|
|
63
|
+
"pt": "Calcule estatísticas de qualquer medidor inteligente",
|
|
64
|
+
"nl": "Bereken statistieken van elke slimme meter",
|
|
65
|
+
"fr": "Calculez les statistiques de n'importe quel compteur intelligent",
|
|
66
|
+
"it": "Calcola le statistiche da qualsiasi contatore intelligente",
|
|
67
|
+
"es": "Calcula estadísticas desde cualquier contador inteligente",
|
|
68
|
+
"pl": "Oblicz statystyki z dowolnego inteligentnego licznika",
|
|
69
|
+
"zh-cn": "从任何智能电表计算统计数据",
|
|
70
|
+
"uk": "Обчислюйте статистику з будь-якого розумного лічильника"
|
|
71
|
+
},
|
|
72
|
+
"authors": [
|
|
73
|
+
"jb-io <96919536+jb-io@users.noreply.github.com>"
|
|
74
|
+
],
|
|
75
|
+
"keywords": [
|
|
76
|
+
"smart",
|
|
77
|
+
"meter",
|
|
78
|
+
"statistics",
|
|
79
|
+
"calculate"
|
|
80
|
+
],
|
|
81
|
+
"license": "GPL-3.0-or-later",
|
|
82
|
+
"platform": "Javascript/Node.js",
|
|
83
|
+
"main": "build/main.js",
|
|
84
|
+
"icon": "meter-statistics.png",
|
|
85
|
+
"enabled": true,
|
|
86
|
+
"extIcon": "https://raw.githubusercontent.com/jb-io/ioBroker.meter-statistics/master/admin/meter-statistics.png",
|
|
87
|
+
"readme": "https://github.com/jb-io/ioBroker.meter-statistics/blob/master/README.md",
|
|
88
|
+
"loglevel": "info",
|
|
89
|
+
"mode": "schedule",
|
|
90
|
+
"schedule": "0 0 * * *",
|
|
91
|
+
"type": "logic",
|
|
92
|
+
"compact": true,
|
|
93
|
+
"connectionType": "local",
|
|
94
|
+
"dataSource": "assumption",
|
|
95
|
+
"adminUI": {
|
|
96
|
+
"config": "json"
|
|
97
|
+
},
|
|
98
|
+
"dependencies": [
|
|
99
|
+
{
|
|
100
|
+
"js-controller": ">=3.3.22"
|
|
101
|
+
}
|
|
102
|
+
],
|
|
103
|
+
"globalDependencies": [
|
|
104
|
+
{
|
|
105
|
+
"admin": ">=5.1.13"
|
|
106
|
+
}
|
|
107
|
+
]
|
|
108
|
+
},
|
|
109
|
+
"native": {
|
|
110
|
+
"meterUnit": "kWh",
|
|
111
|
+
"paymentUnit": "€",
|
|
112
|
+
"paymentValue": 0,
|
|
113
|
+
"paymentCount": 0,
|
|
114
|
+
"paymentCorrectionOffset": 0,
|
|
115
|
+
"paymentBasePrice": 0,
|
|
116
|
+
"meters": []
|
|
117
|
+
},
|
|
118
|
+
"objects": [],
|
|
119
|
+
"instanceObjects": []
|
|
93
120
|
}
|
package/package.json
CHANGED
|
@@ -1,28 +0,0 @@
|
|
|
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 accounting_helper_exports = {};
|
|
20
|
-
__export(accounting_helper_exports, {
|
|
21
|
-
default: () => AccountingHelper
|
|
22
|
-
});
|
|
23
|
-
module.exports = __toCommonJS(accounting_helper_exports);
|
|
24
|
-
class AccountingHelper {
|
|
25
|
-
}
|
|
26
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
27
|
-
0 && (module.exports = {});
|
|
28
|
-
//# sourceMappingURL=accounting-helper.js.map
|