Huge News!Announcing our $40M Series B led by Abstract Ventures.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 0.3.0 to 1.0.0

6

admin/i18n/de/translations.json

@@ -71,3 +71,7 @@ {

"Create additionally HTML lists": "Erstellen Sie zusätzlich HTML-Listen",
"Create the lists also in HTML": "Erstellen Sie die Listen auch in HTML"
"Create the lists also in HTML": "Erstellen Sie die Listen auch in HTML",
"Daily overview of offline devices": "Tägliche Übersicht über Offline-Geräte",
"Get daily an overview with all offline devices": "Erhalten Sie täglich einen Überblick mit allen Offline-Geräten",
"Update-Interval": "Updateintervall",
"Here you can define the update interval of the datapoints/lists. For performance reasons, it is not recommended to select a poll value that is too low. Lower than two seconds is not selectable.": "Hier können Sie das Aktualisierungsintervall für die Datenpunkte/Listen festlegen. Aus Leistungsgründen ist es nicht empfehlenswert, einen zu niedrigen Poll-Wert zu wählen. Kleiner als zwei Sekunden ist nicht wählbar."
}

@@ -68,3 +68,7 @@ {

"Create additionally HTML lists": "Create additionally HTML lists",
"Create the lists also in HTML": "Create the lists also in HTML"
"Create the lists also in HTML": "Create the lists also in HTML",
"Daily overview of offline devices": "Daily overview of offline devices",
"Get daily an overview with all offline devices": "Get daily an overview with all offline devices",
"Update-Interval": "Update-Interval",
"Here you can define the update interval of the datapoints/lists. For performance reasons, it is not recommended to select a poll value that is too low. Lower than two seconds is not selectable.": "Here you can define the update interval of the datapoints/lists. For performance reasons, it is not recommended to select a poll value that is too low. Lower than two seconds is not selectable."
}

@@ -71,3 +71,7 @@ {

"Create additionally HTML lists": "Crear listas HTML adicionales",
"Create the lists also in HTML": "Crea las listas también en HTML"
"Create the lists also in HTML": "Crea las listas también en HTML",
"Daily overview of offline devices": "Resumen diario de dispositivos fuera de línea",
"Get daily an overview with all offline devices": "Obtenga diariamente una descripción general con todos los dispositivos fuera de línea",
"Update-Interval": "Intervalo de actualización",
"Here you can define the update interval of the datapoints/lists. For performance reasons, it is not recommended to select a poll value that is too low. Lower than two seconds is not selectable.": "Aquí puede definir el intervalo de actualización de los puntos de datos/listas. "
}

@@ -71,3 +71,7 @@ {

"Create additionally HTML lists": "Créer des listes HTML supplémentaires",
"Create the lists also in HTML": "Créez les listes aussi en HTML"
"Create the lists also in HTML": "Créez les listes aussi en HTML",
"Daily overview of offline devices": "Aperçu quotidien des appareils hors ligne",
"Get daily an overview with all offline devices": "Obtenez quotidiennement un aperçu de tous les appareils hors ligne",
"Update-Interval": "Intervalle de mise à jour",
"Here you can define the update interval of the datapoints/lists. For performance reasons, it is not recommended to select a poll value that is too low. Lower than two seconds is not selectable.": "Ici, vous pouvez définir l'intervalle de mise à jour des points de données/listes. "
}

@@ -71,3 +71,7 @@ {

"Create additionally HTML lists": "Crea elenchi HTML aggiuntivi",
"Create the lists also in HTML": "Crea le liste anche in HTML"
"Create the lists also in HTML": "Crea le liste anche in HTML",
"Daily overview of offline devices": "Panoramica quotidiana dei dispositivi offline",
"Get daily an overview with all offline devices": "Ottieni quotidianamente una panoramica di tutti i dispositivi offline",
"Update-Interval": "Intervallo di aggiornamento",
"Here you can define the update interval of the datapoints/lists. For performance reasons, it is not recommended to select a poll value that is too low. Lower than two seconds is not selectable.": "Qui è possibile definire l'intervallo di aggiornamento dei punti dati/elenchi. "
}

@@ -71,3 +71,7 @@ {

"Create additionally HTML lists": "Extra HTML-lijsten maken",
"Create the lists also in HTML": "Maak de lijsten ook in HTML aan"
"Create the lists also in HTML": "Maak de lijsten ook in HTML aan",
"Daily overview of offline devices": "Dagelijks overzicht van offline apparaten",
"Get daily an overview with all offline devices": "Krijg dagelijks een overzicht met alle offline apparaten",
"Update-Interval": "Bijwerkingsonderbreking",
"Here you can define the update interval of the datapoints/lists. For performance reasons, it is not recommended to select a poll value that is too low. Lower than two seconds is not selectable.": "Hier kunt u het update-interval van de datapunten/lijsten definiëren. "
}

@@ -71,3 +71,7 @@ {

"Create additionally HTML lists": "Utwórz dodatkowo listy HTML",
"Create the lists also in HTML": "Twórz listy również w HTML"
"Create the lists also in HTML": "Twórz listy również w HTML",
"Daily overview of offline devices": "Codzienny przegląd urządzeń offline",
"Get daily an overview with all offline devices": "Otrzymuj codziennie przegląd na wszystkich urządzeniach offline",
"Update-Interval": "Interwał aktualizacji",
"Here you can define the update interval of the datapoints/lists. For performance reasons, it is not recommended to select a poll value that is too low. Lower than two seconds is not selectable.": "Tutaj możesz zdefiniować interwał aktualizacji punktów danych/list. "
}

@@ -71,3 +71,7 @@ {

"Create additionally HTML lists": "Crie listas HTML adicionais",
"Create the lists also in HTML": "Crie as listas também em HTML"
"Create the lists also in HTML": "Crie as listas também em HTML",
"Daily overview of offline devices": "Visão geral diária de dispositivos offline",
"Get daily an overview with all offline devices": "Obtenha diariamente uma visão geral com todos os dispositivos offline",
"Update-Interval": "Intervalo de atualização",
"Here you can define the update interval of the datapoints/lists. For performance reasons, it is not recommended to select a poll value that is too low. Lower than two seconds is not selectable.": "Aqui você pode definir o intervalo de atualização dos pontos de dados/listas. "
}

