iobroker.device-watcher 2.8.2 → 2.8.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 +4 -0
- package/io-package.json +847 -827
- package/main.js +20 -17
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -2133,26 +2133,25 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2133
2133
|
|
|
2134
2134
|
/**
|
|
2135
2135
|
* Check if instance is alive
|
|
2136
|
-
* @param {string | number | boolean | null | undefined} isAlive
|
|
2137
2136
|
* @param {any} instanceAlivePath
|
|
2138
2137
|
* @param {number} instanceDeactivationTime
|
|
2139
2138
|
*/
|
|
2140
|
-
async checkIsAlive(
|
|
2141
|
-
|
|
2142
|
-
if (
|
|
2139
|
+
async checkIsAlive(instanceAlivePath, instanceDeactivationTime) {
|
|
2140
|
+
let aliveState = await this.getInitValue(instanceAlivePath);
|
|
2141
|
+
if (aliveState) return true;
|
|
2143
2142
|
|
|
2144
2143
|
await this.delay(instanceDeactivationTime);
|
|
2145
|
-
|
|
2146
|
-
if (!
|
|
2144
|
+
aliveState = await this.getInitValue(instanceAlivePath);
|
|
2145
|
+
if (!aliveState) {
|
|
2147
2146
|
await this.delay(instanceDeactivationTime);
|
|
2148
|
-
|
|
2149
|
-
if (!
|
|
2147
|
+
aliveState = await this.getInitValue(instanceAlivePath);
|
|
2148
|
+
if (!aliveState) {
|
|
2150
2149
|
return false; // if instance is turned off
|
|
2151
2150
|
} else {
|
|
2152
|
-
return
|
|
2151
|
+
return true;
|
|
2153
2152
|
}
|
|
2154
2153
|
} else {
|
|
2155
|
-
return
|
|
2154
|
+
return true;
|
|
2156
2155
|
}
|
|
2157
2156
|
}
|
|
2158
2157
|
|
|
@@ -2196,8 +2195,6 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2196
2195
|
}
|
|
2197
2196
|
break;
|
|
2198
2197
|
case 'daemon':
|
|
2199
|
-
if (isDeviceConnected === undefined) isDeviceConnected = true;
|
|
2200
|
-
|
|
2201
2198
|
if (this.userTimeInstancesList.has(instanceAlivePath)) {
|
|
2202
2199
|
// User set own setting for deactivation time
|
|
2203
2200
|
instanceDeactivationTime = this.userTimeInstancesList.get(instanceAlivePath).deactivationTime;
|
|
@@ -2209,9 +2206,11 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2209
2206
|
}
|
|
2210
2207
|
|
|
2211
2208
|
// if instance was deactivated
|
|
2212
|
-
isAlive = await this.checkIsAlive(
|
|
2209
|
+
isAlive = await this.checkIsAlive(instanceAlivePath, instanceDeactivationTime);
|
|
2213
2210
|
if (!isAlive) return ['Instanz deaktiviert', false, null]; // if instance is turned off
|
|
2214
2211
|
|
|
2212
|
+
if (isDeviceConnected === undefined) isDeviceConnected = true;
|
|
2213
|
+
|
|
2215
2214
|
// if instance has an error
|
|
2216
2215
|
if (isHostConnected && isDeviceConnected) {
|
|
2217
2216
|
// In case of (re)start, connection may take some time. We take 3 attempts.
|
|
@@ -2219,26 +2218,30 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2219
2218
|
isHealthy = true;
|
|
2220
2219
|
instanceStatusString = 'Instanz okay';
|
|
2221
2220
|
} else {
|
|
2222
|
-
// 2/3 - after
|
|
2221
|
+
// 2/3 - after x seconds
|
|
2223
2222
|
await this.delay(instanceErrorTime);
|
|
2224
2223
|
|
|
2225
|
-
isAlive = await this.checkIsAlive(
|
|
2224
|
+
isAlive = await this.checkIsAlive(instanceAlivePath, instanceDeactivationTime);
|
|
2226
2225
|
if (!isAlive) return ['Instanz deaktiviert', false, null]; // if instance is turned off
|
|
2227
2226
|
|
|
2228
2227
|
isDeviceConnected = await this.getInitValue(isDeviceConnctedPath);
|
|
2228
|
+
if (isDeviceConnected === undefined) isDeviceConnected = true;
|
|
2229
|
+
|
|
2229
2230
|
isHostConnected = await this.getInitValue(hostConnectedPath);
|
|
2230
2231
|
|
|
2231
2232
|
if (isHostConnected && isDeviceConnected) {
|
|
2232
2233
|
isHealthy = true;
|
|
2233
2234
|
instanceStatusString = 'Instanz okay';
|
|
2234
2235
|
} else {
|
|
2235
|
-
// 3/3 - after
|
|
2236
|
+
// 3/3 - after x seconds in total or user time setting
|
|
2236
2237
|
await this.delay(instanceErrorTime);
|
|
2237
2238
|
|
|
2238
|
-
isAlive = await this.checkIsAlive(
|
|
2239
|
+
isAlive = await this.checkIsAlive(instanceAlivePath, instanceDeactivationTime);
|
|
2239
2240
|
if (!isAlive) return ['Instanz deaktiviert', false, null]; // if instance is turned off
|
|
2240
2241
|
|
|
2241
2242
|
isDeviceConnected = await this.getInitValue(isDeviceConnctedPath);
|
|
2243
|
+
if (isDeviceConnected === undefined) isDeviceConnected = true;
|
|
2244
|
+
|
|
2242
2245
|
isHostConnected = await this.getInitValue(hostConnectedPath);
|
|
2243
2246
|
|
|
2244
2247
|
if (isHostConnected && isDeviceConnected) {
|