New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

iobroker.device-watcher

Package Overview
Dependencies
Maintainers
2
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

iobroker.device-watcher - npm Package Compare versions

Comparing version 2.0.0 to 2.0.1

27

io-package.json
{
"common": {
"name": "device-watcher",
"version": "2.0.0",
"version": "2.0.1",
"news": {
"2.0.1": {
"en": "If the device is offline, set signal strength to '0%'\nIf the device is offline, set battery to ' - '\nrepair some small issues in the lists",
"de": "Ist das Gerät offline, setzen Sie Signalstärke auf 0%\nWenn das Gerät offline ist, setzen Sie Batterie auf ' - '\neinige kleine probleme in den listen reparieren",
"ru": "Если устройство оффлайн, установите силу сигнала до 0%\nЕсли устройство оффлайн, установите аккумулятор в ' - '\nотремонтировать некоторые небольшие проблемы в списках",
"pt": "Se o dispositivo estiver offline, defina a força do sinal para 0%\nSe o dispositivo estiver offline, configure a bateria para ' - '\nreparar alguns pequenos problemas nas listas",
"nl": "Als het apparaat offline is, zet een signaalstilstand op 0%\nAls het apparaat offline is, zet dan batterij op '\nrepareer wat kleine kwesties in de lijst",
"fr": "Si l'appareil est hors ligne, définir la résistance du signal à 0%\nSi l'appareil est hors ligne, régler la batterie à ' - '\nréparer quelques petits problèmes dans les listes",
"it": "Se il dispositivo è offline, impostare la forza del segnale a 0%\nSe il dispositivo è offline, impostare la batteria a ' - '\nriparare alcuni piccoli problemi nelle liste",
"es": "Si el dispositivo está fuera de línea, establece la fuerza de señal al 0%\nSi el dispositivo está fuera de línea, establece la batería a ' - '\nreparar algunas pequeñas cuestiones en las listas",
"pl": "Jeśli urządzenie jest offline, ustawia siłę sygnału do 0%\nJeśli urządzenie jest wycinane, ustawiono baterię do '- '\nwyremontowano drobne problemy w listach",
"uk": "Якщо пристрій вимкнено, встановлюється міцність сигналу на 0%\nЯкщо пристрій вимкнено, встановіть акумулятор до ' - '\nремонт деяких невеликих питань у переліках",
"zh-cn": "如果装置落空,信号强度达到0%\n如果装置不线,便将电池到该地。\n在名单中修理一些小型问题"
},
"2.0.0": {

@@ -78,14 +91,2 @@ "en": "added Lupusec, HS100 adapter, Zigbee2MQTT and MaxCube\nchanged name of Homematic to HM-RPC\nmade a completly makeover of the blacklist\nclean up the code and shorten some",

"zh-cn": "守则、评论和错误处理的许多变化"
},
"0.2.3": {
"en": "many changes of code, comments and error handling",
"de": "viele änderungen von code, kommentaren und fehlerbehandlung",
"ru": "много изменений кода, комментариев и обработки ошибок",
"pt": "muitas mudanças de código, comentários e manipulação de erros",
"nl": "veel veranderingen van code, commentaar en fouten",
"fr": "de nombreux changements de code, de commentaires et de traitement des erreurs",
"it": "molte modifiche di codice, commenti e gestione degli errori",
"es": "muchos cambios de código, comentarios y manejo de errores",
"pl": "wiele zmian kodu, komentarzy i obsługi błędów",
"zh-cn": "守则、评论和错误处理的许多变化"
}

@@ -92,0 +93,0 @@ },

@@ -541,35 +541,27 @@ /* jshint -W097 */

const devices = await this.getForeignStatesAsync(this.arrDev[i].Selektor);
const deviceAdapterName = await this.capitalize(this.arrDev[i].adapter);
const adapterID = this.arrDev[i].adapter;
/*---------- Start of second main loop ----------*/
/*---------- Start of loop ----------*/
for (const [id] of Object.entries(devices)) {
if (!isUnloaded) {
/*=============================================
= Get device name =
=============================================*/
const deviceName = await this.getDeviceName(id, i);
const deviceName = await this.getDeviceName(id, i);
/*=============================================
= Get path to datapoints =
=============================================*/
const currDeviceString = id.slice(0, (id.lastIndexOf('.') + 1) - 1);
const shortCurrDeviceString = currDeviceString.slice(0, (currDeviceString.lastIndexOf('.') + 1) - 1);
// Get battery states
const deviceBatteryState = await this.getInitValue(currDeviceString + this.arrDev[i].battery);
const shortDeviceBatteryState = await this.getInitValue(shortCurrDeviceString + this.arrDev[i].battery);
const shortDeviceBatteryState2 = await this.getInitValue(shortCurrDeviceString + this.arrDev[i].battery2);
//this.devices[deviceName] = currDeviceString + this.arrDev[i].reach;
/*for (const [value] of Object.entries(this.devices)) {
this.log.warn(`${value}`);
this.subscribeForeignStatesAsync(value);
}*/
//this.subscribeForeignStatesAsync(currDeviceString + this.arrDev[i].reach);
// <--- END TEST
// Get link quality
/*=============================================
= Get signal strength =
=============================================*/
let deviceQualityState;
let linkQuality;
switch (this.arrDev[i].adapter) {
switch (adapterID) {
case 'mihomeVacuum':

@@ -597,3 +589,3 @@ deviceQualityState = await this.getForeignStateAsync(shortCurrDeviceString + this.arrDev[i].rssiState);

} else {
switch (this.arrDev[i].adapter) {
switch (adapterID) {
case 'roomba':

@@ -623,3 +615,3 @@ case 'sonoff':

case 'string':
switch (this.arrDev[i].adapter) {
switch (adapterID) {
case 'netatmo':

@@ -639,6 +631,92 @@ // for Netatmo devices

// When was the last contact to the device?
/*=============================================
= Get battery data =
=============================================*/
let batteryHealth;
let lowBatIndicator;
// Get battery states
const deviceBatteryState = await this.getInitValue(currDeviceString + this.arrDev[i].battery);
const shortDeviceBatteryState = await this.getInitValue(shortCurrDeviceString + this.arrDev[i].battery);
const shortDeviceBatteryState2 = await this.getInitValue(shortCurrDeviceString + this.arrDev[i].battery2);
// Get low bat states
let deviceLowBatState = await this.getInitValue(currDeviceString + this.arrDev[i].isLowBat);
if (deviceLowBatState === undefined) {
deviceLowBatState = await this.getInitValue(currDeviceString + this.arrDev[i].isLowBat2);
}
if ((!deviceBatteryState) && (!shortDeviceBatteryState) && (!shortDeviceBatteryState2)) {
if (deviceLowBatState !== undefined) {
switch (this.arrDev[i].isLowBat || this.arrDev[i].isLowBat2) {
case 'none':
batteryHealth = ' - ';
break;
default:
if ((deviceLowBatState === false) || (deviceLowBatState === 'NORMAL') || (deviceLowBatState === 1)) {
batteryHealth = 'ok';
} else {
batteryHealth = 'low';
}
break;
}
} else {
batteryHealth = ' - ';
}
} else {
switch (adapterID) {
case 'hmrpc':
if (deviceBatteryState === 0) {
batteryHealth = ' - ';
} else {
batteryHealth = deviceBatteryState + 'V';
}
break;
case 'hue-extended':
if (shortDeviceBatteryState) {
batteryHealth = shortDeviceBatteryState + '%';
}
break;
case 'mihomeVacuum':
if (shortDeviceBatteryState) {
batteryHealth = shortDeviceBatteryState + '%';
} else if (shortDeviceBatteryState2) {
batteryHealth = shortDeviceBatteryState2 + '%';
}
break;
default:
batteryHealth = (deviceBatteryState) + '%';
}
}
/*=============================================
= Set Lowbat indicator =
=============================================*/
switch (adapterID) {
case 'hmrpc': // there are differnt low bat states between hm and hmIp devices
if (deviceLowBatState) {
lowBatIndicator = true;
}
break;
case 'tado': // there is an string as indicator
if (deviceLowBatState != 'NORMAL') {
lowBatIndicator = true;
}
break;
default: // for all other devices with low bat states
if ((deviceLowBatState === true) || (deviceLowBatState === 0)) {
lowBatIndicator = true;
} else if (deviceBatteryState && (deviceBatteryState < this.config.minWarnBatterie)) { // if the battery state is under the set limit
lowBatIndicator = true;
}
}
/*=============================================
= Get last contact of device =
=============================================*/
let lastContactString;
let lastDeviceUnreachStateChange;
let deviceState = 'Online';
let lastDeviceUnreachStateChange;

@@ -689,3 +767,3 @@ const deviceMainSelector = await this.getForeignStateAsync(id);

//State changed
if (this.arrDev[i].adapter === 'hmrpc') {
if (adapterID === 'hmrpc') {
if (linkQuality != ' - ') {

@@ -726,3 +804,2 @@ if (deviceUnreachState) {

}
} else {

@@ -738,4 +815,5 @@ if (!deviceUnreachState) {

const adapterID = this.arrDev[i].adapter;
/*=============================================
= Set Online Status =
=============================================*/
switch (adapterID) {

@@ -748,5 +826,9 @@ case 'hmrpc':

deviceState = 'Offline'; //set online state to offline
linkQuality = '0%'; // set linkQuality to nothing
batteryHealth = ' - '; // set batteryhelth to nothing
}
} else if ((this.maxMinutes !== undefined) && (lastContact > this.maxMinutes[adapterID])) {
deviceState = 'Offline'; //set online state to offline
linkQuality = '0%'; // set linkQuality to nothing
batteryHealth = ' - '; // set batteryhelth to nothing
}

@@ -758,5 +840,9 @@ break;

deviceState = 'Offline'; //set online state to offline
linkQuality = '0%'; // set linkQuality to nothing
batteryHealth = ' - '; // set batteryhelth to nothing
}
} else if ((this.maxMinutes !== undefined) && (lastContact > this.maxMinutes[adapterID]) && (!deviceUnreachState)) {
deviceState = 'Offline'; //set online state to offline
linkQuality = '0%'; // set linkQuality to nothing
batteryHealth = ' - '; // set batteryhelth to nothing
}

@@ -768,6 +854,9 @@ break;

deviceState = 'Offline'; //set online state to offline
linkQuality = '0%'; // set linkQuality to nothing
batteryHealth = ' - '; // set batteryhelth to nothing
}
} else if ((this.maxMinutes !== undefined) && (lastContact > this.maxMinutes[adapterID])) {
deviceState = 'Offline'; //set online state to offline
linkQuality = '0%'; // set linkQuality to nothing
batteryHealth = ' - '; // set batteryhelth to nothing
}

@@ -780,5 +869,9 @@ break;

deviceState = 'Offline'; //set online state to offline
linkQuality = '0%'; // set linkQuality to nothing
batteryHealth = ' - '; // set batteryhelth to nothing
}
} else if ((!deviceUnreachState) && (typeof lastDeviceUnreachStateChange !== 'undefined') && (this.maxMinutes !== undefined) && (lastContact > this.maxMinutes[adapterID])) {
deviceState = 'Offline'; //set online state to offline
linkQuality = '0%'; // set linkQuality to nothing
batteryHealth = ' - '; // set batteryhelth to nothing
}

@@ -790,5 +883,9 @@ break;

deviceState = 'Offline'; //set online state to offline
linkQuality = '0%'; // set linkQuality to nothing
batteryHealth = ' - '; // set batteryhelth to nothing
}
} else if ((this.maxMinutes !== undefined) && (lastContact > this.maxMinutes[adapterID])) {
deviceState = 'Offline'; //set online state to offline
linkQuality = '0%'; // set linkQuality to nothing
batteryHealth = ' - '; // set batteryhelth to nothing
}

@@ -801,5 +898,9 @@ break;

deviceState = 'Offline'; //set online state to offline
linkQuality = '0%'; // set linkQuality to nothing
batteryHealth = ' - '; // set batteryhelth to nothing
}
} else if ((this.maxMinutes !== undefined) && (lastContact > this.maxMinutes[adapterID])) {
deviceState = 'Offline'; //set online state to offline
linkQuality = '0%'; // set linkQuality to nothing
batteryHealth = ' - '; // set batteryhelth to nothing
}

@@ -810,5 +911,9 @@ } else {

deviceState = 'Offline'; //set online state to offline
linkQuality = '0%'; // set linkQuality to nothing
batteryHealth = ' - '; // set batteryhelth to nothing
}
} else if ((this.maxMinutes !== undefined) && (lastContact > this.maxMinutes[adapterID])) {
deviceState = 'Offline'; //set online state to offline
linkQuality = '0%'; // set linkQuality to nothing
batteryHealth = ' - '; // set batteryhelth to nothing
}

@@ -821,5 +926,9 @@ }