@@ -71,3 +71,7 @@ {

"Create additionally HTML lists": "Создание дополнительных HTML-списков",
"Create the lists also in HTML": "Создавайте списки также в HTML"
"Create the lists also in HTML": "Создавайте списки также в HTML",
"Daily overview of offline devices": "Ежедневный обзор автономных устройств",
"Get daily an overview with all offline devices": "Получайте ежедневный обзор всех автономных устройств",
"Update-Interval": "Интервал обновления",
"Here you can define the update interval of the datapoints/lists. For performance reasons, it is not recommended to select a poll value that is too low. Lower than two seconds is not selectable.": "Здесь вы можете определить интервал обновления точек данных/списков. "
}

@@ -71,3 +71,7 @@ {

"Create additionally HTML lists": "额外创建 HTML 列表",
"Create the lists also in HTML": "也在 HTML 中创建列表"
"Create the lists also in HTML": "也在 HTML 中创建列表",
"Daily overview of offline devices": "离线设备的每日概览",
"Get daily an overview with all offline devices": "每天获取所有离线设备的概览",
"Update-Interval": "更新间隔",
"Here you can define the update interval of the datapoints/lists. For performance reasons, it is not recommended to select a poll value that is too low. Lower than two seconds is not selectable.": "您可以在此处定义数据点/列表的更新间隔。"
}

@@ -56,2 +56,9 @@ {

},
"harmonyDevices": {
"type": "checkbox",
"sm": 6,
"md": 6,
"lg": 3,
"label": "Harmony"
},
"homematicDevices": {

@@ -78,2 +85,9 @@ "type": "checkbox",

},
"jeelinkDevices": {
"type": "checkbox",
"sm": 6,
"md": 6,
"lg": 3,
"label": "Jeelink"
},
"mihomeDevices": {

@@ -168,2 +182,10 @@ "type": "checkbox",

},
"checkSendOfflineMsgDaily": {
"type":"checkbox",
"sm": 12,
"md": 6,
"lg": 3,
"label": "Daily overview of offline devices",
"help": "Get daily an overview with all offline devices"
},
"trenner": {

@@ -589,2 +611,28 @@ "newLine": true,

},
"_updateInterval": {
"type": "header",
"text": "Update-Interval",
"size": 2
},
"textUpdateInterval": {
"type": "staticText",
"text": "Here you can define the update interval of the datapoints/lists. For performance reasons, it is not recommended to select a poll value that is too low. Lower than two seconds is not selectable.",
"sm": 12,
"md": 12,
"lg": 12,
"style": {
"fontSize": 16,
"marginBottom": 10
}
},
"updateinterval": {
"type": "number",
"min": 2,
"max": 100000,
"sm": 6,
"md": 6,
"lg": 3,
"label": "Update-Interval",
"help": "in seconds"
},
"_headerOfflineTime": {

@@ -603,3 +651,3 @@ "type": "header",

"fontSize": 16,
"marginBottom": 20
"marginBottom": 10
}

@@ -679,2 +727,14 @@ },

},
"harmonyMaxMinutes": {
"type": "number",
"min": -1,
"max": 100000,
"sm": 6,
"md": 6,
"lg": 3,
"label": "Harmony",
"help": "in minutes",
"hidden": "!data.harmonyDevices",
"hideOnlyControl": false
},
"homematicMaxMinutes": {

@@ -716,2 +776,14 @@ "type": "number",

},
"jeelinkMaxMinutes": {
"type": "number",
"min": 0,
"max": 100000,
"sm": 6,
"md": 6,
"lg": 3,
"label": "Jeelink",
"help": "in minutes",
"hidden": "!data.jeelinkDevices",
"hideOnlyControl": false
},
"mihomeMaxMinutes": {

@@ -731,3 +803,3 @@ "type": "number",

"type": "number",
"min": 0,
"min": -1,
"max": 100000,

@@ -744,3 +816,3 @@ "sm": 6,

"type": "number",
"min": -1,
"min": 0,
"max": 100000,

@@ -747,0 +819,0 @@ "sm": 6,

{
"common": {
"name": "device-watcher",
"version": "0.3.0",
"version": "1.0.0",
"news": {
"1.0.0": {
"en": "** BREAKING CHANGE ** If you update from version <= 0.3.0, remove the old instance first before you update to >= 1.0.0. After that you can create a new instance.\nchanged mode from shedule to daemon, please take aware from the advice above\nadded Logitech Harmony Hub\nsmall bugfixes (own function for blacklist, fix for memory leak etc.)",
"de": "** BREAKING CHANGE ** Wenn Sie von der Version <= 0.3.0 aktualisieren, entfernen Sie die alte Instanz zuerst, bevor Sie auf >= 1.0.0 aktualisieren danach können Sie eine neue Instanz erstellen.\ngeänderter modus von shedule nach daemon, bitte beachten sie die oben genannten ratschläge\nlogitech Harmony Hub\nkleine bugfixes (eigene funktion für blacklist, fix für speicherleck etc.)",
"ru": "Завтраки изменить Если вы обновляете из версии <= 0.3.0, сначала удалите старый экземпляр, прежде чем обновиться до >= 1.0.0 После этого вы можете создать новый экземпляр.\nизмененный режим от shedule до daemon, пожалуйста, ознакомьтесь с советами выше\nдобавил Logitech Harmony Hub\nнебольшие багфиксы (собственная функция для черного списка, исправить для утечки памяти и т.д.)",
"pt": "** REGRAS DE CONCORRÊNCIA Se você atualizar da versão <= 0.3.0, remova a antiga instância primeiro antes de atualizar para >= 1.0.0 Depois disso você pode criar uma nova instância.\nmodo alterado de shedule para daemon, por favor tome conhecimento do conselho acima\nadicionado Logitech Harmony Hub\npequenos bugfixes (função própria para a lista negra, corrigir para vazamento de memória etc.)",
"nl": "BREAKING CHANGE Als je updates van de versie 0.3.0, verwijder het oude instance eerst voordat je updates geeft aan 1.0, nadat je een nieuw voorbeeld kan creëren.\nverandering van shedule tot daemon, neem het advies boven\nvoegde Logitech Harmony Hub\nkleine insecten (own functie voor blacklist, herstel voor geheugenlek.)",
"fr": "♪ BREAKING CHANGE ♪ Si vous mettez à jour à partir de la version = 0.3.0, retirez l'ancienne instance avant de mettre à jour la version 1.0.0 Après cela, vous pouvez créer une nouvelle instance.\nchangement de mode de shedule à daemon, s'il vous plaît prendre conscience de l'avis ci-dessus\najouté Logitech Harmony Hub\npetits bugfix (fonction unique pour liste noire, correction pour fuite de mémoire etc.)",
"it": "# BREAKING CHANG # Se si aggiorna dalla versione <= 0.3.0, rimuovere la vecchia istanza prima di aggiornare a >= 1.0.0 Dopo di che è possibile creare una nuova istanza.\nmodo cambiato da capannone a demone, si prega di prendere coscienza dal consiglio sopra\naggiunto Logitech Harmony Hub\npiccoli bugfixes (funzione propria per blacklist, fix per perdita di memoria ecc.)",
"es": "# BREAKING CHANGE # Si se actualiza de la versión 0,3.0, retire la vieja instancia primero antes de actualizar a 0,0 Después de eso puede crear una nueva instancia.\ncambio de modo de shedule a daemon, por favor tome conciencia del consejo anterior\nañadido Logitech Harmony Hub\npequeños bugfixes (función propia para la lista negra, fijar para la fuga de memoria, etc.)",
"pl": "BTEAKING CHANGE (ang.). Jeśli uaktualnienie od wersji <= 0.3.0, usunie starego przykładu przed aktualizacją do >= 1.0.0 po tym, jak możesz stworzyć nowy przykład.\nzmienione mody od ul. do daemonu, słyszeć radę powyżej\nlogite Harmony Hub\nmałe błędy (właściwe funkcje czarnej listy, naprawy wyciek pamięci itp.)",
"zh-cn": "** BREAKANGE ** 如果你从 <=0.3.0”的版本中更新,那么,在你更新到1.0.0之前,将旧的事例删除。.\n更改从单元到大都市的模式,请从上述咨询意见中了解。\n增额后勤技术\n小型配制(黑名单的主位,用于纪念泄漏等)。"
},
"0.3.0": {

@@ -207,5 +219,3 @@ "en": "removed channelnumber in Homematic devices name\nadded function to create html list\nadded german and english documentation",

"loglevel": "info",
"mode": "schedule",
"schedule": "*/15 * * * *",
"allowInit": true,
"mode": "daemon",
"type": "misc-data",

@@ -224,2 +234,10 @@ "compact": true,

},
"docs": {
"en": [
"docs/en/README.md"
],
"de": [
"docs/de/README.md"
]
},
"dependencies": [

@@ -248,4 +266,6 @@ {

"fritzdectDevices": false,
"harmonyDevices": false,
"hueDevices": false,
"hueExtDevices": false,
"jeelinkDevices": false,
"nukiExtDevices": false,

@@ -262,2 +282,3 @@ "pingDevices": false,

"checkSendOfflineMsg": false,
"checkSendOfflineMsgDaily": false,
"checkSendBatteryMsg": false,

@@ -289,2 +310,3 @@ "minWarnBatterie": 35,

"tableBlacklist": [],
"updateinterval": 10,
"alexa2MaxMinutes": -1,

@@ -296,8 +318,10 @@ "bleMaxMinutes": 300,

"fritzdectMaxMinutes": -1,
"harmonyMaxMinutes": -1,
"homematicMaxMinutes": -1,
"hueMaxMinutes": -1,
"hueextMaxMinutes": -1,
"jeelinkMaxMinutes": 300,
"mihomeMaxMinutes": 300,
"mihomeVacuumMaxMinutes": 300,
"nukiextendMaxMinutes": -1,
"mihomeVacuumMaxMinutes": -1,
"nukiextendMaxMinutes": 300,
"pingMaxMinutes": -1,

@@ -597,4 +621,28 @@ "shellyMaxMinutes": -1,

"native": {}
},
{
"_id": "info.lastOfflineNotification",
"type": "state",
"common": {
"name": {
"en": "Indicator if last daily offline notification was send today.",
"de": "Indikator, wenn letzte tägliche Offline-Benachrichtigung wurde heute gesendet.",
"ru": "Индикатор, если последнее ежедневное уведомление оффлайн было отправлено сегодня.",
"pt": "Indicador se última notificação off-line diária foi enviado hoje.",
"nl": "Indicator als de laatste dagelijkse offline-informatie vandaag werd verstuurd.",
"fr": "Indicateur si la dernière notification quotidienne hors ligne a été envoyée aujourd'hui.",
"it": "Indicatore se ultima notifica offline giornaliera è stato inviato oggi.",
"es": "Indicador si la última notificación diaria fuera de línea fue enviada hoy.",
"pl": "Wskazuje się na to, że do dziś wysłano ostatni dzienne powiadomienie.",
"zh-cn": "如果最后一天的无线通知今天才发出。."
},
"type": "boolean",
"role": "indicator",
"read": true,
"write": false,
"def": false
},
"native": {}
}
]
}
}

447

main.js

@@ -22,8 +22,2 @@ /* jshint -W097 */

this.on('ready', this.onReady.bind(this));
//this.on('stateChange', this.onStateChange.bind(this));
// this.on('objectChange', this.onObjectChange.bind(this));
// this.on('message', this.onMessage.bind(this));
this.on('unload', this.onUnload.bind(this));
// arrays

@@ -48,2 +42,5 @@ this.offlineDevices = [];

// Interval timer
this.refreshDataTimeout = null;
// arrays of supported adapters

@@ -94,2 +91,9 @@ this.arrApart = {

},
harmony: {
'Selektor': 'harmony.*.hubConnected',
'adapter': 'harmony',
'battery': 'none',
'reach': '.hubConnected',
'isLowBat': 'none'
},
homematic: {

@@ -118,2 +122,9 @@ 'Selektor': 'hm-rpc.*.UNREACH',

},
jeelink: {
'Selektor': 'jeelink.*.lowBatt',
'adapter': 'jeelink',
'battery': 'none',
'reach': 'none',
'isLowBat': '.lowBatt'
},
mihome: {

@@ -134,14 +145,16 @@ 'Selektor': 'mihome.*.percent',

mihomeVacuum: {
'Selektor': 'mihome-vacuum.*.wifi_signal',
'Selektor': 'mihome-vacuum.*.connection',
'adapter': 'mihomeVacuum',
'rssiState': '.wifi_signal',
'rssiState': '.deviceInfo.wifi_signal',
'battery': '.info.battery',
'battery2': '.control.battary_life',
'reach': '.connection',
'isLowBat': 'none'
'reach': '.info.connection',
'isLowBat': 'none',
'id': '.deviceInfo.model'
},
nukiExt: {
'Selektor': 'nuki-extended.*.batteryCritical',
'Selektor': 'nuki-extended.*.lastDataUpdate',
'adapter': 'nuki-extended',
'battery': '.batteryCharge',
'rssiState': 'none',
'battery': '.batteryChargeState',
'reach': 'none',

@@ -200,4 +213,20 @@ 'isLowBat': '.batteryCritical'

'isLowBat': '.Battery.isLow'
},
test: { // Only for Dev
'Selektor': '0_userdata.*.UNREACH',
'adapter': 'homematic',
'rssiState': '.RSSI_DEVICE',
'battery': '.OPERATING_VOLTAGE',
'reach': '.UNREACH',
'isLowBat': '.LOW_BAT',
'isLowBat2': '.LOWBAT'
}
};
this.on('ready', this.onReady.bind(this));
this.on('stateChange', this.onStateChange.bind(this));
// this.on('objectChange', this.onObjectChange.bind(this));
// this.on('message', this.onMessage.bind(this));
this.on('unload', this.onUnload.bind(this));
}

@@ -209,17 +238,2 @@

try {
await this.main();
await this.writeDatapoints();
this.log.debug('all done, exiting');
this.terminate ? this.terminate('Everything done. Going to terminate till next schedule', 11) : process.exit(0);
} catch (error) {
this.errorReporting('[onReady]', error);
this.terminate ? this.terminate(15) : process.exit(15);
}
}
async main() {
this.log.debug(`Function started: ${this.main.name}`);
try {
this.supAdapter = {

@@ -232,5 +246,7 @@ alexa2: this.config.alexa2Devices,

fritzdect: this.config.fritzdectDevices,
harmony: this.config.harmonyDevices,
homematic: this.config.homematicDevices,
hue: this.config.hueDevices,
hueExt: this.config.hueExtDevices,
jeelink: this.config.jeelinkDevices,
mihome: this.config.mihomeDevices,

@@ -247,2 +263,3 @@ mihomeGW: this.config.mihomeDevices,

zwave: this.config.zwaveDevices,
test: false // Only for Dev
};

@@ -254,3 +271,2 @@

this.adapterSelected.push(await this.capitalize(id));
this.log.debug(JSON.stringify(this.arrDev));
}

@@ -261,2 +277,5 @@ }

