iobroker.tibberlink 3.5.2 → 3.5.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/README.md +9 -0
- package/admin/jsonConfig.json +5 -0
- package/build/lib/{tibberHelper.js → projectUtils.js} +70 -42
- package/build/lib/projectUtils.js.map +1 -0
- package/build/lib/tibberAPICaller.js +82 -81
- package/build/lib/tibberAPICaller.js.map +1 -1
- package/build/lib/tibberCalculator.js +104 -97
- package/build/lib/tibberCalculator.js.map +1 -1
- package/build/lib/tibberLocal.js +16 -16
- package/build/lib/tibberLocal.js.map +1 -1
- package/build/lib/tibberPulse.js +28 -28
- package/build/lib/tibberPulse.js.map +1 -1
- package/build/main.js +15 -13
- package/build/main.js.map +1 -1
- package/io-package.json +14 -14
- package/package.json +11 -11
- package/build/lib/tibberHelper.js.map +0 -1
package/README.md
CHANGED
|
@@ -106,6 +106,15 @@ If you enjoyed this project — or just feeling generous, consider buying me a b
|
|
|
106
106
|
|
|
107
107
|
## Changelog
|
|
108
108
|
|
|
109
|
+
### 3.5.3 (2024-11-23)
|
|
110
|
+
|
|
111
|
+
- (HombachC) fix edge case in output state setup and usage
|
|
112
|
+
- (HombachC) optimzed state subscription
|
|
113
|
+
- (HombachC) update deprecated state calls
|
|
114
|
+
- (HombachC) add await to delObjectAsync
|
|
115
|
+
- (HombachC) harmonize project tools
|
|
116
|
+
- (HombachC) dependency updates
|
|
117
|
+
|
|
109
118
|
### 3.5.2 (2024-10-30)
|
|
110
119
|
|
|
111
120
|
- (HombachC) add verification for YES/NO 2 values in calculator (#547)
|
package/admin/jsonConfig.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ProjectUtils = exports.enCalcType = void 0;
|
|
4
4
|
exports.getCalcTypeDescription = getCalcTypeDescription;
|
|
5
5
|
var enCalcType;
|
|
6
6
|
(function (enCalcType) {
|
|
@@ -35,27 +35,11 @@ function getCalcTypeDescription(calcType) {
|
|
|
35
35
|
return "Unknown";
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
class
|
|
38
|
+
class ProjectUtils {
|
|
39
39
|
adapter;
|
|
40
40
|
constructor(adapter) {
|
|
41
41
|
this.adapter = adapter;
|
|
42
42
|
}
|
|
43
|
-
getStatePrefix(homeId, space, id, name) {
|
|
44
|
-
//protected getStatePrefix(homeId: string, space: string, id: string, name?: string): { [key: string]: string } {
|
|
45
|
-
const statePrefix = {
|
|
46
|
-
key: name ? name : id,
|
|
47
|
-
value: `Homes.${homeId}.${space}.${id}`,
|
|
48
|
-
};
|
|
49
|
-
return statePrefix;
|
|
50
|
-
}
|
|
51
|
-
getStatePrefixLocal(pulse, id, name) {
|
|
52
|
-
//protected getStatePrefixLocal(pulse: number, id: string, name?: string): { [key: string]: string } {
|
|
53
|
-
const statePrefix = {
|
|
54
|
-
key: name ? name : id,
|
|
55
|
-
value: `LocalPulse.${pulse}.${id}`,
|
|
56
|
-
};
|
|
57
|
-
return statePrefix;
|
|
58
|
-
}
|
|
59
43
|
/**
|
|
60
44
|
* Retrieves the value of a given state by its name.
|
|
61
45
|
*
|
|
@@ -111,6 +95,52 @@ class TibberHelper {
|
|
|
111
95
|
}
|
|
112
96
|
return true;
|
|
113
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Get foreign state value
|
|
100
|
+
* @param {string} stateName - Full path to state, like 0_userdata.0.other.isSummer
|
|
101
|
+
* @return {Promise<*>} - State value, or null if error
|
|
102
|
+
*/
|
|
103
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
104
|
+
async asyncGetForeignStateVal(stateName) {
|
|
105
|
+
try {
|
|
106
|
+
const stateObject = await this.asyncGetForeignState(stateName);
|
|
107
|
+
if (stateObject == null)
|
|
108
|
+
return null; // errors thrown already in asyncGetForeignState()
|
|
109
|
+
return stateObject.val;
|
|
110
|
+
}
|
|
111
|
+
catch (error) {
|
|
112
|
+
this.adapter.log.error(`[asyncGetForeignStateValue](${stateName}): ${error}`);
|
|
113
|
+
return null;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Get foreign state
|
|
118
|
+
*
|
|
119
|
+
* @param {string} stateName - Full path to state, like 0_userdata.0.other.isSummer
|
|
120
|
+
* @return {Promise<object>} - State object: {val: false, ack: true, ts: 1591117034451, …}, or null if error
|
|
121
|
+
*/
|
|
122
|
+
async asyncGetForeignState(stateName) {
|
|
123
|
+
try {
|
|
124
|
+
const stateObject = await this.adapter.getForeignObjectAsync(stateName); // Check state existence
|
|
125
|
+
if (!stateObject) {
|
|
126
|
+
throw `State '${stateName}' does not exist.`;
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
// Get state value, so like: {val: false, ack: true, ts: 1591117034451, …}
|
|
130
|
+
const stateValueObject = await this.adapter.getForeignStateAsync(stateName);
|
|
131
|
+
if (!this.isLikeEmpty(stateValueObject)) {
|
|
132
|
+
return stateValueObject;
|
|
133
|
+
}
|
|
134
|
+
else {
|
|
135
|
+
throw `Unable to retrieve info from state '${stateName}'.`;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
catch (error) {
|
|
140
|
+
this.adapter.log.error(`[asyncGetForeignState](${stateName}): ${error}`);
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
114
144
|
/**
|
|
115
145
|
* Checks if the given input variable is effectively empty.
|
|
116
146
|
*
|
|
@@ -144,7 +174,7 @@ class TibberHelper {
|
|
|
144
174
|
/**
|
|
145
175
|
* Checks if a string state exists, creates it if necessary, and updates its value.
|
|
146
176
|
*
|
|
147
|
-
* @param stateName -
|
|
177
|
+
* @param stateName - A string representing the name of the state.
|
|
148
178
|
* @param value - The string value to set for the state.
|
|
149
179
|
* @param description - Optional description for the state (default is "-").
|
|
150
180
|
* @param writeable - Optional boolean indicating if the state should be writeable (default is false).
|
|
@@ -156,7 +186,7 @@ class TibberHelper {
|
|
|
156
186
|
if (value != undefined) {
|
|
157
187
|
if (value.trim().length > 0) {
|
|
158
188
|
const commonObj = {
|
|
159
|
-
name: stateName.
|
|
189
|
+
name: stateName.split(".").pop(),
|
|
160
190
|
type: "string",
|
|
161
191
|
role: "text",
|
|
162
192
|
desc: description,
|
|
@@ -164,21 +194,21 @@ class TibberHelper {
|
|
|
164
194
|
write: writeable,
|
|
165
195
|
};
|
|
166
196
|
if (!forceMode) {
|
|
167
|
-
await this.adapter.setObjectNotExistsAsync(stateName
|
|
197
|
+
await this.adapter.setObjectNotExistsAsync(stateName, {
|
|
168
198
|
type: "state",
|
|
169
199
|
common: commonObj,
|
|
170
200
|
native: {},
|
|
171
201
|
});
|
|
172
202
|
}
|
|
173
203
|
else {
|
|
174
|
-
await this.adapter.setObjectAsync(stateName
|
|
204
|
+
await this.adapter.setObjectAsync(stateName, {
|
|
175
205
|
type: "state",
|
|
176
206
|
common: commonObj,
|
|
177
207
|
native: {},
|
|
178
208
|
});
|
|
179
209
|
}
|
|
180
|
-
if (!dontUpdate || (await this.adapter.getStateAsync(stateName
|
|
181
|
-
await this.adapter.setState(stateName
|
|
210
|
+
if (!dontUpdate || (await this.adapter.getStateAsync(stateName)) === null) {
|
|
211
|
+
await this.adapter.setState(stateName, { val: value, ack: true });
|
|
182
212
|
}
|
|
183
213
|
}
|
|
184
214
|
}
|
|
@@ -186,7 +216,7 @@ class TibberHelper {
|
|
|
186
216
|
/**
|
|
187
217
|
* Checks if a number state exists, creates it if necessary, and updates its value.
|
|
188
218
|
*
|
|
189
|
-
* @param stateName -
|
|
219
|
+
* @param stateName - A string representing the name of the state.
|
|
190
220
|
* @param value - The number value to set for the state.
|
|
191
221
|
* @param description - Optional description for the state (default is "-").
|
|
192
222
|
* @param unit - Optional unit string to set for the state (default is undefined).
|
|
@@ -197,9 +227,8 @@ class TibberHelper {
|
|
|
197
227
|
*/
|
|
198
228
|
async checkAndSetValueNumber(stateName, value, description = "-", unit, writeable = false, dontUpdate = false, forceMode = false) {
|
|
199
229
|
if (value !== undefined) {
|
|
200
|
-
//if (value || value === 0) {
|
|
201
230
|
const commonObj = {
|
|
202
|
-
name: stateName.
|
|
231
|
+
name: stateName.split(".").pop(),
|
|
203
232
|
type: "number",
|
|
204
233
|
role: "value",
|
|
205
234
|
desc: description,
|
|
@@ -211,61 +240,60 @@ class TibberHelper {
|
|
|
211
240
|
commonObj.unit = unit;
|
|
212
241
|
}
|
|
213
242
|
if (!forceMode) {
|
|
214
|
-
await this.adapter.setObjectNotExistsAsync(stateName
|
|
243
|
+
await this.adapter.setObjectNotExistsAsync(stateName, {
|
|
215
244
|
type: "state",
|
|
216
245
|
common: commonObj,
|
|
217
246
|
native: {},
|
|
218
247
|
});
|
|
219
248
|
}
|
|
220
249
|
else {
|
|
221
|
-
await this.adapter.setObjectAsync(stateName
|
|
250
|
+
await this.adapter.setObjectAsync(stateName, {
|
|
222
251
|
type: "state",
|
|
223
252
|
common: commonObj,
|
|
224
253
|
native: {},
|
|
225
254
|
});
|
|
226
255
|
}
|
|
227
|
-
if (!dontUpdate || (await this.adapter.getStateAsync(stateName
|
|
228
|
-
await this.adapter.setState(stateName
|
|
256
|
+
if (!dontUpdate || (await this.adapter.getStateAsync(stateName)) === null) {
|
|
257
|
+
await this.adapter.setState(stateName, { val: value, ack: true });
|
|
229
258
|
}
|
|
230
259
|
}
|
|
231
260
|
}
|
|
232
261
|
/**
|
|
233
262
|
* Checks if a boolean state exists, creates it if necessary, and updates its value.
|
|
234
263
|
*
|
|
235
|
-
* @param stateName -
|
|
264
|
+
* @param stateName - A string representing the name of the state.
|
|
236
265
|
* @param value - The boolean value to set for the state.
|
|
237
266
|
* @param description - Optional description for the state (default is "-").
|
|
238
267
|
* @param writeable - Optional boolean indicating if the state should be writeable (default is false).
|
|
239
268
|
* @param dontUpdate - Optional boolean indicating if the state should not be updated if it already exists (default is false).
|
|
240
269
|
* @returns A Promise that resolves when the state is checked, created (if necessary), and updated.
|
|
241
270
|
*/
|
|
242
|
-
async checkAndSetValueBoolean(stateName, value, description = "-", writeable = false, dontUpdate = false) {
|
|
271
|
+
async checkAndSetValueBoolean(stateName, value, description = "-", writeable = false, dontUpdate = false, forceMode = false) {
|
|
243
272
|
if (value !== undefined && value !== null) {
|
|
244
273
|
const commonObj = {
|
|
245
|
-
name: stateName.
|
|
274
|
+
name: stateName.split(".").pop(),
|
|
246
275
|
type: "boolean",
|
|
247
276
|
role: "indicator",
|
|
248
277
|
desc: description,
|
|
249
278
|
read: true,
|
|
250
279
|
write: writeable,
|
|
251
280
|
};
|
|
252
|
-
if (
|
|
253
|
-
await this.adapter.setObjectNotExistsAsync(stateName
|
|
281
|
+
if (!forceMode) {
|
|
282
|
+
await this.adapter.setObjectNotExistsAsync(stateName, {
|
|
254
283
|
type: "state",
|
|
255
284
|
common: commonObj,
|
|
256
285
|
native: {},
|
|
257
286
|
});
|
|
258
287
|
}
|
|
259
288
|
else {
|
|
260
|
-
await this.adapter.setObjectAsync(stateName
|
|
289
|
+
await this.adapter.setObjectAsync(stateName, {
|
|
261
290
|
type: "state",
|
|
262
291
|
common: commonObj,
|
|
263
292
|
native: {},
|
|
264
293
|
});
|
|
265
294
|
}
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
await this.adapter.setState(stateName.value, { val: value, ack: true });
|
|
295
|
+
if (!dontUpdate || (await this.adapter.getStateAsync(stateName)) === null) {
|
|
296
|
+
await this.adapter.setState(stateName, { val: value, ack: true });
|
|
269
297
|
}
|
|
270
298
|
}
|
|
271
299
|
}
|
|
@@ -298,5 +326,5 @@ class TibberHelper {
|
|
|
298
326
|
return `Error (${error.statusMessage || error.statusText || "Unknown Status"}) occurred during: -${context}- : ${errorMessages}`;
|
|
299
327
|
}
|
|
300
328
|
}
|
|
301
|
-
exports.
|
|
302
|
-
//# sourceMappingURL=
|
|
329
|
+
exports.ProjectUtils = ProjectUtils;
|
|
330
|
+
//# sourceMapping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M,IAAI,KAAK,CAAC,OAAO,EAAE,CAAC;YAC1B,aAAa,GAAG,KAAK,CAAC,OAAO,CAAC,CAAC,mFAAmF;QACnH,CAAC;aAAM,CAAC;YACP,aAAa,GAAG,eAAe,CAAC,CAAC,4EAA4E;QAC9G,CAAC;QACD,oFAAoF;QACpF,OAAO,UAAU,KAAK,CAAC,aAAa,IAAI,KAAK,CAAC,UAAU,IAAI,gBAAgB,uBAAuB,OAAO,OAAO,aAAa,EAAE,CAAC;IAClI,CAAC;CACD;AAtTD,oCAsTC"}
|
|
@@ -3,8 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.TibberAPICaller = void 0;
|
|
4
4
|
const tibber_api_1 = require("tibber-api");
|
|
5
5
|
const EnergyResolution_1 = require("tibber-api/lib/src/models/enums/EnergyResolution");
|
|
6
|
-
const
|
|
7
|
-
|
|
6
|
+
const projectUtils_1 = require("./projectUtils");
|
|
7
|
+
// import { IHomeInfo } from "./tibberHelper";
|
|
8
|
+
class TibberAPICaller extends projectUtils_1.ProjectUtils {
|
|
8
9
|
tibberConfig;
|
|
9
10
|
tibberQuery;
|
|
10
11
|
constructor(tibberConfig, adapter) {
|
|
@@ -29,22 +30,22 @@ class TibberAPICaller extends tibberHelper_1.TibberHelper {
|
|
|
29
30
|
// Set HomeId in tibberConfig for further API Calls
|
|
30
31
|
this.tibberConfig.homeId = currentHome.id;
|
|
31
32
|
// Home GENERAL
|
|
32
|
-
this.checkAndSetValue(
|
|
33
|
-
this.checkAndSetValue(
|
|
34
|
-
this.checkAndSetValue(
|
|
35
|
-
this.checkAndSetValue(
|
|
33
|
+
this.checkAndSetValue(`Homes.${currentHome.id}.General.Id`, currentHome.id, "ID of your home");
|
|
34
|
+
this.checkAndSetValue(`Homes.${currentHome.id}.General.Timezone`, currentHome.timeZone, "The time zone the home resides in");
|
|
35
|
+
this.checkAndSetValue(`Homes.${currentHome.id}.General.NameInApp`, currentHome.appNickname, "The nickname given to the home");
|
|
36
|
+
this.checkAndSetValue(`Homes.${currentHome.id}.General.AvatarInApp`, currentHome.appAvatar, "The chosen app avatar for the home");
|
|
36
37
|
// Values: APARTMENT, ROWHOUSE, FLOORHOUSE1, FLOORHOUSE2, FLOORHOUSE3, COTTAGE, CASTLE
|
|
37
|
-
this.checkAndSetValue(
|
|
38
|
+
this.checkAndSetValue(`Homes.${currentHome.id}.General.Type`, currentHome.type, "The type of home.");
|
|
38
39
|
// Values: APARTMENT, ROWHOUSE, HOUSE, COTTAGE
|
|
39
|
-
this.checkAndSetValue(
|
|
40
|
+
this.checkAndSetValue(`Homes.${currentHome.id}.General.PrimaryHeatingSource`, currentHome.primaryHeatingSource, "The primary form of heating in the home");
|
|
40
41
|
// Values: AIR2AIR_HEATPUMP, ELECTRICITY, GROUND, DISTRICT_HEATING, ELECTRIC_BOILER, AIR2WATER_HEATPUMP, OTHER
|
|
41
|
-
this.checkAndSetValueNumber(
|
|
42
|
-
this.checkAndSetValueNumber(
|
|
43
|
-
this.checkAndSetValueNumber(
|
|
44
|
-
this.checkAndSetValueBoolean(
|
|
42
|
+
this.checkAndSetValueNumber(`Homes.${currentHome.id}.General.Size`, currentHome.size, "The size of the home in square meters");
|
|
43
|
+
this.checkAndSetValueNumber(`Homes.${currentHome.id}.General.NumberOfResidents`, currentHome.numberOfResidents, "The number of people living in the home");
|
|
44
|
+
this.checkAndSetValueNumber(`Homes.${currentHome.id}.General.MainFuseSize`, currentHome.mainFuseSize, "The main fuse size");
|
|
45
|
+
this.checkAndSetValueBoolean(`Homes.${currentHome.id}.General.HasVentilationSystem`, currentHome.hasVentilationSystem, "Whether the home has a ventilation system");
|
|
45
46
|
this.fetchAddress(currentHome.id, "Address", currentHome.address);
|
|
46
47
|
this.fetchLegalEntity(currentHome.id, "Owner", currentHome.owner);
|
|
47
|
-
this.checkAndSetValueBoolean(
|
|
48
|
+
this.checkAndSetValueBoolean(`Homes.${currentHome.id}.Features.RealTimeConsumptionEnabled`, currentHome.features.realTimeConsumptionEnabled, "Whether Tibber server will send consumption data by API");
|
|
48
49
|
}
|
|
49
50
|
return homeInfoList;
|
|
50
51
|
}
|
|
@@ -140,7 +141,7 @@ class TibberAPICaller extends tibberHelper_1.TibberHelper {
|
|
|
140
141
|
}
|
|
141
142
|
else {
|
|
142
143
|
const now = new Date();
|
|
143
|
-
this.checkAndSetValue(
|
|
144
|
+
this.checkAndSetValue(`Homes.${curHomeInfo.ID}.PricesToday.lastUpdate`, now.toString(), `last update of prices today`);
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
147
|
return okprice;
|
|
@@ -170,7 +171,7 @@ class TibberAPICaller extends tibberHelper_1.TibberHelper {
|
|
|
170
171
|
throw new Error(`Got invalid data structure from Tibber [you might not have a valid (or fully confirmed) contract]`);
|
|
171
172
|
}
|
|
172
173
|
this.adapter.log.debug(`Got prices today from tibber api: ${JSON.stringify(pricesToday)} Force: ${forceUpdate}`);
|
|
173
|
-
this.checkAndSetValue(
|
|
174
|
+
this.checkAndSetValue(`Homes.${homeId}.PricesToday.json`, JSON.stringify(pricesToday), "The prices today as json"); // write also it might be empty
|
|
174
175
|
this.fetchPriceAverage(homeId, `PricesToday.average`, pricesToday);
|
|
175
176
|
this.fetchPriceRemainingAverage(homeId, `PricesToday.averageRemaining`, pricesToday);
|
|
176
177
|
this.fetchPriceMaximum(homeId, `PricesToday.maximum`, pricesToday.sort((a, b) => a.total - b.total));
|
|
@@ -181,7 +182,7 @@ class TibberAPICaller extends tibberHelper_1.TibberHelper {
|
|
|
181
182
|
await this.fetchPrice(homeId, `PricesToday.${hour}`, price);
|
|
182
183
|
}
|
|
183
184
|
if (Array.isArray(pricesToday) && pricesToday[2] && pricesToday[2].startsAt) {
|
|
184
|
-
this.checkAndSetValue(
|
|
185
|
+
this.checkAndSetValue(`Homes.${homeId}.PricesToday.jsonBYpriceASC`, JSON.stringify(pricesToday.sort((a, b) => a.total - b.total)), "prices sorted by cost ascending as json");
|
|
185
186
|
exDate = new Date(pricesToday[2].startsAt);
|
|
186
187
|
if (exDate && exDate >= today) {
|
|
187
188
|
return true;
|
|
@@ -189,7 +190,7 @@ class TibberAPICaller extends tibberHelper_1.TibberHelper {
|
|
|
189
190
|
}
|
|
190
191
|
else {
|
|
191
192
|
// Handle the case when pricesToday is not an array, it's empty!, so just don't sort and write
|
|
192
|
-
this.checkAndSetValue(
|
|
193
|
+
this.checkAndSetValue(`Homes.${homeId}.PricesToday.jsonBYpriceASC`, JSON.stringify(pricesToday), "prices sorted by cost ascending as json");
|
|
193
194
|
return false;
|
|
194
195
|
}
|
|
195
196
|
}
|
|
@@ -224,7 +225,7 @@ class TibberAPICaller extends tibberHelper_1.TibberHelper {
|
|
|
224
225
|
}
|
|
225
226
|
else {
|
|
226
227
|
const now = new Date();
|
|
227
|
-
this.checkAndSetValue(
|
|
228
|
+
this.checkAndSetValue(`Homes.${curHomeInfo.ID}.PricesTomorrow.lastUpdate`, now.toString(), `last update of prices tomorrow`);
|
|
228
229
|
}
|
|
229
230
|
}
|
|
230
231
|
return okprice;
|
|
@@ -252,7 +253,7 @@ class TibberAPICaller extends tibberHelper_1.TibberHelper {
|
|
|
252
253
|
if (!exDate || exDate < morgen || forceUpdate) {
|
|
253
254
|
const pricesTomorrow = await this.tibberQuery.getTomorrowsEnergyPrices(homeId);
|
|
254
255
|
this.adapter.log.debug(`Got prices tomorrow from tibber api: ${JSON.stringify(pricesTomorrow)} Force: ${forceUpdate}`);
|
|
255
|
-
this.checkAndSetValue(
|
|
256
|
+
this.checkAndSetValue(`Homes.${homeId}.PricesTomorrow.json`, JSON.stringify(pricesTomorrow), "The prices tomorrow as json"); // write also it might be empty
|
|
256
257
|
if (pricesTomorrow.length === 0) {
|
|
257
258
|
// pricing not known, before about 13:00 - delete all the states
|
|
258
259
|
this.adapter.log.debug(`Emptying prices tomorrow and average cause existing ones are obsolete...`);
|
|
@@ -262,7 +263,7 @@ class TibberAPICaller extends tibberHelper_1.TibberHelper {
|
|
|
262
263
|
this.emptyingPriceAverage(homeId, `PricesTomorrow.average`);
|
|
263
264
|
this.emptyingPriceMaximum(homeId, `PricesTomorrow.maximum`);
|
|
264
265
|
this.emptyingPriceMinimum(homeId, `PricesTomorrow.minimum`);
|
|
265
|
-
this.checkAndSetValue(
|
|
266
|
+
this.checkAndSetValue(`Homes.${homeId}.PricesTomorrow.jsonBYpriceASC`, JSON.stringify(pricesTomorrow), "prices sorted by cost ascending as json");
|
|
266
267
|
return false;
|
|
267
268
|
}
|
|
268
269
|
else if (Array.isArray(pricesTomorrow)) {
|
|
@@ -275,7 +276,7 @@ class TibberAPICaller extends tibberHelper_1.TibberHelper {
|
|
|
275
276
|
this.fetchPriceAverage(homeId, `PricesTomorrow.average`, pricesTomorrow);
|
|
276
277
|
this.fetchPriceMaximum(homeId, `PricesTomorrow.maximum`, pricesTomorrow.sort((a, b) => a.total - b.total));
|
|
277
278
|
this.fetchPriceMinimum(homeId, `PricesTomorrow.minimum`, pricesTomorrow.sort((a, b) => a.total - b.total));
|
|
278
|
-
this.checkAndSetValue(
|
|
279
|
+
this.checkAndSetValue(`Homes.${homeId}.PricesTomorrow.jsonBYpriceASC`, JSON.stringify(pricesTomorrow.sort((a, b) => a.total - b.total)), "prices sorted by cost ascending as json");
|
|
279
280
|
exDate = new Date(pricesTomorrow[2].startsAt);
|
|
280
281
|
if (exDate && exDate >= morgen) {
|
|
281
282
|
return true;
|
|
@@ -326,10 +327,10 @@ class TibberAPICaller extends tibberHelper_1.TibberHelper {
|
|
|
326
327
|
else {
|
|
327
328
|
consumption = await this.tibberQuery.getConsumption(type, numCons, homeID);
|
|
328
329
|
}
|
|
329
|
-
this.checkAndSetValue(
|
|
330
|
+
this.checkAndSetValue(`Homes.${homeID}.Consumption.${state}`, JSON.stringify(consumption), `Historical consumption last ${description}s as json)`);
|
|
330
331
|
}
|
|
331
332
|
else {
|
|
332
|
-
this.checkAndSetValue(
|
|
333
|
+
this.checkAndSetValue(`Homes.${homeID}.Consumption.${state}`, `[]`);
|
|
333
334
|
}
|
|
334
335
|
}
|
|
335
336
|
this.adapter.log.debug(`Got all consumption data from Tibber Server for home: ${homeID}`);
|
|
@@ -348,12 +349,12 @@ class TibberAPICaller extends tibberHelper_1.TibberHelper {
|
|
|
348
349
|
* @returns Promise<void> - Resolves when the price data is successfully fetched and updated.
|
|
349
350
|
*/
|
|
350
351
|
async fetchPrice(homeId, objectDestination, price) {
|
|
351
|
-
await this.checkAndSetValueNumber(
|
|
352
|
-
this.checkAndSetValueNumber(
|
|
353
|
-
this.checkAndSetValueNumber(
|
|
354
|
-
this.checkAndSetValue(
|
|
355
|
-
//this.checkAndSetValue(
|
|
356
|
-
this.checkAndSetValue(
|
|
352
|
+
await this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.total`, price.total, "Total price (energy + taxes)");
|
|
353
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.energy`, price.energy, "Spotmarket energy price");
|
|
354
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.tax`, price.tax, "Tax part of the price (energy, tax, VAT...)");
|
|
355
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.startsAt`, price.startsAt, "Start time of the price");
|
|
356
|
+
//this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.currency`, price.currency, "The price currency");
|
|
357
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.level`, price.level, "Price level compared to recent price values");
|
|
357
358
|
}
|
|
358
359
|
fetchPriceAverage(homeId, objectDestination, price) {
|
|
359
360
|
const totalSum = price.reduce((sum, item) => {
|
|
@@ -362,11 +363,11 @@ class TibberAPICaller extends tibberHelper_1.TibberHelper {
|
|
|
362
363
|
}
|
|
363
364
|
return sum;
|
|
364
365
|
}, 0);
|
|
365
|
-
this.checkAndSetValueNumber(
|
|
366
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.total`, Math.round(1000 * (totalSum / price.length)) / 1000, "Todays total price average");
|
|
366
367
|
const energySum = price.reduce((sum, item) => sum + item.energy, 0);
|
|
367
|
-
this.checkAndSetValueNumber(
|
|
368
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.energy`, Math.round(1000 * (energySum / price.length)) / 1000, "Todays average spotmarket price");
|
|
368
369
|
const taxSum = price.reduce((sum, item) => sum + item.tax, 0);
|
|
369
|
-
this.checkAndSetValueNumber(
|
|
370
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.tax`, Math.round(1000 * (taxSum / price.length)) / 1000, "Todays average tax price");
|
|
370
371
|
}
|
|
371
372
|
fetchPriceRemainingAverage(homeId, objectDestination, price) {
|
|
372
373
|
const now = new Date(); // current time
|
|
@@ -382,64 +383,64 @@ class TibberAPICaller extends tibberHelper_1.TibberHelper {
|
|
|
382
383
|
}
|
|
383
384
|
return sum;
|
|
384
385
|
}, 0);
|
|
385
|
-
this.checkAndSetValueNumber(
|
|
386
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.total`, Math.round(1000 * (remainingTotalSum / filteredPrices.length)) / 1000, "Todays total price remaining average");
|
|
386
387
|
const remainingEnergySum = filteredPrices.reduce((sum, item) => sum + item.energy, 0);
|
|
387
|
-
this.checkAndSetValueNumber(
|
|
388
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.energy`, Math.round(1000 * (remainingEnergySum / filteredPrices.length)) / 1000, "Todays remaining average spot market price");
|
|
388
389
|
const remainingTaxSum = filteredPrices.reduce((sum, item) => sum + item.tax, 0);
|
|
389
|
-
this.checkAndSetValueNumber(
|
|
390
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.tax`, Math.round(1000 * (remainingTaxSum / filteredPrices.length)) / 1000, "Todays remaining average tax price");
|
|
390
391
|
}
|
|
391
392
|
fetchPriceMaximum(homeId, objectDestination, price) {
|
|
392
393
|
if (!price || typeof price[23].total !== "number") {
|
|
393
394
|
// possible exit 1.4.3 - Sentry discovered possible error in 1.4.1
|
|
394
395
|
// return;
|
|
395
396
|
}
|
|
396
|
-
this.checkAndSetValueNumber(
|
|
397
|
-
this.checkAndSetValueNumber(
|
|
398
|
-
this.checkAndSetValueNumber(
|
|
399
|
-
this.checkAndSetValue(
|
|
400
|
-
this.checkAndSetValue(
|
|
397
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.total`, Math.round(1000 * price[23].total) / 1000, "Todays total price maximum");
|
|
398
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.energy`, Math.round(1000 * price[23].energy) / 1000, "Todays spotmarket price at total price maximum");
|
|
399
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.tax`, Math.round(1000 * price[23].tax) / 1000, "Todays tax price at total price maximum");
|
|
400
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.level`, price[23].level, "Price level compared to recent price values");
|
|
401
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.startsAt`, price[23].startsAt, "Start time of the price maximum");
|
|
401
402
|
}
|
|
402
403
|
fetchPriceMinimum(homeId, objectDestination, price) {
|
|
403
|
-
this.checkAndSetValueNumber(
|
|
404
|
-
this.checkAndSetValueNumber(
|
|
405
|
-
this.checkAndSetValueNumber(
|
|
406
|
-
this.checkAndSetValue(
|
|
407
|
-
this.checkAndSetValue(
|
|
404
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.total`, Math.round(1000 * price[0].total) / 1000, "Todays total price minimum");
|
|
405
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.energy`, Math.round(1000 * price[0].energy) / 1000, "Todays spotmarket price at total price minimum");
|
|
406
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.tax`, Math.round(1000 * price[0].tax) / 1000, "Todays tax price at total price minimum");
|
|
407
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.level`, price[0].level, "Price level compared to recent price values");
|
|
408
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.startsAt`, price[0].startsAt, "Start time of the price minimum");
|
|
408
409
|
}
|
|
409
410
|
emptyingPrice(homeId, objectDestination) {
|
|
410
|
-
this.checkAndSetValueNumber(
|
|
411
|
-
this.checkAndSetValueNumber(
|
|
412
|
-
this.checkAndSetValueNumber(
|
|
413
|
-
this.checkAndSetValue(
|
|
411
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.total`, 0, "The total price (energy + taxes)");
|
|
412
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.energy`, 0, "Spotmarket price");
|
|
413
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.tax`, 0, "Tax part of the price (energy tax, VAT, etc.)");
|
|
414
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.level`, "Not known now", "Price level compared to recent price values");
|
|
414
415
|
}
|
|
415
416
|
emptyingPriceAverage(homeId, objectDestination) {
|
|
416
|
-
this.checkAndSetValueNumber(
|
|
417
|
-
this.checkAndSetValueNumber(
|
|
418
|
-
this.checkAndSetValueNumber(
|
|
417
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.total`, 0, "The todays total price average");
|
|
418
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.energy`, 0, "The todays avarage spotmarket price");
|
|
419
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.tax`, 0, "The todays avarage tax price");
|
|
419
420
|
}
|
|
420
421
|
emptyingPriceMaximum(homeId, objectDestination) {
|
|
421
|
-
this.checkAndSetValueNumber(
|
|
422
|
-
this.checkAndSetValueNumber(
|
|
423
|
-
this.checkAndSetValueNumber(
|
|
424
|
-
this.checkAndSetValue(
|
|
425
|
-
this.checkAndSetValue(
|
|
422
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.total`, 0, "Todays total price maximum");
|
|
423
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.energy`, 0, "Todays spotmarket price at total price maximum");
|
|
424
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.tax`, 0, "Todays tax price at total price maximum");
|
|
425
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.level`, "Not known now", "Price level compared to recent price values");
|
|
426
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.startsAt`, "Not known now", "Start time of the price maximum");
|
|
426
427
|
}
|
|
427
428
|
emptyingPriceMinimum(homeId, objectDestination) {
|
|
428
|
-
this.checkAndSetValueNumber(
|
|
429
|
-
this.checkAndSetValueNumber(
|
|
430
|
-
this.checkAndSetValueNumber(
|
|
431
|
-
this.checkAndSetValue(
|
|
432
|
-
this.checkAndSetValue(
|
|
429
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.total`, 0, "Todays total price minimum");
|
|
430
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.energy`, 0, "Todays spotmarket price at total price minimum");
|
|
431
|
+
this.checkAndSetValueNumber(`Homes.${homeId}.${objectDestination}.tax`, 0, "Todays tax price at total price minimum");
|
|
432
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.level`, "Not known now", "Price level compared to recent price values");
|
|
433
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.startsAt`, "Not known now", "Start time of the price minimum");
|
|
433
434
|
}
|
|
434
435
|
fetchLegalEntity(homeId, objectDestination, legalEntity) {
|
|
435
|
-
this.checkAndSetValue(
|
|
436
|
-
this.checkAndSetValue(
|
|
437
|
-
this.checkAndSetValueBoolean(
|
|
438
|
-
this.checkAndSetValue(
|
|
439
|
-
this.checkAndSetValue(
|
|
440
|
-
this.checkAndSetValue(
|
|
441
|
-
this.checkAndSetValue(
|
|
442
|
-
this.checkAndSetValue(
|
|
436
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.Id`, legalEntity.id);
|
|
437
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.FirstName`, legalEntity.firstName);
|
|
438
|
+
this.checkAndSetValueBoolean(`Homes.${homeId}.${objectDestination}.IsCompany`, legalEntity.isCompany);
|
|
439
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.Name`, legalEntity.name);
|
|
440
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.MiddleName`, legalEntity.middleName);
|
|
441
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.LastName`, legalEntity.lastName);
|
|
442
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.OrganizationNo`, legalEntity.organizationNo);
|
|
443
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.Language`, legalEntity.language);
|
|
443
444
|
if (legalEntity.contactInfo) {
|
|
444
445
|
this.fetchContactInfo(homeId, objectDestination + ".ContactInfo", legalEntity.contactInfo);
|
|
445
446
|
}
|
|
@@ -448,20 +449,20 @@ class TibberAPICaller extends tibberHelper_1.TibberHelper {
|
|
|
448
449
|
}
|
|
449
450
|
}
|
|
450
451
|
fetchContactInfo(homeId, objectDestination, contactInfo) {
|
|
451
|
-
this.checkAndSetValue(
|
|
452
|
-
this.checkAndSetValue(
|
|
452
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.Email`, contactInfo.email);
|
|
453
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.Mobile`, contactInfo.mobile);
|
|
453
454
|
}
|
|
454
455
|
fetchAddress(homeId, objectDestination, address) {
|
|
455
|
-
this.checkAndSetValue(
|
|
456
|
-
this.checkAndSetValue(
|
|
457
|
-
this.checkAndSetValue(
|
|
458
|
-
this.checkAndSetValue(
|
|
459
|
-
this.checkAndSetValue(
|
|
460
|
-
this.checkAndSetValue(
|
|
461
|
-
this.checkAndSetValue(
|
|
462
|
-
this.checkAndSetValue(
|
|
456
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.address1`, address.address1);
|
|
457
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.address2`, address.address2);
|
|
458
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.address3`, address.address3);
|
|
459
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.City`, address.city);
|
|
460
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.PostalCode`, address.postalCode);
|
|
461
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.Country`, address.country);
|
|
462
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.Latitude`, address.latitude);
|
|
463
|
+
this.checkAndSetValue(`Homes.${homeId}.${objectDestination}.Longitude`, address.longitude);
|
|
463
464
|
}
|
|
464
|
-
//#region *** obsolete data poll for consumption data
|
|
465
|
+
//#region *** obsolete data poll for consumption data ***
|
|
465
466
|
/**
|
|
466
467
|
* Get energy consumption for one or more homes.
|
|
467
468
|
* Returns an array of IConsumption
|