iobroker.device-watcher 2.10.4 → 2.11.0
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 +8 -0
- package/admin/jsonConfig.json5 +19 -0
- package/admin/words.js +87 -84
- package/io-package.json +841 -861
- package/lib/arrApart.js +13 -0
- package/main.js +91 -87
- package/package.json +7 -7
package/lib/arrApart.js
CHANGED
|
@@ -430,6 +430,19 @@ const arrApart = {
|
|
|
430
430
|
reach: '.status',
|
|
431
431
|
isLowBat: 'none',
|
|
432
432
|
},
|
|
433
|
+
ring: {
|
|
434
|
+
Selektor: 'ring.*.latest_signal_strength',
|
|
435
|
+
timeSelector: '.latest_signal_strength',
|
|
436
|
+
adapterID: 'ring',
|
|
437
|
+
adapter: 'Ring',
|
|
438
|
+
rssiState: '.latest_signal_strength',
|
|
439
|
+
battery: '.battery_percentage',
|
|
440
|
+
charger: '.external_connection',
|
|
441
|
+
reach: 'none',
|
|
442
|
+
isLowBat: 'none',
|
|
443
|
+
id: 'none',
|
|
444
|
+
upgrade: '.firmware',
|
|
445
|
+
},
|
|
433
446
|
roomba: {
|
|
434
447
|
Selektor: 'roomba.*.signal',
|
|
435
448
|
timeSelector: '.signal',
|
package/main.js
CHANGED
|
@@ -151,6 +151,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
151
151
|
nut: this.config.nutDevices,
|
|
152
152
|
ping: this.config.pingDevices,
|
|
153
153
|
proxmox: this.config.proxmoxDevices,
|
|
154
|
+
ring: this.config.ringDevices,
|
|
154
155
|
roomba: this.config.roombaDevices,
|
|
155
156
|
shelly: this.config.shellyDevices,
|
|
156
157
|
smartgarden: this.config.smartgardenDevices,
|
|
@@ -212,6 +213,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
212
213
|
nut: this.config.nutMaxMinutes,
|
|
213
214
|
ping: this.config.pingMaxMinutes,
|
|
214
215
|
proxmox: this.config.proxmoxMaxMinutes,
|
|
216
|
+
ring: this.config.ringMaxMinutes,
|
|
215
217
|
roomba: this.config.roombaMaxMinutes,
|
|
216
218
|
shelly: this.config.shellyMaxMinutes,
|
|
217
219
|
smartgarden: this.config.smartgardenMaxMinutes,
|
|
@@ -997,6 +999,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
997
999
|
case 'loqedSmartLock':
|
|
998
1000
|
case 'viessmann':
|
|
999
1001
|
case 'homekitController':
|
|
1002
|
+
case 'ring':
|
|
1000
1003
|
if (shortDeviceObject && typeof shortDeviceObject === 'object' && shortDeviceObject.common) {
|
|
1001
1004
|
deviceName = shortDeviceObject.common.name;
|
|
1002
1005
|
}
|
|
@@ -1138,41 +1141,44 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1138
1141
|
let batteryHealthRaw;
|
|
1139
1142
|
let batteryHealthUnitRaw;
|
|
1140
1143
|
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
if (
|
|
1144
|
-
|
|
1145
|
-
isBatteryDevice = true;
|
|
1146
|
-
} else if (deviceLowBatState !== undefined && deviceLowBatState !== 1) {
|
|
1147
|
-
batteryHealth = 'ok';
|
|
1148
|
-
isBatteryDevice = true;
|
|
1149
|
-
} else if (deviceLowBatState !== undefined) {
|
|
1150
|
-
batteryHealth = 'low';
|
|
1151
|
-
isBatteryDevice = true;
|
|
1152
|
-
}
|
|
1153
|
-
} else if (deviceBatteryState !== 0 && deviceBatteryState < 6) {
|
|
1154
|
-
batteryHealth = `${deviceBatteryState}V`;
|
|
1155
|
-
batteryHealthRaw = deviceBatteryState;
|
|
1156
|
-
batteryHealthUnitRaw = 'V';
|
|
1157
|
-
isBatteryDevice = true;
|
|
1158
|
-
}
|
|
1159
|
-
} else {
|
|
1160
|
-
if (deviceBatteryState === undefined) {
|
|
1161
|
-
if (deviceLowBatState !== undefined) {
|
|
1162
|
-
if (deviceLowBatState !== true && deviceLowBatState !== 'NORMAL' && deviceLowBatState !== 1) {
|
|
1144
|
+
switch (adapterID) {
|
|
1145
|
+
case 'hmrpc':
|
|
1146
|
+
if (deviceBatteryState === undefined) {
|
|
1147
|
+
if (faultReportingState !== undefined && faultReportingState !== 6) {
|
|
1163
1148
|
batteryHealth = 'ok';
|
|
1164
1149
|
isBatteryDevice = true;
|
|
1165
|
-
} else if (deviceLowBatState !==
|
|
1150
|
+
} else if (deviceLowBatState !== undefined && deviceLowBatState !== 1) {
|
|
1151
|
+
batteryHealth = 'ok';
|
|
1152
|
+
isBatteryDevice = true;
|
|
1153
|
+
} else if (deviceLowBatState !== undefined) {
|
|
1166
1154
|
batteryHealth = 'low';
|
|
1167
1155
|
isBatteryDevice = true;
|
|
1168
1156
|
}
|
|
1157
|
+
} else if (deviceBatteryState !== 0 && deviceBatteryState < 6) {
|
|
1158
|
+
batteryHealth = `${deviceBatteryState}V`;
|
|
1159
|
+
batteryHealthRaw = deviceBatteryState;
|
|
1160
|
+
batteryHealthUnitRaw = 'V';
|
|
1161
|
+
isBatteryDevice = true;
|
|
1169
1162
|
}
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1163
|
+
break;
|
|
1164
|
+
default:
|
|
1165
|
+
if (deviceBatteryState === undefined) {
|
|
1166
|
+
if (deviceLowBatState !== undefined) {
|
|
1167
|
+
if (deviceLowBatState !== true && deviceLowBatState !== 'NORMAL' && deviceLowBatState !== 1) {
|
|
1168
|
+
batteryHealth = 'ok';
|
|
1169
|
+
isBatteryDevice = true;
|
|
1170
|
+
} else if (deviceLowBatState !== true) {
|
|
1171
|
+
batteryHealth = 'low';
|
|
1172
|
+
isBatteryDevice = true;
|
|
1173
|
+
}
|
|
1174
|
+
}
|
|
1175
|
+
} else {
|
|
1176
|
+
batteryHealth = `${deviceBatteryState}%`;
|
|
1177
|
+
batteryHealthRaw = deviceBatteryState;
|
|
1178
|
+
batteryHealthUnitRaw = '%';
|
|
1179
|
+
isBatteryDevice = true;
|
|
1180
|
+
}
|
|
1181
|
+
break;
|
|
1176
1182
|
}
|
|
1177
1183
|
|
|
1178
1184
|
return [batteryHealth, isBatteryDevice, batteryHealthRaw, batteryHealthUnitRaw];
|
|
@@ -1459,6 +1465,13 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
1459
1465
|
isUpgradable = false;
|
|
1460
1466
|
}
|
|
1461
1467
|
break;
|
|
1468
|
+
case 'ring':
|
|
1469
|
+
if (deviceUpdateSelector !== 'Up to Date') {
|
|
1470
|
+
isUpgradable = true;
|
|
1471
|
+
} else {
|
|
1472
|
+
isUpgradable = false;
|
|
1473
|
+
}
|
|
1474
|
+
break;
|
|
1462
1475
|
default:
|
|
1463
1476
|
if (deviceUpdateSelector !== null && typeof deviceUpdateSelector === 'boolean') {
|
|
1464
1477
|
if (deviceUpdateSelector) {
|
|
@@ -2109,7 +2122,6 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2109
2122
|
isConnectedHost: instanceConnectedHostVal,
|
|
2110
2123
|
isConnectedDevice: instanceConnectedDeviceVal,
|
|
2111
2124
|
status: instanceStatus,
|
|
2112
|
-
checkIsRunning: false,
|
|
2113
2125
|
aliveDP: `system.adapter.${instanceID}.alive`,
|
|
2114
2126
|
hostConnectionDP: instanceConnectedHostDP,
|
|
2115
2127
|
deviceConnectionDP: instanceConnectedDeviceDP,
|
|
@@ -2141,7 +2153,6 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2141
2153
|
const connectedHostState = await this.getInitValue(`system.adapter.${instanceID}.connected`);
|
|
2142
2154
|
const isAlive = await this.getInitValue(`system.adapter.${instanceID}.alive`);
|
|
2143
2155
|
let connectedDeviceState = await this.getInitValue(`${instanceID}.info.connection`);
|
|
2144
|
-
|
|
2145
2156
|
if (connectedDeviceState === undefined) {
|
|
2146
2157
|
connectedDeviceState = true;
|
|
2147
2158
|
}
|
|
@@ -2160,7 +2171,7 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2160
2171
|
}
|
|
2161
2172
|
}
|
|
2162
2173
|
|
|
2163
|
-
return [Boolean(isAlive), Boolean(isHealthy), String(instanceStatusString)];
|
|
2174
|
+
return [Boolean(isAlive), Boolean(isHealthy), String(instanceStatusString), Boolean(connectedHostState), Boolean(connectedDeviceState)];
|
|
2164
2175
|
}
|
|
2165
2176
|
|
|
2166
2177
|
/**
|
|
@@ -2188,8 +2199,10 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2188
2199
|
isAlive = Boolean(daemonIsAlive[0]);
|
|
2189
2200
|
isHealthy = Boolean(daemonIsAlive[1]);
|
|
2190
2201
|
instanceStatusString = String(daemonIsAlive[2]);
|
|
2202
|
+
const connectedToHost = Boolean(daemonIsAlive[3]);
|
|
2203
|
+
const connectedToDevice = Boolean(daemonIsAlive[4]);
|
|
2191
2204
|
|
|
2192
|
-
return [isAlive, isHealthy, instanceStatusString];
|
|
2205
|
+
return [isAlive, isHealthy, instanceStatusString, connectedToHost, connectedToDevice];
|
|
2193
2206
|
}
|
|
2194
2207
|
|
|
2195
2208
|
async checkScheduleisHealty(instanceID, scheduleTime) {
|
|
@@ -2229,52 +2242,21 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2229
2242
|
async setInstanceStatus(instanceMode, scheduleTime, instanceID) {
|
|
2230
2243
|
let instanceDeactivationTime = (this.config.offlineTimeInstances * 1000) / 2;
|
|
2231
2244
|
let instanceErrorTime = (this.config.errorTimeInstances * 1000) / 2;
|
|
2232
|
-
|
|
2233
|
-
|
|
2234
|
-
|
|
2235
|
-
|
|
2236
|
-
|
|
2237
|
-
|
|
2238
|
-
|
|
2239
|
-
|
|
2240
|
-
};
|
|
2241
|
-
|
|
2242
|
-
const checkDaemonIsHealthy = async () => {
|
|
2243
|
-
const daemonIsAlive = await this.checkDaemonIsHealthy(instanceID);
|
|
2244
|
-
|
|
2245
|
-
if (daemonIsAlive[0] && !daemonIsAlive[1]) {
|
|
2246
|
-
await this.delay(instanceErrorTime);
|
|
2247
|
-
const daemonIsAliveAfterDelay = await this.checkDaemonIsHealthy(instanceID);
|
|
2248
|
-
|
|
2249
|
-
if (daemonIsAliveAfterDelay[0] && !daemonIsAliveAfterDelay[1]) {
|
|
2250
|
-
await this.delay(instanceErrorTime);
|
|
2251
|
-
const daemonIsAliveAfterSecondDelay = await this.checkDaemonIsHealthy(instanceID);
|
|
2252
|
-
|
|
2253
|
-
if (daemonIsAliveAfterSecondDelay[0] && !daemonIsAliveAfterSecondDelay[1]) {
|
|
2254
|
-
return {
|
|
2255
|
-
isAlive: Boolean(daemonIsAliveAfterSecondDelay[0]),
|
|
2256
|
-
isHealthy: Boolean(daemonIsAliveAfterSecondDelay[1]),
|
|
2257
|
-
instanceStatusString: String(daemonIsAliveAfterSecondDelay[2]),
|
|
2258
|
-
};
|
|
2259
|
-
}
|
|
2260
|
-
}
|
|
2261
|
-
}
|
|
2262
|
-
|
|
2263
|
-
const daemonIsNotAlive = await this.checkDaemonIsAlive(instanceID, instanceDeactivationTime);
|
|
2264
|
-
return {
|
|
2265
|
-
isAlive: Boolean(daemonIsNotAlive[0]),
|
|
2266
|
-
isHealthy: Boolean(daemonIsNotAlive[1]),
|
|
2267
|
-
instanceStatusString: String(daemonIsNotAlive[2]),
|
|
2268
|
-
};
|
|
2269
|
-
};
|
|
2270
|
-
|
|
2271
|
-
let isAlive = false;
|
|
2272
|
-
let isHealthy = false;
|
|
2273
|
-
let instanceStatusString = translations.instance_deactivated[this.config.userSelectedLanguage];
|
|
2245
|
+
let isAlive;
|
|
2246
|
+
let isHealthy;
|
|
2247
|
+
let instanceStatusString;
|
|
2248
|
+
let daemonIsAlive;
|
|
2249
|
+
let daemonIsNotAlive;
|
|
2250
|
+
let scheduleIsAlive;
|
|
2251
|
+
let connectedToHost;
|
|
2252
|
+
let connectedToDevice;
|
|
2274
2253
|
|
|
2275
2254
|
switch (instanceMode) {
|
|
2276
2255
|
case 'schedule':
|
|
2277
|
-
|
|
2256
|
+
scheduleIsAlive = await this.checkScheduleisHealty(instanceID, scheduleTime);
|
|
2257
|
+
isAlive = Boolean(scheduleIsAlive[0]);
|
|
2258
|
+
isHealthy = Boolean(scheduleIsAlive[1]);
|
|
2259
|
+
instanceStatusString = String(scheduleIsAlive[2]);
|
|
2278
2260
|
break;
|
|
2279
2261
|
case 'daemon':
|
|
2280
2262
|
// check with time the user did define for error and deactivation
|
|
@@ -2283,12 +2265,36 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2283
2265
|
instanceDeactivationTime = (userTimeInstances.deactivationTime * 1000) / 2;
|
|
2284
2266
|
instanceErrorTime = (userTimeInstances.errorTime * 1000) / 2;
|
|
2285
2267
|
}
|
|
2268
|
+
daemonIsAlive = await this.checkDaemonIsHealthy(instanceID);
|
|
2269
|
+
if (daemonIsAlive[0] && !daemonIsAlive[1]) {
|
|
2270
|
+
await this.delay(instanceErrorTime);
|
|
2271
|
+
const daemonIsAliveAfterDelay = await this.checkDaemonIsHealthy(instanceID);
|
|
2272
|
+
|
|
2273
|
+
if (daemonIsAliveAfterDelay[0] && !daemonIsAliveAfterDelay[1]) {
|
|
2274
|
+
await this.delay(instanceErrorTime);
|
|
2275
|
+
const daemonIsAliveAfterSecondDelay = await this.checkDaemonIsHealthy(instanceID);
|
|
2276
|
+
|
|
2277
|
+
if (daemonIsAliveAfterSecondDelay[0] && !daemonIsAliveAfterSecondDelay[1]) {
|
|
2278
|
+
isAlive = Boolean(daemonIsAliveAfterSecondDelay[0]);
|
|
2279
|
+
isHealthy = Boolean(daemonIsAliveAfterSecondDelay[1]);
|
|
2280
|
+
instanceStatusString = String(daemonIsAliveAfterSecondDelay[2]);
|
|
2281
|
+
connectedToHost = Boolean(daemonIsAliveAfterSecondDelay[3]);
|
|
2282
|
+
connectedToDevice = Boolean(daemonIsAliveAfterSecondDelay[4]);
|
|
2283
|
+
}
|
|
2284
|
+
}
|
|
2285
|
+
} else {
|
|
2286
|
+
daemonIsNotAlive = await this.checkDaemonIsAlive(instanceID, instanceDeactivationTime);
|
|
2287
|
+
isAlive = Boolean(daemonIsNotAlive[0]);
|
|
2288
|
+
isHealthy = Boolean(daemonIsNotAlive[1]);
|
|
2289
|
+
instanceStatusString = String(daemonIsNotAlive[2]);
|
|
2290
|
+
connectedToHost = Boolean(daemonIsNotAlive[3]);
|
|
2291
|
+
connectedToDevice = Boolean(daemonIsNotAlive[4]);
|
|
2292
|
+
}
|
|
2286
2293
|
|
|
2287
|
-
({ isAlive, isHealthy, instanceStatusString } = await checkDaemonIsHealthy());
|
|
2288
2294
|
break;
|
|
2289
2295
|
}
|
|
2290
2296
|
|
|
2291
|
-
return [isAlive, isHealthy, instanceStatusString];
|
|
2297
|
+
return [isAlive, isHealthy, instanceStatusString, connectedToHost, connectedToDevice];
|
|
2292
2298
|
}
|
|
2293
2299
|
|
|
2294
2300
|
/**
|
|
@@ -2530,15 +2536,13 @@ class DeviceWatcher extends utils.Adapter {
|
|
|
2530
2536
|
let instanceStatusRaw;
|
|
2531
2537
|
|
|
2532
2538
|
const checkInstance = async (instanceID, instanceData) => {
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
return;
|
|
2541
|
-
}
|
|
2539
|
+
instanceStatusRaw = await this.setInstanceStatus(instanceData.instanceMode, instanceData.schedule, instanceID);
|
|
2540
|
+
instanceData.isAlive = instanceStatusRaw[0];
|
|
2541
|
+
instanceData.isHealthy = instanceStatusRaw[1];
|
|
2542
|
+
instanceData.status = instanceStatusRaw[2];
|
|
2543
|
+
instanceData.isConnectedHost = instanceStatusRaw[3];
|
|
2544
|
+
instanceData.isConnectedDevice = instanceStatusRaw[4];
|
|
2545
|
+
return;
|
|
2542
2546
|
};
|
|
2543
2547
|
|
|
2544
2548
|
switch (id) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "iobroker.device-watcher",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.0",
|
|
4
4
|
"description": "Watchdog for devices",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Christian Behrends",
|
|
@@ -37,22 +37,22 @@
|
|
|
37
37
|
"@types/chai": "^4.3.11",
|
|
38
38
|
"@types/chai-as-promised": "^7.1.8",
|
|
39
39
|
"@types/mocha": "^10.0.6",
|
|
40
|
-
"@types/node": "^20.11.
|
|
41
|
-
"@types/node-schedule": "^2.1.
|
|
40
|
+
"@types/node": "^20.11.24",
|
|
41
|
+
"@types/node-schedule": "^2.1.6",
|
|
42
42
|
"@types/proxyquire": "^1.3.31",
|
|
43
43
|
"@types/sinon": "^17.0.3",
|
|
44
44
|
"@types/sinon-chai": "^3.2.12",
|
|
45
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^7.0.0",
|
|
46
46
|
"@typescript-eslint/parser": "^6.20.0",
|
|
47
47
|
"chai": "^4.4.1",
|
|
48
48
|
"chai-as-promised": "^7.1.1",
|
|
49
49
|
"cron-parser": "^4.9.0",
|
|
50
|
-
"eslint": "^8.
|
|
50
|
+
"eslint": "^8.57.0",
|
|
51
51
|
"eslint-config-prettier": "^9.1.0",
|
|
52
52
|
"eslint-plugin-prettier": "^5.1.3",
|
|
53
|
-
"mocha": "^10.
|
|
53
|
+
"mocha": "^10.3.0",
|
|
54
54
|
"node-schedule": "^2.1.1",
|
|
55
|
-
"prettier": "^3.2.
|
|
55
|
+
"prettier": "^3.2.5",
|
|
56
56
|
"proxyquire": "^2.1.3",
|
|
57
57
|
"sinon": "^17.0.1",
|
|
58
58
|
"sinon-chai": "^3.7.0",
|