if (this.adapterSelected.length >= 1) {
// show list in debug log
this.log.debug(JSON.stringify(this.arrDev));
this.log.info(`Number of selected adapters: ${this.adapterSelected.length}. Loading data from: ${(this.adapterSelected).join(', ')} ...`);

@@ -268,6 +287,65 @@ } else {

//create Blacklist
try {
await this.createBlacklist();
} catch (error) {
this.errorReporting('[onReady - create blacklist]', error);
}
// update data now
await this.main();
// update data in interval
await this.refreshData();
} catch (error) {
this.errorReporting('[onReady]', error);
this.terminate ? this.terminate(15) : process.exit(15);
}
}
/**
* Is called if a subscribed state changes
* @param {string} id
* @param {ioBroker.State | null | undefined} state
*/
async onStateChange(id, state) {
if (state) {
// The state was changed
this.log.debug(`state ${id} changed: ${state.val} (ack = ${state.ack})`);
await this.main();
} else {
// The state was deleted
this.log.debug(`state ${id} deleted`);
}
}
async refreshData() {
const nextTimeout = this.config.updateinterval * 1000;
await this.main();
// Clear existing timeout
if (this.refreshDataTimeout) {
this.log.debug('clearing old refresh timeout');
this.clearTimeout(this.refreshDataTimeout);
}
this.refreshDataTimeout = this.setTimeout(() => {
this.log.debug('Updating Data');
this.refreshDataTimeout = null;
this.refreshData();
}, nextTimeout);
}
async main() {
this.log.debug(`Function started: ${this.main.name}`);
try {
//create and fill datapoints for each adapter if selected
try {
for (const [id] of Object.entries(this.arrApart)) {
if (this.supAdapter[id]) {
if ((this.supAdapter !== undefined) && (this.supAdapter[id])) {

@@ -305,3 +383,3 @@ if (this.config.createOwnFolder) {

/**
* @param {string} [sentence] - Word which should be capitalize
* @param {string} sentence - Word which should be capitalize
**/

@@ -314,3 +392,3 @@ async capitalize(sentence) {

/**
* @param {object} [obj] - State of datapoint
* @param {object} obj - State of datapoint
**/

@@ -324,3 +402,3 @@ async getInitValue(obj) {

/**
* @param {object} [obj] - State of own datapoint
* @param {object} obj - State of own datapoint
**/

@@ -335,3 +413,3 @@ async getOwnInitValue(obj) {

/**
* @param {object} [adptName] - Adaptername of devices
* @param {object} adptName - Adaptername of devices
**/

@@ -662,4 +740,16 @@ async createDPsForEachAdapter(adptName) {

async createBlacklist() {
this.log.debug(`Function started: ${this.createBlacklist.name}`);
const myBlacklist = this.config.tableBlacklist;
for (const i in myBlacklist) {
this.blacklistArr.push(myBlacklist[i].device);
}
this.log.info(`Found items on the blacklist: ${this.blacklistArr}`);
this.log.debug(`Function finished: ${this.createBlacklist.name}`);
}
/**
* @param {object} [i] - Device Object
* @param {object} i - Device Object
**/

@@ -669,10 +759,3 @@ async createData(i) {

const deviceAdapterName = await this.capitalize(this.arrDev[i].adapter);
const myBlacklist = this.config.tableBlacklist;
/*---------- Loop for blacklist ----------*/
for (const i in myBlacklist) {
this.blacklistArr.push(myBlacklist[i].device);
this.log.debug(`Found items on the blacklist: ${this.blacklistArr}`);
}
/*---------- Start of second main loop ----------*/

@@ -685,3 +768,3 @@ for (const [id] of Object.entries(devices)) {

//Get device name
// Get device name
const deviceObject = await this.getForeignObjectAsync(currDeviceString);

@@ -692,3 +775,3 @@ const shortDeviceObject = await this.getForeignObjectAsync(shortCurrDeviceString);

switch (this.arrDev[i].adapter) {
case 'switchbotBle': //Get ID for Switchbot and ESPHome Devices
case 'switchbotBle': // Get ID for Switchbot and ESPHome Devices
case 'esphome':

@@ -699,4 +782,4 @@ deviceName = await this.getInitValue(currDeviceString + this.arrDev[i].id);

case 'hue-extended':
case 'mihomeVacuum':
case 'homematic':
case 'nuki-extended':
if (shortDeviceObject && typeof shortDeviceObject === 'object') {

@@ -707,2 +790,6 @@ deviceName = shortDeviceObject.common.name;

case 'mihomeVacuum':
deviceName = await this.getInitValue(shortCurrDeviceString + this.arrDev[i].id);
break;
default:

@@ -717,3 +804,3 @@ if (deviceObject && typeof deviceObject === 'object') {

// 3. Get battery states
// Get battery states
const deviceBatteryState = await this.getInitValue(currDeviceString + this.arrDev[i].battery);

@@ -723,3 +810,3 @@ const shortDeviceBatteryState = await this.getInitValue(shortCurrDeviceString + this.arrDev[i].battery);

// 1. Get link quality
// Get link quality
let deviceQualityState;

@@ -730,8 +817,13 @@ let linkQuality;

case 'sonoff':
case 'mihomeVacuum':
case 'homematic':
deviceQualityState = await this.getForeignStateAsync(currDeviceString + this.arrDev[i].rssiState);
break;
case 'mihomeVacuum':
deviceQualityState = await this.getForeignStateAsync(shortCurrDeviceString + this.arrDev[i].rssiState);
break;
default:
deviceQualityState = await this.getForeignStateAsync(id);
break;
}

@@ -769,10 +861,9 @@

} else {
// no linkQuality available for powered devices
linkQuality = ' - ';
linkQuality = ' - '; // no linkQuality available for powered devices
}
// 1b. Count how many devices with link Quality
// Count how many devices with link Quality
this.linkQualityCount = this.linkQualityDevices.length;
// 2. When was the last contact to the device?
// When was the last contact to the device?
let lastContactString;

@@ -787,2 +878,3 @@

const deviceUnreachState = await this.getInitValue(currDeviceString + this.arrDev[i].reach);
const shortDeviceUnreachState = await this.getInitValue(shortCurrDeviceString + this.arrDev[i].reach);

@@ -811,17 +903,25 @@ const getLastContact = async () => {

// 2b. wenn seit X Minuten kein Kontakt mehr besteht, nimm Gerät in Liste auf
//Rechne auf Tage um, wenn mehr als 48 Stunden seit letztem Kontakt vergangen sind
switch (this.arrDev[i].adapter) {
case 'ping':
// If there is no contact since user sets minutes add device in offline list
// calculate to days after 48 hours
switch (this.arrDev[i].reach) {
case 'none':
await getLastContact();
break;
default:
//State changed
if (!deviceUnreachState) {
await getLastStateChange();
if (this.arrDev[i].adapter == 'homematic') {
if (deviceUnreachState) {
await getLastStateChange();
} else {
await getLastContact();
}
} else {
await getLastContact();
if ((!deviceUnreachState)) {
await getLastStateChange();
} else {
await getLastContact();
}
break;
}
break;
default:
await getLastContact();
break;
}

@@ -851,2 +951,4 @@

// await this.subscribeForeignStatesAsync(currDeviceString + this.arrDev[i].reach);
switch (this.arrDev[i].adapter) {

@@ -859,3 +961,3 @@ case 'alexa2':

}
} else if (lastContact > this.config.alexa2MaxMinutes) {
} else if ((lastStateChange > this.config.alexa2MaxMinutes) && (!deviceUnreachState)) {
deviceState = 'Offline'; //set online state to offline

@@ -882,3 +984,3 @@ await pushOfflineDevice();

}
} else if (lastContact > this.config.deconzMaxMinutes) {
} else if ((lastStateChange > this.config.deconzMaxMinutes) && (!deviceUnreachState)) {
deviceState = 'Offline'; //set online state to offline

@@ -905,3 +1007,3 @@ await pushOfflineDevice();

}
} else if (lastContact > this.config.esphomeMaxMinutes) {
} else if ((lastStateChange > this.config.esphomeMaxMinutes) && (!deviceUnreachState)) {
deviceState = 'Offline'; //set online state to offline

@@ -917,3 +1019,3 @@ await pushOfflineDevice();

}
} else if (lastContact > this.config.fritzdectMaxMinutes) {
} else if ((lastStateChange > this.config.fritzdectMaxMinutes) && (!deviceUnreachState)) {
deviceState = 'Offline'; //set online state to offline

@@ -923,2 +1025,13 @@ await pushOfflineDevice();

break;
case 'harmony':
if (this.config.harmonyMaxMinutes === -1) {
if (!deviceUnreachState) {
deviceState = 'Offline'; //set online state to offline
await pushOfflineDevice();
}
} else if ((lastStateChange > this.config.harmonyMaxMinutes) && (!deviceUnreachState)) {
deviceState = 'Offline'; //set online state to offline
await pushOfflineDevice();
}
break;
case 'homematic':

@@ -930,3 +1043,3 @@ if (this.config.homematicMaxMinutes === -1) {

}
} else if (lastContact > this.config.homematicMaxMinutes) {
} else if ((lastStateChange > this.config.homematicMaxMinutes) && (deviceUnreachState)) {
deviceState = 'Offline'; //set online state to offline

@@ -942,3 +1055,3 @@ await pushOfflineDevice();

}
} else if (lastContact > this.config.hueMaxMinutes) {
} else if ((lastStateChange > this.config.hueMaxMinutes) && (!deviceUnreachState)) {
deviceState = 'Offline'; //set online state to offline

@@ -954,3 +1067,3 @@ await pushOfflineDevice();

}
} else if (lastContact > this.config.hueextMaxMinutes) {
} else if ((lastStateChange > this.config.hueextMaxMinutes) && (!deviceUnreachState)) {
deviceState = 'Offline'; //set online state to offline

@@ -960,2 +1073,13 @@ await pushOfflineDevice();

break;
case 'jeelink':
if (this.config.jeelinkMaxMinutes === -1) {
if (!deviceUnreachState) {
deviceState = 'Offline'; //set online state to offline
await pushOfflineDevice();
}
} else if (lastContact > this.config.jeelinkMaxMinutes) {
deviceState = 'Offline'; //set online state to offline
await pushOfflineDevice();
}
break;
case 'miHome':

@@ -967,3 +1091,3 @@ if (this.config.mihomeMaxMinutes === -1) {

}
} else if (lastContact > this.config.mihomeMaxMinutes) {
} else if ((lastStateChange > this.config.mihomeMaxMinutes) && (!deviceUnreachState)) {
deviceState = 'Offline'; //set online state to offline

@@ -975,7 +1099,7 @@ await pushOfflineDevice();

if (this.config.mihomeVacuumMaxMinutes === -1) {
if (!deviceUnreachState) {
if (!shortDeviceUnreachState) {
deviceState = 'Offline'; //set online state to offline
await pushOfflineDevice();
}
} else if (lastContact > this.config.mihomeVacuumMaxMinutes) {
} else if ((lastStateChange > this.config.mihomeVacuumMaxMinutes) && (!shortDeviceUnreachState)) {
deviceState = 'Offline'; //set online state to offline

@@ -1013,3 +1137,3 @@ await pushOfflineDevice();

}
} else if (lastContact > this.config.shellyMaxMinutes) {
} else if ((lastStateChange > this.config.shellyMaxMinutes) && (!deviceUnreachState)) {
deviceState = 'Offline'; //set online state to offline

@@ -1025,3 +1149,3 @@ await pushOfflineDevice();

}
} else if (lastContact > this.config.sonoffMaxMinutes) {
} else if ((lastStateChange > this.config.sonoffMaxMinutes) && (!deviceUnreachState)) {
deviceState = 'Offline'; //set online state to offline

@@ -1037,3 +1161,3 @@ await pushOfflineDevice();

}
} else if (lastContact > this.config.sonosMaxMinutes) {
} else if ((lastStateChange > this.config.sonosMaxMinutes) && (!deviceUnreachState)) {
deviceState = 'Offline'; //set online state to offline

@@ -1060,3 +1184,3 @@ await pushOfflineDevice();

}
} else if (lastContact > this.config.zigbeeMaxMinutes) {
} else if ((lastStateChange > this.config.zigbeeMaxMinutes) && (!deviceUnreachState)) {
deviceState = 'Offline'; //set online state to offline

@@ -1072,3 +1196,3 @@ await pushOfflineDevice();

}
} else if (lastContact > this.config.zwaveMaxMinutes) {
} else if ((lastStateChange > this.config.zwaveMaxMinutes) && (!deviceUnreachState)) {
deviceState = 'Offline'; //set online state to offline

@@ -1086,12 +1210,47 @@ await pushOfflineDevice();

// 2c. Count how many devcies are offline
// Count how many devcies are offline
this.offlineDevicesCount = this.offlineDevices.length;
// 3. Get battery states
// Get battery states
let batteryHealth;
const deviceLowBatState = await this.getInitValue(currDeviceString + this.arrDev[i].isLowBat);
const deviceLowBatStateHM = await this.getInitValue(currDeviceString + this.arrDev[i].isLowBat2);
if ((!deviceBatteryState) && (!shortDeviceBatteryState)) {
batteryHealth = ' - ';
if ((!deviceBatteryState) && (!shortDeviceBatteryState) && (!shortDeviceBatteryState2)) {
if ((deviceLowBatState !== undefined) || (deviceLowBatState !== undefined) || (deviceLowBatStateHM !== undefined)) {
switch (this.arrDev[i].isLowBat) {
case 'none':
batteryHealth = ' - ';
break;
default:
if (!deviceLowBatState) {
batteryHealth = 'ok';
} else {
batteryHealth = 'low';
}
break;
}
switch (this.arrDev[i].isLowBat2) {
case 'none':
batteryHealth = ' - ';
break;
default:
if (!deviceLowBatState) {
batteryHealth = 'ok';
} else {
batteryHealth = 'low';
}
break;
}
this.batteryPowered.push(
{
'Device': deviceName,
'Adapter': deviceAdapterName,
'Battery': batteryHealth
}
);
} else {
batteryHealth = ' - ';
}
} else {
switch (this.arrDev[i].adapter) {

@@ -1158,12 +1317,11 @@ case 'homematic':

// 3b. Count how many devices are with battery
// Count how many devices are with battery
this.batteryPoweredCount = this.batteryPowered.length;
// 3c. Count how many devices are with low battery
// Count how many devices are with low battery
const batteryWarningMin = this.config.minWarnBatterie;
const deviceLowBatState = await this.getInitValue(currDeviceString + this.arrDev[i].isLowBat);
const deviceLowBatStateHM = await this.getInitValue(currDeviceString + this.arrDev[i].isLowBat2);
// fill list with low battery devices
switch (this.arrDev[i].adapter) {
case 'homematic':
case 'homematic': // there are differnt low bat states between hm and hmIp devices
if (deviceLowBatState || deviceLowBatStateHM) {

@@ -1180,3 +1338,3 @@ this.batteryLowPowered.push(

default:
default: // for all other devices with low bat states
if (deviceLowBatState) {

@@ -1190,3 +1348,3 @@ this.batteryLowPowered.push(

);
} else if (deviceBatteryState && (deviceBatteryState < batteryWarningMin)) {
} else if (deviceBatteryState && (deviceBatteryState < batteryWarningMin)) { // if the battery state is under the set limit
this.batteryLowPowered.push(

@@ -1240,3 +1398,3 @@ {

/**
* @param {string} [adptName] - Adapter name
* @param {string} adptName - Adapter name
*/

@@ -1278,2 +1436,3 @@ async createDataForEachAdapter(adptName) {

if (this.config.checkSendOfflineMsg) await this.sendOfflineNotifications(); // send message if new devices are offline
if (this.config.checkSendOfflineMsgDaily) await this.sendDailyOfflineNotifications(); // send daily overview of offline devices
if (this.config.checkSendBatteryMsg) await this.sendBatteryNotifications(); // send message for low battery devices

@@ -1291,3 +1450,3 @@ await this.writeDatapoints(); // fill the datapoints

* Notification service
* @param {string} [text] - Text which should be send
* @param {string} text - Text which should be send
**/

@@ -1421,4 +1580,6 @@ async sendNotification(text) {

if ((this.offlineDevicesCount != offlineDevicesCountOld)) {
if (this.offlineDevicesCount == 1) { // make singular if it is only one device
if ((this.offlineDevicesCount !== offlineDevicesCountOld)) {
if (this.offlineDevicesCount == 0) {
msg = 'Alle Geräte sind Online.';
} else if (this.offlineDevicesCount == 1) { // make singular if it is only one device
msg = 'Folgendes Gerät ist seit einiger Zeit nicht erreichbar: \n';

@@ -1432,2 +1593,3 @@ } else if (this.offlineDevicesCount >= 2) { //make plural if it is more than one device

}
this.log.info(msg);

@@ -1440,6 +1602,73 @@ await this.setStateAsync('lastNotification', msg, true);

}
try {
// send daily an overview with offline devices
if (this.config.checkSendOfflineMsgDaily) {
// Check if the daily message for offline devices was already sent today
const lastOfflineNotifyIndicator = await this.getOwnInitValue('info.lastOfflineNotification');
const now = new Date(); // get date
// set indicator for send message first to 'false', after sending to 'true'
if (now.getHours() < 11) await this.setStateAsync('info.lastOfflineNotification', false, true);
// if time is > 11 (12:00 pm create message for offline devices devices)
if ((now.getHours() > 11) && (!lastOfflineNotifyIndicator)) {
let msg = '';
for (const id of this.offlineDevices) {
msg = `${msg} \n ${id['Device']} (${id['Last contact']})`;
}
if (this.offlineDevicesCount > 0) {
this.log.info(`Geräte Offline: ${msg}`);
await this.setStateAsync('lastNotification', `Geräte Offline: ${msg}`, true);
await this.sendNotification(`Geräte Offline: ${msg}`);
await this.setStateAsync('info.lastOfflineNotification', true, true);
}
}
}
} catch (error) {
this.errorReporting('[sendOfflineMessage - daily message]', error);
}
this.log.debug(`Finished the function: ${this.sendOfflineNotifications.name}`);
}//<--End of offline notification
async sendDailyOfflineNotifications() {
// send daily an overview with offline devices
this.log.debug(`Start the function: ${this.sendDailyOfflineNotifications.name}`);
try {
// Check if the daily message for offline devices was already sent today
const lastOfflineNotifyIndicator = await this.getOwnInitValue('info.lastOfflineNotification');
const now = new Date(); // get date
// set indicator for send message first to 'false', after sending to 'true'
if (now.getHours() < 11) await this.setStateAsync('info.lastOfflineNotification', false, true);
// if time is > 11 (12:00 pm create message for offline devices devices)
if ((now.getHours() > 11) && (!lastOfflineNotifyIndicator)) {
let msg = '';
for (const id of this.offlineDevices) {
msg = `${msg} \n ${id['Device']} (${id['Last contact']})`;
}
if (this.offlineDevicesCount > 0) {
this.log.info(`Geräte Offline: ${msg}`);
await this.setStateAsync('lastNotification', `Geräte Offline: ${msg}`, true);
await this.sendNotification(`Geräte Offline: ${msg}`);
await this.setStateAsync('info.lastOfflineNotification', true, true);
}
}
} catch (error) {
this.errorReporting('[sendDailyOfflineNotifications]', error);
}
this.log.debug(`Finished the function: ${this.sendDailyOfflineNotifications.name}`);
}//<--End of daily offline notification
async sendBatteryNotifications() {

@@ -1484,3 +1713,3 @@ // send message for low battery devices

// set indicator for send message first to 'false', after sending to 'true'
if (now.getHours() < 11) { await this.setStateAsync('info.lastBatteryNotification', false, true); }
if (now.getHours() < 11) await this.setStateAsync('info.lastBatteryNotification', false, true);

@@ -1517,3 +1746,3 @@ // if time is > 11 (12:00 pm create message for low battery devices)

// arrays
this.offlineDevices = [],
this.offlineDevices = [];
this.linkQualityDevices = [];

@@ -1613,4 +1842,4 @@ this.batteryPowered = [];

/**
* @param {object} [devices] - Device
* @param {number} [deviceCount] - Counted devices
* @param {object} devices - Device
* @param {number} deviceCount - Counted devices
*/

@@ -1646,4 +1875,4 @@ async creatLinkQualityListHTML(devices, deviceCount) {

/**
* @param {object} [devices] - Device
* @param {number} [deviceCount] - Counted devices
* @param {object} devices - Device
* @param {number} deviceCount - Counted devices
*/

@@ -1705,5 +1934,5 @@ async createOfflineListHTML(devices, deviceCount) {

if (isLowBatteryList) {
html += `<td align=center><font color=orange>${device.Battery == ' - ' ? 'schwach' : device.Battery}</font></td>`;
html += `<td align=center><font color=orange>${device.Battery}</font></td>`;
} else {
html += `<td align=right><font color=#3bcf0e>${device.Battery == ' - ' ? 'ok' : device.Battery}</font></td>`;
html += `<td align=right><font color=#3bcf0e>${device.Battery}</font></td>`;
}

@@ -1719,4 +1948,4 @@

/**
* @param {string} [codePart] - Message Prefix
* @param {object} [error] - Sentry message
* @param {string} codePart - Message Prefix
* @param {object} error - Sentry message
*/

@@ -1739,5 +1968,14 @@ errorReporting(codePart, error) {

/**
* @param {() => void} callback
*/
onUnload(callback) {
try {
this.log.info('cleaned everything up...');
if (this.refreshDataTimeout) {
this.log.debug('clearing refresh timeout');
this.clearTimeout(this.refreshDataTimeout);
}
callback();

@@ -1750,2 +1988,3 @@ } catch (e) {

// @ts-ignore parent is a valid property on module
if (require.main !== module) {

@@ -1752,0 +1991,0 @@ // Export the constructor in compact mode

{
"name": "iobroker.device-watcher",
"version": "0.3.0",
"version": "1.0.0",
"description": "Watchdog for devices",

@@ -29,8 +29,8 @@ "author": {

"@alcalzone/release-script": "^3.5.9",
"@iobroker/adapter-dev": "^1.0.0",
"@iobroker/testing": "^3.0.2",
"@types/chai": "^4.3.1",
"@iobroker/adapter-dev": "^1.0.1",
"@iobroker/testing": "^4.1.0",
"@types/chai": "^4.3.3",
"@types/chai-as-promised": "^7.1.5",
"@types/mocha": "^9.1.1",
"@types/node": "^18.6.3",
"@types/node": "^18.7.14",
"@types/proxyquire": "^1.3.28",

@@ -41,3 +41,3 @@ "@types/sinon": "^10.0.13",

"chai-as-promised": "^7.1.1",
"eslint": "^8.20.0",
"eslint": "^8.23.0",
"mocha": "^10.0.0",

@@ -47,3 +47,3 @@ "proxyquire": "^2.1.3",

"sinon-chai": "^3.7.0",
"typescript": "~4.7.4"
"typescript": "~4.8.2"
},

@@ -75,2 +75,2 @@ "main": "main.js",

"readmeFilename": "README.md"
}
}

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

[![GitHub license](https://img.shields.io/github/license/ciddi89/ioBroker.device-watcher)](https://github.com/ciddi89/ioBroker.device-watcher/blob/main/LICENSE)
![GitHub repo size](https://img.shields.io/github/repo-size/ciddi89/ioBroker.device-watcher)
![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/v0.2.4)
![GitHub commits since tagged version (branch)](https://img.shields.io/github/commits-since/ciddi89/ioBroker.device-watcher/v1.0.0)
![GitHub last commit](https://img.shields.io/github/last-commit/ciddi89/ioBroker.device-watcher)
![GitHub issues](https://img.shields.io/github/issues/ciddi89/ioBroker.device-watcher)
[![NPM](https://nodei.co/npm/iobroker.device-watcher.png?downloads=true)](https://nodei.co/npm/iobroker.device-watcher/)
**Tests:** ![Test and Release](https://github.com/ciddi89/ioBroker.device-watcher/workflows/Test%20and%20Release/badge.svg)

@@ -28,3 +27,3 @@

This is a watchdog for wireless devices. The adapter looks every fifteen minutes for the rssi/link quality and battery states and create JSON lists of them (devices with battery, devices with link quality, devices offline and devices all) and count the devices in the same categories. For example you can use the lists and states for Grafana, Jarvis etc.
This is a watchdog for wireless devices. The adapter looks for the rssi/link quality and battery states and create JSON lists of them (devices with battery, devices with link quality, devices offline and devices all) and count the devices in the same categories. For example you can use the lists and states for Grafana, Jarvis etc.

@@ -38,5 +37,7 @@ Supported adapters are:

* FritzDect
* Harmony
* Homematic
* Hue
* Hue Extended
* Jeelink
* MiHome

@@ -89,2 +90,8 @@ * MiHome Vacuum

-->
### 1.0.0 (2022-09-03)
- ** BREAKING CHANGE ** If you update from version <= 0.3.0, remove the old instance first before you update to >= 1.0.0. After that you can create a new instance.
- changed mode from shedule to daemon, please take aware from the advice above
- added Logitech Harmony Hub
- small bugfixes (own function for blacklist, fix for memory leak etc.)
### 0.3.0 (2022-08-10)

@@ -94,4 +101,6 @@ - removed channelnumber in Homematic devices name

- added german and english documentation
### 0.2.4 (2022-07-31)
- many changes of code, comments and error handling
### 0.2.2 (2022-07-28)

@@ -98,0 +107,0 @@ - fixed translations

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