deviceState = 'Offline'; //set online state to offline
linkQuality = '0%'; // set linkQuality to nothing
batteryHealth = ' - '; // set batteryhelth to nothing
}
} else if ((this.maxMinutes !== undefined) && (lastContact > this.maxMinutes[adapterID])) {
deviceState = 'Offline'; //set online state to offline
linkQuality = '0%'; // set linkQuality to nothing
batteryHealth = ' - '; // set batteryhelth to nothing
}

@@ -833,75 +942,8 @@ break;

// Get battery states
let batteryHealth;
let lowBatIndicator;
let deviceLowBatState = await this.getInitValue(currDeviceString + this.arrDev[i].isLowBat);
if (deviceLowBatState === undefined) {
deviceLowBatState = await this.getInitValue(currDeviceString + this.arrDev[i].isLowBat2);
}
/*=============================================
= Fill Raw Lists =
=============================================*/
if ((!deviceBatteryState) && (!shortDeviceBatteryState) && (!shortDeviceBatteryState2)) {
if (deviceLowBatState !== undefined) {
switch (this.arrDev[i].isLowBat || this.arrDev[i].isLowBat2) {
case 'none':
batteryHealth = ' - ';
break;
default:
if ((deviceLowBatState === false) || (deviceLowBatState === 'NORMAL') || (deviceLowBatState === 1)) {
batteryHealth = 'ok';
} else {
batteryHealth = 'low';
}
break;
}
} else {
batteryHealth = ' - ';
}
} else {
switch (this.arrDev[i].adapter) {
case 'hmrpc':
if (deviceBatteryState === 0) {
batteryHealth = ' - ';
} else {
batteryHealth = deviceBatteryState + 'V';
}
break;
case 'hue-extended':
if (shortDeviceBatteryState) {
batteryHealth = shortDeviceBatteryState + '%';
}
break;
case 'mihomeVacuum':
if (shortDeviceBatteryState) {
batteryHealth = shortDeviceBatteryState + '%';
} else if (shortDeviceBatteryState2) {
batteryHealth = shortDeviceBatteryState2 + '%';
}
break;
default:
batteryHealth = (deviceBatteryState) + '%';
}
}
// fill list with low battery devices
switch (this.arrDev[i].adapter) {
case 'hmrpc': // there are differnt low bat states between hm and hmIp devices
if (deviceLowBatState) {
lowBatIndicator = true;
}
break;
case 'tado': // there is an string as indicator
if (deviceLowBatState != 'NORMAL') {
lowBatIndicator = true;
}
break;
default: // for all other devices with low bat states
if ((deviceLowBatState === true) || (deviceLowBatState === 0)) {
lowBatIndicator = true;
} else if (deviceBatteryState && (deviceBatteryState < this.config.minWarnBatterie)) { // if the battery state is under the set limit
lowBatIndicator = true;
}
}
if (this.listOnlyBattery) { // Add only devices with battery in the list
/* Add only devices with battery in the rawlist */
if (this.listOnlyBattery) {
if (deviceBatteryState || shortDeviceBatteryState) {

@@ -912,3 +954,3 @@ this.listAllDevicesRaw.push(

'Device': deviceName,
'Adapter': deviceAdapterName,
'Adapter': await this.capitalize(adapterID),
'Battery': batteryHealth,

@@ -922,3 +964,4 @@ 'LowBat': lowBatIndicator,

}
} else { // Add all devices
} else {
/* Add all devices */
this.listAllDevicesRaw.push(

@@ -928,3 +971,3 @@ {

'Device': deviceName,
'Adapter': deviceAdapterName,
'Adapter': await this.capitalize(adapterID),
'Battery': batteryHealth,

@@ -939,3 +982,4 @@ 'LowBat': lowBatIndicator,

} else {
return; // cancel run if unloaded was called.
/* cancel run if unloaded was called. */
return;
}

@@ -955,2 +999,4 @@ } // <-- end of loop

await this.resetVars(); // reset the arrays and counts
try {

@@ -963,4 +1009,4 @@ for (let i = 0; i < this.arrDev.length; i++) {

}
await this.writeDatapoints(adptName); // fill the datapoints
await this.resetVars(); // reset the arrays and counts

@@ -967,0 +1013,0 @@ } catch (error) {

{
"name": "iobroker.device-watcher",
"version": "2.0.0",
"version": "2.0.1",
"description": "Watchdog for devices",

@@ -5,0 +5,0 @@ "author": {

@@ -11,3 +11,3 @@ ![Logo](admin/device-watcher.png)

![GitHub commit activity](https://img.shields.io/github/commit-activity/m/ciddi89/ioBroker.device-watcher)
![GitHub commits since tagged version (branch)](https://img.shields.io/github/commits-since/ciddi89/ioBroker.device-watcher/v2.0.0)
![GitHub commits since tagged version (branch)](https://img.shields.io/github/commits-since/ciddi89/ioBroker.device-watcher/v2.0.1)
![GitHub last commit](https://img.shields.io/github/last-commit/ciddi89/ioBroker.device-watcher)

@@ -102,3 +102,2 @@ ![GitHub issues](https://img.shields.io/github/issues/ciddi89/ioBroker.device-watcher)

## To-Do
- make blacklist more user-friendly
- clean up the code

@@ -113,2 +112,7 @@ - add support for reaction on state-changes

-->
### 2.0.1 (2022-11-02)
- If the device is offline, set signal strength to '0%'
- If the device is offline, set battery to ' - '
- repair some small issues in the lists
### 2.0.0 (2022-11-01)

@@ -115,0 +119,0 @@ - added Lupusec, HS100 adapter, Zigbee2MQTT and MaxCube

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc