iobroker.teslafi 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/LICENSE +21 -0
- package/README.md +78 -0
- package/admin/jsonConfig.json +110 -0
- package/admin/teslafi.png +0 -0
- package/admin/teslafiwt.png +0 -0
- package/build/lib/teslafiAPICaller.js +601 -0
- package/build/lib/teslafiAPICaller.js.map +1 -0
- package/build/lib/teslafiHelper.js +261 -0
- package/build/lib/teslafiHelper.js.map +1 -0
- package/build/main.js +199 -0
- package/build/main.js.map +1 -0
- package/docu/bluePayPal.svg +118 -0
- package/io-package.json +156 -0
- package/package.json +86 -0
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TeslaFiHelper = void 0;
|
|
4
|
+
class TeslaFiHelper {
|
|
5
|
+
adapter;
|
|
6
|
+
constructor(adapter) {
|
|
7
|
+
this.adapter = adapter;
|
|
8
|
+
}
|
|
9
|
+
// protected getStatePrefix(homeId: string, space: string, id: string, name?: string): { [key: string]: string } {
|
|
10
|
+
getStatePrefix(id, name) {
|
|
11
|
+
const statePrefix = {
|
|
12
|
+
key: name ? name : id,
|
|
13
|
+
value: `Cars.${id}`,
|
|
14
|
+
};
|
|
15
|
+
return statePrefix;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves the value of a given state by its name.
|
|
19
|
+
*
|
|
20
|
+
* @param stateName - A string representing the name of the state to retrieve.
|
|
21
|
+
* @returns A Promise that resolves with the value of the state if it exists, otherwise resolves with null.
|
|
22
|
+
*/
|
|
23
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
24
|
+
async getStateValue(stateName) {
|
|
25
|
+
try {
|
|
26
|
+
const stateObject = await this.getState(stateName);
|
|
27
|
+
return stateObject?.val ?? null; // errors have already been handled in getState()
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
this.adapter.log.error(`[getStateValue](${stateName}): ${error}`);
|
|
31
|
+
return null;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Retrieves the state object by its name.
|
|
36
|
+
*
|
|
37
|
+
* @param stateName - A string representing the name of the state to retrieve.
|
|
38
|
+
* @returns A Promise that resolves with the object of the state if it exists, otherwise resolves with null.
|
|
39
|
+
*/
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
async getState(stateName) {
|
|
42
|
+
try {
|
|
43
|
+
if (await this.verifyStateAvailable(stateName)) {
|
|
44
|
+
// Get state value, so like: {val: false, ack: true, ts: 1591117034451, �}
|
|
45
|
+
const stateValueObject = await this.adapter.getStateAsync(stateName);
|
|
46
|
+
if (!this.isLikeEmpty(stateValueObject)) {
|
|
47
|
+
return stateValueObject;
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
throw `Unable to retrieve info from state '${stateName}'.`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
this.adapter.log.error(`[asyncGetState](${stateName}): ${error}`);
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Verifies the availability of a state by its name.
|
|
61
|
+
*
|
|
62
|
+
* @param stateName - A string representing the name of the state to verify.
|
|
63
|
+
* @returns A Promise that resolves with true if the state exists, otherwise resolves with false.
|
|
64
|
+
*/
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
66
|
+
async verifyStateAvailable(stateName) {
|
|
67
|
+
const stateObject = await this.adapter.getObjectAsync(stateName); // Check state existence
|
|
68
|
+
if (!stateObject) {
|
|
69
|
+
this.adapter.log.debug(`[verifyStateAvailable](${stateName}): State does not exist.`);
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Checks if the given input variable is effectively empty.
|
|
76
|
+
*
|
|
77
|
+
* This method examines the provided `inputVar` to determine if it contains any meaningful data.
|
|
78
|
+
* It performs a series of transformations to strip out whitespace and common punctuation, then checks if the result is an empty string.
|
|
79
|
+
*
|
|
80
|
+
* @param inputVar - The state variable to check, which can be of type `ioBroker.State`, `null`, or `undefined`.
|
|
81
|
+
* @returns A boolean indicating whether the input variable is considered empty (`true` if empty, `false` otherwise).
|
|
82
|
+
*/
|
|
83
|
+
isLikeEmpty(inputVar) {
|
|
84
|
+
if (typeof inputVar !== "undefined" && inputVar !== null) {
|
|
85
|
+
let sTemp = JSON.stringify(inputVar);
|
|
86
|
+
sTemp = sTemp.replace(/\s+/g, ""); // remove all white spaces
|
|
87
|
+
sTemp = sTemp.replace(/"+/g, ""); // remove all >"<
|
|
88
|
+
sTemp = sTemp.replace(/'+/g, ""); // remove all >'<
|
|
89
|
+
sTemp = sTemp.replace(/\[+/g, ""); // remove all >[<
|
|
90
|
+
sTemp = sTemp.replace(/\]+/g, ""); // remove all >]<
|
|
91
|
+
sTemp = sTemp.replace(/\{+/g, ""); // remove all >{<
|
|
92
|
+
sTemp = sTemp.replace(/\}+/g, ""); // remove all >}<
|
|
93
|
+
if (sTemp !== "") {
|
|
94
|
+
return false;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Checks if a string state exists, creates it if necessary, and updates its value.
|
|
106
|
+
*
|
|
107
|
+
* @param stateName - A string containing the name of the state.
|
|
108
|
+
* @param value - The string value to set for the state.
|
|
109
|
+
* @param description - Optional description for the state (default is "-").
|
|
110
|
+
* @param writeable - Optional boolean indicating if the state should be writeable (default is false).
|
|
111
|
+
* @param dontUpdate - Optional boolean indicating if the state should not be updated if it already exists (default is false).
|
|
112
|
+
* @param forceMode - Optional boolean indicating if the state should be reinitiated if it already exists (default is false).
|
|
113
|
+
* @returns A Promise that resolves when the state is checked, created (if necessary), and updated.
|
|
114
|
+
*/
|
|
115
|
+
async checkAndSetValue(stateName, value, description = "-", writeable = false, dontUpdate = false, forceMode = false) {
|
|
116
|
+
if (value != undefined) {
|
|
117
|
+
if (value.trim().length > 0) {
|
|
118
|
+
const commonObj = {
|
|
119
|
+
name: stateName,
|
|
120
|
+
type: "string",
|
|
121
|
+
role: "text",
|
|
122
|
+
desc: description,
|
|
123
|
+
read: true,
|
|
124
|
+
write: writeable,
|
|
125
|
+
};
|
|
126
|
+
if (!forceMode) {
|
|
127
|
+
await this.adapter.setObjectNotExistsAsync(stateName, {
|
|
128
|
+
type: "state",
|
|
129
|
+
common: commonObj,
|
|
130
|
+
native: {},
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
else {
|
|
134
|
+
await this.adapter.setObjectAsync(stateName, {
|
|
135
|
+
type: "state",
|
|
136
|
+
common: commonObj,
|
|
137
|
+
native: {},
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
if (!dontUpdate || (await this.adapter.getStateAsync(stateName)) === null) {
|
|
141
|
+
await this.adapter.setState(stateName, { val: value, ack: true });
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Checks if a number state exists, creates it if necessary, and updates its value.
|
|
148
|
+
*
|
|
149
|
+
* @param stateName - A string containing the name of the state.
|
|
150
|
+
* @param value - The number value to set for the state.
|
|
151
|
+
* @param description - Optional description for the state (default is "-").
|
|
152
|
+
* @param unit - Optional unit string to set for the state (default is undefined).
|
|
153
|
+
* @param writeable - Optional boolean indicating if the state should be writeable (default is false).
|
|
154
|
+
* @param dontUpdate - Optional boolean indicating if the state should not be updated if it already exists (default is false).
|
|
155
|
+
* @param forceMode - Optional boolean indicating if the state should be reinitiated if it already exists (default is false).
|
|
156
|
+
* @returns A Promise that resolves when the state is checked, created (if necessary), and updated.
|
|
157
|
+
*/
|
|
158
|
+
async checkAndSetValueNumber(stateName, value, description = "-", unit, writeable = false, dontUpdate = false, forceMode = false) {
|
|
159
|
+
if (value || value === 0) {
|
|
160
|
+
const commonObj = {
|
|
161
|
+
name: stateName,
|
|
162
|
+
type: "number",
|
|
163
|
+
role: "value",
|
|
164
|
+
desc: description,
|
|
165
|
+
read: true,
|
|
166
|
+
write: writeable,
|
|
167
|
+
};
|
|
168
|
+
// Add unit only if it's provided and not null or undefined
|
|
169
|
+
if (unit !== null && unit !== undefined) {
|
|
170
|
+
commonObj.unit = unit;
|
|
171
|
+
}
|
|
172
|
+
if (!forceMode) {
|
|
173
|
+
await this.adapter.setObjectNotExistsAsync(stateName, {
|
|
174
|
+
type: "state",
|
|
175
|
+
common: commonObj,
|
|
176
|
+
native: {},
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
await this.adapter.setObjectAsync(stateName, {
|
|
181
|
+
type: "state",
|
|
182
|
+
common: commonObj,
|
|
183
|
+
native: {},
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
if (!dontUpdate || (await this.adapter.getStateAsync(stateName)) === null) {
|
|
187
|
+
await this.adapter.setState(stateName, { val: value, ack: true });
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Checks if a boolean state exists, creates it if necessary, and updates its value.
|
|
193
|
+
*
|
|
194
|
+
* @param stateName - A string containing the name of the state.
|
|
195
|
+
* @param value - The boolean value to set for the state.
|
|
196
|
+
* @param description - Optional description for the state (default is "-").
|
|
197
|
+
* @param writeable - Optional boolean indicating if the state should be writeable (default is false).
|
|
198
|
+
* @param dontUpdate - Optional boolean indicating if the state should not be updated if it already exists (default is false).
|
|
199
|
+
* @returns A Promise that resolves when the state is checked, created (if necessary), and updated.
|
|
200
|
+
*/
|
|
201
|
+
async checkAndSetValueBoolean(stateName, value, description = "-", writeable = false, dontUpdate = false) {
|
|
202
|
+
if (value !== undefined && value !== null) {
|
|
203
|
+
const commonObj = {
|
|
204
|
+
name: stateName,
|
|
205
|
+
type: "boolean",
|
|
206
|
+
role: "indicator",
|
|
207
|
+
desc: description,
|
|
208
|
+
read: true,
|
|
209
|
+
write: writeable,
|
|
210
|
+
};
|
|
211
|
+
if (stateName.split(".").pop() === stateName) {
|
|
212
|
+
await this.adapter.setObjectNotExistsAsync(stateName, {
|
|
213
|
+
type: "state",
|
|
214
|
+
common: commonObj,
|
|
215
|
+
native: {},
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
else {
|
|
219
|
+
await this.adapter.setObjectAsync(stateName, {
|
|
220
|
+
type: "state",
|
|
221
|
+
common: commonObj,
|
|
222
|
+
native: {},
|
|
223
|
+
});
|
|
224
|
+
}
|
|
225
|
+
// Update the state value if not in don't update mode or the state does not exist
|
|
226
|
+
if (!dontUpdate || (await this.adapter.getStateAsync(stateName)) === null) {
|
|
227
|
+
await this.adapter.setState(stateName, { val: value, ack: true });
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Generates a formatted error message based on the provided error object and context.
|
|
233
|
+
*
|
|
234
|
+
* @param error - The error object containing information about the error, such as status and error messages.
|
|
235
|
+
* @param context - A string providing context for where the error occurred.
|
|
236
|
+
* @returns A string representing the formatted error message.
|
|
237
|
+
*/
|
|
238
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
239
|
+
generateErrorMessage(error, context) {
|
|
240
|
+
let errorMessages = "";
|
|
241
|
+
// Check if error object has an 'errors' property that is an array
|
|
242
|
+
if (error.errors && Array.isArray(error.errors)) {
|
|
243
|
+
// Iterate over the array of errors and concatenate their messages
|
|
244
|
+
for (const err of error.errors) {
|
|
245
|
+
if (errorMessages)
|
|
246
|
+
errorMessages += ", ";
|
|
247
|
+
errorMessages += err.message;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
else if (error.message) {
|
|
251
|
+
errorMessages = error.message; // If 'errors' array is not present, use the 'message' property of the error object
|
|
252
|
+
}
|
|
253
|
+
else {
|
|
254
|
+
errorMessages = "Unknown error"; // If no 'errors' or 'message' property is found, default to "Unknown error"
|
|
255
|
+
}
|
|
256
|
+
// Construct the final error message string with status, context, and error messages
|
|
257
|
+
return `Error (${error.statusMessage || error.statusText || "Unknown Status"}) occurred during: -${context}- : ${errorMessages}`;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
exports.TeslaFiHelper = TeslaFiHelper;
|
|
261
|
+
//# sourceMappingURL=teslafiHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"teslafiHelper.js","sourceRoot":"","sources":["../../src/lib/teslafiHelper.ts"],"names":[],"mappings":";;;AAEA,MAAa,aAAa;IACzB,OAAO,CAAwB;IAE/B,YAAY,OAA8B;QACzC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACxB,CAAC;IAED,kHAAkH;IACxG,cAAc,CAAC,EAAU,EAAE,IAAa;QACjD,MAAM,WAAW,GAAG;YACnB,GAAG,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE;YACrB,KAAK,EAAE,QAAQ,EAAE,EAAE;SACnB,CAAC;QACF,OAAO,WAAW,CAAC;IACpB,CAAC;IAED;;;;;OAKG;IACH,8DAA8D;IACpD,KAAK,CAAC,aAAa,CAAC,SAAiB;QAC9C,IAAI,CAAC;YACJ,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;YACnD,OAAO,WAAW,EAAE,GAAG,IAAI,IAAI,CAAC,CAAC,iDAAiD;QACnF,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,mBAAmB,SAAS,MAAM,KAAK,EAAE,CAAC,CAAC;YAClE,OAAO,IAAI,CAAC;QACb,CA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C,UAAU,IAAI,gBAAgB,uBAAuB,OAAO,OAAO,aAAa,EAAE,CAAC;IAClI,CAAC;CACD;AA/QD,sCA+QC"}
|
package/build/main.js
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
// The adapter-core module gives you access to the core ioBroker functions you need to create an adapter
|
|
27
|
+
const utils = __importStar(require("@iobroker/adapter-core"));
|
|
28
|
+
const teslafiAPICaller_1 = require("./lib/teslafiAPICaller");
|
|
29
|
+
class TeslaFi extends utils.Adapter {
|
|
30
|
+
intervalList;
|
|
31
|
+
constructor(options = {}) {
|
|
32
|
+
super({
|
|
33
|
+
...options,
|
|
34
|
+
name: "teslafi",
|
|
35
|
+
});
|
|
36
|
+
this.on("ready", this.onReady.bind(this));
|
|
37
|
+
this.on("stateChange", this.onStateChange.bind(this));
|
|
38
|
+
// this.on("objectChange", this.onObjectChange.bind(this));
|
|
39
|
+
this.on("message", this.onMessage.bind(this));
|
|
40
|
+
this.on("unload", this.onUnload.bind(this));
|
|
41
|
+
this.intervalList = [];
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Is called when databases are connected and adapter received configuration.
|
|
45
|
+
*/
|
|
46
|
+
async onReady() {
|
|
47
|
+
// Reset the connection indicator during startup;
|
|
48
|
+
if (!this.config.TeslaFiAPIToken) {
|
|
49
|
+
// No Token defined in configuration
|
|
50
|
+
this.log.error(`Missing API Token - please check configuration`);
|
|
51
|
+
this.setState(`info.connection`, false, true);
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
// Now read TeslaFi data from API for the first time
|
|
55
|
+
const teslaFiAPICaller = new teslafiAPICaller_1.TeslaFiAPICaller(this);
|
|
56
|
+
try {
|
|
57
|
+
// set info.connection if data received
|
|
58
|
+
if (await teslaFiAPICaller.ReadTeslaFi()) {
|
|
59
|
+
this.setState("info.connection", true, true);
|
|
60
|
+
this.log.debug(`received data in first poll - good connection`);
|
|
61
|
+
}
|
|
62
|
+
else {
|
|
63
|
+
this.log.warn(`Got no data from TeslaFi - adapter restarts in 5 minutes`);
|
|
64
|
+
await this.delay(5 * 60 * 1000);
|
|
65
|
+
this.restart();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch (error) {
|
|
69
|
+
this.log.error(teslaFiAPICaller.generateErrorMessage(error, `pull of homes from Tibber-Server`));
|
|
70
|
+
}
|
|
71
|
+
// sentry.io ping
|
|
72
|
+
if (this.supportsFeature && this.supportsFeature("PLUGINS")) {
|
|
73
|
+
const sentryInstance = this.getPluginInstance("sentry");
|
|
74
|
+
const today = new Date();
|
|
75
|
+
const last = await this.getStateAsync("info.LastSentryLogDay");
|
|
76
|
+
if (last?.val != (await today.getDate())) {
|
|
77
|
+
if (sentryInstance) {
|
|
78
|
+
const Sentry = sentryInstance.getSentryObject();
|
|
79
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
|
80
|
+
Sentry &&
|
|
81
|
+
Sentry.withScope((scope) => {
|
|
82
|
+
scope.setLevel("info");
|
|
83
|
+
scope.setTag("SentryDay", today.getDate());
|
|
84
|
+
scope.setTag("usedInterval", this.config.UpdateInterval);
|
|
85
|
+
Sentry.captureMessage("Adapter TeslaFi started", "info"); // Level "info"
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
this.setState("info.LastSentryLogDay", { val: today.getDate(), ack: true });
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
// Init Interval job
|
|
92
|
+
const jobVehicleData = setInterval(async () => {
|
|
93
|
+
this.log.debug(`Interval job VehicleData - Result: ${await teslaFiAPICaller.ReadTeslaFi()}`);
|
|
94
|
+
}, this.config.UpdateInterval * 1000);
|
|
95
|
+
this.intervalList.push(jobVehicleData);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Is called from adapter config screen
|
|
100
|
+
*/
|
|
101
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
102
|
+
onMessage(obj) {
|
|
103
|
+
if (obj) {
|
|
104
|
+
switch (obj.command) {
|
|
105
|
+
case "WiP":
|
|
106
|
+
if (obj.callback) {
|
|
107
|
+
try {
|
|
108
|
+
this.log.warn("onMessage called");
|
|
109
|
+
}
|
|
110
|
+
catch {
|
|
111
|
+
this.sendTo(obj.from, obj.command, [{ label: "None available", value: "None available" }], obj.callback);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
break;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Is called when adapter shuts down - callback has to be called under any circumstances!
|
|
120
|
+
*/
|
|
121
|
+
onUnload(callback) {
|
|
122
|
+
try {
|
|
123
|
+
// Here you must clear all timeouts or intervals that may still be active
|
|
124
|
+
for (const intervalJob of this.intervalList) {
|
|
125
|
+
clearInterval(intervalJob);
|
|
126
|
+
}
|
|
127
|
+
this.setState("info.connection", false, true);
|
|
128
|
+
callback();
|
|
129
|
+
}
|
|
130
|
+
catch (e) {
|
|
131
|
+
this.log.warn(e.message);
|
|
132
|
+
callback();
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Is called if a subscribed state changes
|
|
137
|
+
*/
|
|
138
|
+
onStateChange(id, state) {
|
|
139
|
+
try {
|
|
140
|
+
if (state) {
|
|
141
|
+
// The state was changed
|
|
142
|
+
// this.adapter.subscribeStates(`Homes.${homeId}.Calculations.${channel}.*`);
|
|
143
|
+
if (!state.ack) {
|
|
144
|
+
if (id.includes(`.Calculations.`)) {
|
|
145
|
+
const statePath = id.split(".");
|
|
146
|
+
//const homeIDToMatch = statePath[3];
|
|
147
|
+
const calcChannel = parseInt(statePath[5]);
|
|
148
|
+
const settingType = statePath[6];
|
|
149
|
+
if (!isNaN(calcChannel) && settingType !== undefined) {
|
|
150
|
+
/*
|
|
151
|
+
switch (settingType) {
|
|
152
|
+
case "Active":
|
|
153
|
+
// Update .chActive based on state.val if it's a boolean
|
|
154
|
+
if (typeof state.val === "boolean") {
|
|
155
|
+
} else {
|
|
156
|
+
this.log.warn(`Wrong type for channel: ${calcChannel} - chActive: ${state.val}`);
|
|
157
|
+
}
|
|
158
|
+
break;
|
|
159
|
+
case "AmountHours":
|
|
160
|
+
// Update .chAmountHours based on state.val if it's a number
|
|
161
|
+
if (typeof state.val === "number") {
|
|
162
|
+
} else {
|
|
163
|
+
this.log.warn(`Wrong type for channel: ${calcChannel} - chAmountHours: ${state.val}`);
|
|
164
|
+
}
|
|
165
|
+
break;
|
|
166
|
+
case "StartTime":
|
|
167
|
+
// Update .chStartTime based on state.val if it's a datetime
|
|
168
|
+
if (typeof state.val === "string") {
|
|
169
|
+
} else {
|
|
170
|
+
this.log.warn(`Wrong type for channel: ${calcChannel} - chStartTime: ${state.val}`);
|
|
171
|
+
}
|
|
172
|
+
break;
|
|
173
|
+
default:
|
|
174
|
+
this.log.debug(`unknown value for setting type: ${settingType}`);
|
|
175
|
+
}
|
|
176
|
+
*/
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
// The state was deleted
|
|
183
|
+
this.log.warn(`state ${id} deleted`);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
catch (e) {
|
|
187
|
+
this.log.error(`Unhandled exception processing onstateChange: ${e}`);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
if (require.main !== module) {
|
|
192
|
+
// Export the constructor in compact mode
|
|
193
|
+
module.exports = (options) => new TeslaFi(options);
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
// otherwise start the instance directly
|
|
197
|
+
(() => new TeslaFi())();
|
|
198
|
+
}
|
|
199
|
+
//# sourceMappingURL=main.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,wGAAwG;AACxG,8DAAgD;AAChD,6DAA0D;AAE1D,MAAM,OAAQ,SAAQ,KAAK,CAAC,OAAO;IAClC,YAAY,CAAmB;IAE/B,YAAmB,UAAyC,EAAE;QAC7D,KAAK,CAAC;YACL,GAAG,OAAO;YACV,IAAI,EAAE,SAAS;SACf,CAAC,CAAC;QACH,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;QAC1C,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,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Plug-In . SVG Version: 6.00 Build 0) -->
|
|
3
|
+
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
|
4
|
+
viewBox="0 0 1050 200" style="enable-background:new 0 0 1050 200;" xml:space="preserve">
|
|
5
|
+
<style type="text/css">
|
|
6
|
+
.st0{fill:#009CDE;}
|
|
7
|
+
.st1{fill:#FFFFFF;}
|
|
8
|
+
.st2{filter:url(#Adobe_OpacityMaskFilter);}
|
|
9
|
+
.st3{opacity:0.678;mask:url(#e_1_);fill:#FFFFFF;enable-background:new ;}
|
|
10
|
+
.st4{filter:url(#Adobe_OpacityMaskFilter_1_);}
|
|
11
|
+
.st5{opacity:0.696;mask:url(#g_1_);fill:#FFFFFF;enable-background:new ;}
|
|
12
|
+
.st6{filter:url(#Adobe_OpacityMaskFilter_2_);}
|
|
13
|
+
.st7{mask:url(#i_1_);fill:#FFFFFF;}
|
|
14
|
+
</style>
|
|
15
|
+
<g id="button">
|
|
16
|
+
<path id="blue" class="st0" d="M1018,200H32c-17.7,0-32-14.3-32-32L0,32C0,14.3,14.3,0,32,0l986,0c17.7,0,32,14.3,32,32v136
|
|
17
|
+
C1050,185.7,1035.7,200,1018,200z"/>
|
|
18
|
+
</g>
|
|
19
|
+
<g id="donate">
|
|
20
|
+
<g>
|
|
21
|
+
<path class="st1" d="M73.3,110.6c0-13.1,6.8-21.4,17.2-21.4c5.9,0,10.6,3.1,12.8,7.7h0.2V79.3c0-3.3,2-5.1,4.8-5.1
|
|
22
|
+
s4.9,1.8,4.9,5.1v47.9c0,3.1-2,4.9-4.8,4.9s-4.9-1.7-4.9-4.9V124h-0.2c-2,4.8-6.4,8-12.9,8C80,132,73.3,123.8,73.3,110.6z
|
|
23
|
+
M103.5,110.6c0-8.1-4-13.4-10.2-13.4c-6.3,0-10.2,5.2-10.2,13.4c0,8.2,3.9,13.4,10.2,13.4C99.5,124,103.5,118.8,103.5,110.6z"/>
|
|
24
|
+
<path class="st1" d="M205.5,131.7c-3.3,0-5.2-2-5.2-5.7v-19.7c0-5.4-2.7-8.5-7.5-8.5c-5.4,0-8.7,3.9-8.7,10.4v17.8
|
|
25
|
+
c0,3.6-1.9,5.7-5.2,5.7s-5.2-2-5.2-5.7V95c0-3.4,2-5.5,5.1-5.5c3.1,0,4.9,1.8,5,5.2v2.5h0.5c1.6-4.9,6.3-8,12.3-8
|
|
26
|
+
c8.8,0,13.8,5.2,13.8,14.3v22.5C210.6,129.7,208.8,131.7,205.5,131.7z"/>
|
|
27
|
+
<path class="st1" d="M232,131.9c-8.1,0-13.6-5.1-13.6-12.6c0-7.7,5.7-12.4,15.1-12.4h9.8v-3.4c0-4.2-2.6-6.4-7.3-6.4
|
|
28
|
+
c-3.1,0-5.4,1.2-7.7,3.2c-1.2,0.9-2.3,1.4-3.9,1.4c-2.3,0-3.7-1.5-3.7-3.6c0-2.4,1.7-4.9,5.3-6.7c2.6-1.4,6.1-2.1,10.6-2.1
|
|
29
|
+
c10.9,0,17,5.2,17,14.3v22.7c0,3.5-1.8,5.5-5,5.5c-2.7,0-4.5-1.5-4.8-4.2v-1.4h-0.5C241.1,129.8,237,131.9,232,131.9z
|
|
30
|
+
M235.4,124.5c4.5,0,7.9-3,7.9-7v-4.3h-8c-4.2,0-6.7,2-6.7,5.4C228.6,122.1,231.4,124.5,235.4,124.5z"/>
|
|
31
|
+
<path class="st1" d="M266.3,98.3h-2.1c-2.8,0-4.4-1.5-4.4-4s1.6-4,4.4-4h2.3v-5.4c0-3.6,1.8-5.5,5-5.5c3.2,0,5,2,5,5.5v5.4h4.1
|
|
32
|
+
c2.8,0,4.4,1.5,4.4,4s-1.6,4-4.4,4h-4v20.9c0,3.8,1,5,4.1,5c1.1,0,1.8-0.2,2.7-0.2c1.8,0,3,1.2,3,3.1c0,1.5-0.7,2.8-2.1,3.7
|
|
33
|
+
c-1.4,0.9-3.6,1.4-6.4,1.4c-8.2,0-11.7-3.4-11.7-11.9V98.3z"/>
|
|
34
|
+
<path class="st1" d="M291.3,108c0-11.3,7.5-19,18.6-19c10.5,0,18,7.5,18,17.7c0,4.6-1.3,6.2-5.2,6.2h-21v1.8
|
|
35
|
+
c0,5.8,3.7,9.5,9.8,9.5c3.2,0,5.5-0.8,7.3-2.3c2-1.5,2.7-2.1,4.3-2.1c2.1,0,3.6,1.5,3.6,3.8c0,1.8-1.1,3.6-3.1,5
|
|
36
|
+
c-2.7,2.3-7.5,3.7-12.8,3.7c-12.1,0-19.6-7.1-19.6-18.9V108z M318.1,106.4L318.1,106.4c0-5.7-3.1-9.4-8-9.4
|
|
37
|
+
c-5.1,0-8.3,3.8-8.3,9.3v0.1H318.1z"/>
|
|
38
|
+
<path class="st1" d="M359.5,97.1c-0.3-1.2-0.4-1.9-0.4-2.5c0-2.9,2.1-5,5.2-5c2.7,0,4.5,1.8,5,5.1l5.2,25.9h0.5l6.2-24.5
|
|
39
|
+
c1.2-4.8,2.9-6.6,6.3-6.6c3.4,0,5.2,1.8,6.4,6.6l6.3,24.5h0.5l5.4-25.9c0.6-3.2,2.4-5.1,5-5.1c3.1,0,5,2,5,4.7
|
|
40
|
+
c0,0.6-0.2,1.5-0.5,2.7l-7.2,26.5c-1.7,6.2-3.7,8.2-7.3,8.2c-3.9,0-5.9-2-7.5-8.2l-6-21.8h-0.4l-5.8,21.8
|
|
41
|
+
c-1.6,6.3-3.4,8.2-7.3,8.2c-3.8,0-5.9-2.1-7.5-8.2L359.5,97.1z"/>
|
|
42
|
+
<path class="st1" d="M426.9,74c3.4,0,5.9,2.3,5.9,5.4s-2.5,5.4-5.9,5.4c-3.3,0-5.8-2.3-5.8-5.4S423.6,74,426.9,74z M426.9,131.7
|
|
43
|
+
c-3.2,0-5.1-2-5.1-5.7V95.2c0-3.8,2-5.7,5.2-5.7c3.2,0,5.1,2,5.1,5.7v30.9C432.1,129.8,430.1,131.7,426.9,131.7z"/>
|
|
44
|
+
<path class="st1" d="M444,98.3h-2.1c-2.8,0-4.4-1.5-4.4-4s1.6-4,4.4-4h2.3v-5.4c0-3.6,1.8-5.5,5-5.5c3.2,0,5,2,5,5.5v5.4h4.1
|
|
45
|
+
c2.8,0,4.4,1.5,4.4,4s-1.6,4-4.4,4h-4v20.9c0,3.8,1,5,4.1,5c1.1,0,1.8-0.2,2.7-0.2c1.8,0,3,1.2,3,3.1c0,1.5-0.7,2.8-2.1,3.7
|
|
46
|
+
c-1.4,0.9-3.6,1.4-6.4,1.4c-8.2,0-11.7-3.4-11.7-11.9V98.3z"/>
|
|
47
|
+
<path class="st1" d="M501.1,131.7c-3.3,0-5.2-2-5.2-5.7v-19.6c0-5.4-2.8-8.5-7.6-8.5c-5.3,0-8.8,4-8.8,10.4v17.8
|
|
48
|
+
c0,3.6-1.9,5.7-5.2,5.7s-5.1-2-5.1-5.7V80.6c0-3.6,1.8-5.7,5.2-5.7c3.3,0,5.1,2.1,5.1,5.7v16.6h0.5c1.4-4.7,6.5-8,12.4-8
|
|
49
|
+
c8.6,0,13.8,5.4,13.8,14.4v22.4C506.3,129.7,504.4,131.7,501.1,131.7z"/>
|
|
50
|
+
</g>
|
|
51
|
+
<path id="heart_2_" class="st1" d="M154.3,89.2c-4.3,0-8.5,2.1-10.8,6.7c-2.3-4.6-6.5-6.7-10.8-6.7c-6.7,0-12.7,4.7-12.7,13.1
|
|
52
|
+
c0,14.2,19.4,21.4,23.5,29.9c4.1-8.5,23.5-15.7,23.5-29.9C167,93.3,160.3,89.2,154.3,89.2z M150.2,99.2c3,0,5.7,2,5.7,6
|
|
53
|
+
c0,6.3-8.3,10.6-12.8,15.2c-4.4-4.6-12.8-8.9-12.8-15.2c0-3.9,2.6-6,5.7-6c4.1,0,6.2,4.6,7,6.8C144,103.8,146.2,99.2,150.2,99.2z"
|
|
54
|
+
/>
|
|
55
|
+
</g>
|
|
56
|
+
<g id="PayPal">
|
|
57
|
+
<path class="st1" d="M888.7,89.7c-1.2,8-7.3,8-13.2,8h-3.4l2.4-14.9c0.1-0.9,0.9-1.6,1.8-1.6h1.5c4,0,7.8,0,9.7,2.3
|
|
58
|
+
C888.8,84.9,889.1,86.9,888.7,89.7 M886.1,68.9h-22.2c-1.5,0-2.8,1.1-3,2.6l-9,56.9c-0.2,1,0.5,2,1.5,2.1c0.1,0,0.2,0,0.3,0h11.4
|
|
59
|
+
c1.1,0,2-0.8,2.1-1.8l2.5-16.1c0.2-1.5,1.5-2.6,3.1-2.6h7c14.6,0,23.1-7.1,25.3-21.1c1-6.1,0-11-2.8-14.3
|
|
60
|
+
C899.2,70.9,893.6,68.9,886.1,68.9 M730.2,89.7c-1.2,8-7.3,8-13.2,8h-3.4l2.4-14.9c0.1-0.9,0.9-1.6,1.8-1.6h1.5c4,0,7.8,0,9.7,2.3
|
|
61
|
+
C730.3,84.9,730.7,86.9,730.2,89.7 M727.7,68.9h-22.2c-1.5,0-2.8,1.1-3.1,2.6l-9,56.9c-0.2,1,0.5,2,1.5,2.1c0.1,0,0.2,0,0.3,0h10.6
|
|
62
|
+
c1.5,0,2.8-1.1,3-2.6l2.4-15.4c0.2-1.5,1.5-2.6,3-2.6h7c14.6,0,23.1-7.1,25.3-21.1c1-6.1,0-11-2.8-14.3
|
|
63
|
+
C740.7,70.9,735.1,68.9,727.7,68.9 M779.3,110.2c-1,6.1-5.9,10.2-12,10.2c-3.1,0-5.6-1-7.1-2.9c-1.6-1.9-2.2-4.5-1.7-7.5
|
|
64
|
+
c1-6,5.9-10.2,11.9-10.2c3,0,5.5,1,7.1,2.9C779.1,104.5,779.7,107.2,779.3,110.2 M794.1,89.5h-10.6c-0.9,0-1.7,0.7-1.8,1.6l-0.5,3
|
|
65
|
+
l-0.7-1.1c-2.3-3.3-7.4-4.5-12.6-4.5c-11.8,0-21.8,8.9-23.7,21.4c-1,6.2,0.4,12.2,4,16.3c3.2,3.8,7.9,5.4,13.4,5.4
|
|
66
|
+
c9.5,0,14.7-6.1,14.7-6.1l-0.5,3c-0.2,1,0.5,2,1.5,2.1c0.1,0,0.2,0,0.3,0h9.6c1.5,0,2.8-1.1,3-2.6l5.8-36.4c0.2-1-0.5-2-1.5-2.1
|
|
67
|
+
C794.3,89.5,794.2,89.5,794.1,89.5 M937.7,110.2c-1,6.1-5.9,10.2-12,10.2c-3.1,0-5.6-1-7.1-2.9c-1.6-1.9-2.2-4.5-1.7-7.5
|
|
68
|
+
c1-6,5.9-10.2,11.9-10.2c3,0,5.5,1,7.1,2.9C937.5,104.5,938.2,107.2,937.7,110.2 M952.5,89.5h-10.6c-0.9,0-1.7,0.7-1.8,1.6l-0.5,3
|
|
69
|
+
l-0.7-1.1c-2.3-3.3-7.4-4.5-12.6-4.5c-11.8,0-21.8,8.9-23.7,21.4c-1,6.2,0.4,12.2,4,16.3c3.2,3.8,7.9,5.4,13.4,5.4
|
|
70
|
+
c9.5,0,14.7-6.1,14.7-6.1l-0.5,3c-0.2,1,0.5,2,1.5,2.1c0.1,0,0.2,0,0.3,0h9.6c1.5,0,2.8-1.1,3-2.6l5.8-36.4c0.2-1-0.5-2-1.5-2.1
|
|
71
|
+
C952.7,89.5,952.6,89.5,952.5,89.5 M850.7,89.5H840c-1,0-2,0.5-2.6,1.4l-14.7,21.7l-6.3-20.9c-0.4-1.3-1.6-2.2-3-2.2H803
|
|
72
|
+
c-1,0-1.9,0.8-1.9,1.9c0,0.2,0,0.4,0.1,0.6l11.8,34.5L802,142.1c-0.9,1.2,0,2.9,1.5,2.9h10.7c1,0,2-0.5,2.5-1.3l35.6-51.3
|
|
73
|
+
C853.1,91.1,852.2,89.5,850.7,89.5 M965.1,70.5l-9.1,58c-0.2,1,0.5,2,1.5,2.1c0.1,0,0.2,0,0.3,0h9.2c1.5,0,2.8-1.1,3-2.6l9-56.9
|
|
74
|
+
c0.2-1-0.5-2-1.5-2.1c-0.1,0-0.2,0-0.3,0h-10.3C966,68.9,965.2,69.6,965.1,70.5"/>
|
|
75
|
+
<g>
|
|
76
|
+
<defs>
|
|
77
|
+
<filter id="Adobe_OpacityMaskFilter" filterUnits="userSpaceOnUse" x="575" y="47" width="83.1" height="98">
|
|
78
|
+
<feColorMatrix type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"/>
|
|
79
|
+
</filter>
|
|
80
|
+
</defs>
|
|
81
|
+
<mask maskUnits="userSpaceOnUse" x="575" y="47" width="83.1" height="98" id="e_1_">
|
|
82
|
+
<g class="st2">
|
|
83
|
+
<path id="d_1_" class="st1" d="M575,47h83.1v98H575V47z"/>
|
|
84
|
+
</g>
|
|
85
|
+
</mask>
|
|
86
|
+
<path class="st3" d="M649.9,71.9c1.2-7.6,0-12.8-4.1-17.5c-4.5-5.2-12.7-7.4-23.2-7.4H592c-2.1,0-4,1.6-4.3,3.7L575,131.1
|
|
87
|
+
c-0.2,1.4,0.7,2.8,2.2,3c0.1,0,0.3,0,0.4,0h18.8l-1.3,8.2c-0.2,1.2,0.7,2.4,1.9,2.6c0.1,0,0.2,0,0.4,0h15.9c1.9,0,3.5-1.4,3.8-3.2
|
|
88
|
+
l0.2-0.8l3-18.9l0.2-1c0.3-1.9,1.9-3.2,3.8-3.2h2.4c15.4,0,27.4-6.2,30.9-24.3c1.5-7.5,0.7-13.8-3.2-18.3
|
|
89
|
+
C653,73.9,651.6,72.8,649.9,71.9"/>
|
|
90
|
+
<defs>
|
|
91
|
+
<filter id="Adobe_OpacityMaskFilter_1_" filterUnits="userSpaceOnUse" x="575" y="47" width="75.3" height="87.1">
|
|
92
|
+
<feColorMatrix type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"/>
|
|
93
|
+
</filter>
|
|
94
|
+
</defs>
|
|
95
|
+
<mask maskUnits="userSpaceOnUse" x="575" y="47" width="75.3" height="87.1" id="g_1_">
|
|
96
|
+
<g class="st4">
|
|
97
|
+
<path id="f_1_" class="st1" d="M575,47h75.3v87.1H575V47z"/>
|
|
98
|
+
</g>
|
|
99
|
+
</mask>
|
|
100
|
+
<path class="st5" d="M649.9,71.9c1.2-7.6,0-12.8-4.1-17.5c-4.5-5.2-12.7-7.4-23.2-7.4H592c-2.1,0-4,1.6-4.3,3.7L575,131.1
|
|
101
|
+
c-0.2,1.4,0.7,2.8,2.2,3c0.1,0,0.3,0,0.4,0h18.8l4.7-30l-0.1,0.9c0.3-2.1,2.1-3.7,4.3-3.7h8.9c17.6,0,31.3-7.1,35.3-27.8
|
|
102
|
+
C649.7,73.1,649.8,72.5,649.9,71.9"/>
|
|
103
|
+
<defs>
|
|
104
|
+
<filter id="Adobe_OpacityMaskFilter_2_" filterUnits="userSpaceOnUse" x="575" y="47" width="75.3" height="87.1">
|
|
105
|
+
<feColorMatrix type="matrix" values="1 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 1 0"/>
|
|
106
|
+
</filter>
|
|
107
|
+
</defs>
|
|
108
|
+
<mask maskUnits="userSpaceOnUse" x="575" y="47" width="75.3" height="87.1" id="i_1_">
|
|
109
|
+
<g class="st6">
|
|
110
|
+
<path id="h_1_" class="st1" d="M575,47h75.3v87.1H575V47z"/>
|
|
111
|
+
</g>
|
|
112
|
+
</mask>
|
|
113
|
+
<path class="st7" d="M606.2,72c0.3-1.9,1.9-3.2,3.8-3.2h23.9c2.8,0,5.5,0.2,7.9,0.6c0.7,0.1,1.4,0.2,2,0.4
|
|
114
|
+
c0.9,0.2,1.9,0.5,2.8,0.8c1.1,0.4,2.2,0.8,3.3,1.4c1.2-7.6,0-12.8-4.1-17.5c-4.5-5.2-12.7-7.4-23.2-7.4H592c-2.1,0-4,1.6-4.3,3.7
|
|
115
|
+
L575,131.1c-0.2,1.4,0.7,2.8,2.2,3c0.1,0,0.3,0,0.4,0h18.8l4.7-30L606.2,72L606.2,72z"/>
|
|
116
|
+
</g>
|
|
117
|
+
</g>
|
|
118
|
+
</svg>
|