/******************************************************* * Testversion Fehler finden *******************************************************/ const Version = 1.00; const logging = true; //Sollte immer auf true stehen. Bei false wird garnicht protokolliert const debugging = true; //true protokolliert viele zusätzliche Infos const find_bug = true; //erhöht das Logging wird nur verwendet wenn ein aktulles Bug gesucht wird const show_each_device = true; //zeigt alle verfügbaren Datenpunkte je Device const autoAck = true; //Löschen bestätigbarer Kommunikationsstörungen (true = an, false = aus) const observation = true; //Dauerhafte Überwachung der Geräte auf Servicemeldungen aktiv (true = aktiv // false =inaktiv) const onetime = true; //Prüft beim Script Start ob derzeit Geräte eine Servicemeldung haben const with_time = false; //Hängt die Uhrzeit an die Serviemeldung //Geräte die nicht überwacht werden sollen. Komma getrennt erfassen const no_observation = 'LEQ092862x9, XXX'; //pro Fehlertyp kann eine andere Prio genutzt werden const prio_UNREACH = 0; const prio_STICKY_UNREACH = 0; //Variablen für Servicemeldung in Objekt schreiben // Wenn einer Meldung auftritt wird diese in ein Textfeld geschrieben. z. B. für vis const write_message = false; // true schreibt beim auftreten einer Servicemeldung die Serviemeldung in ein Objekt const id_Text_Servicemeldung = ''; // Objekt wo die Servicemeldung hingeschrieben werden soll //Ab hier eigentliches Script const SelectorUNREACH = $('channel[state.id=hm-rpc.*.0.UNREACH_ALARM$]'); const SelectorSTICKY_UNREACH = $('channel[state.id=hm-rpc.*.0.STICKY_UNREACH_ALARM$]'); let timer = null; let timer_sticky_unreach = null; let meldung_alt = []; let meldung_neu = []; function func_translate_status(meldungsart, native_type, status){ let status_text; if(meldungsart == 'UNREACH_ALARM' || meldungsart == 'STICKY_UNREACH_ALARM'){ if(status === 0){ status_text = 'keine Kommunikationsfehler'; } else if (status == 1){ status_text = 'Kommunikation gestört'; } else if (status == 2){ status_text = 'Kommunikation war gestört'; } } else if(meldungsart == 'SABOTAGE_ALARM'){ if(status === 0){ status_text = 'Keine Sabotage'; } else if(status === 1){ status_text = 'Sabotage'; } else if(status === 2){ status_text = 'Sabotage aufgehoben'; } } else if(meldungsart == 'ERROR'){ if((native_type == 'HM-Sec-RHS') || (native_type == 'HM-Sec-RHS-2') || (native_type == 'HM-Sec-SC') || (native_type == 'HM-Sec-SC-2') || (native_type == 'HM-Sec-SCo') || (native_type == 'HM-Sec-MD') || (native_type == 'HM-Sec-MDIR') || (native_type == 'HM-Sec-MDIR-2')){ if(status == 7){ status_text = 'Sabotage'; } else { status_text = 'ERROR mit dem Wert: ' +status; } } else if ((native_type=='HM-Sec-Key') || (native_type=='HM-Sec-Key-S') || (native_type=='HM-Sec-Key-O')){ if(status == 1){ status_text = 'Einkuppeln fehlgeschlagen'; } else if(status == 2){ status_text = 'Motorlauf abgebrochen'; } else { status_text = 'ERROR mit dem Wert: ' +status; } } else if (native_type=='HM-CC-VD'){ if(status == 1){ status_text = 'Ventil Antrieb blockiert'; } else if(status == 2){ status_text = 'Ventil nicht montiert'; } else if(status == 3){ status_text = 'Stellbereich zu klein'; } else if(status == 4){ status_text = 'Batteriezustand niedrig'; } else { status_text = 'ERROR mit dem Wert: ' +status; } } else { status_text = meldungsart +' mit dem Wert: ' +status; } } else if(meldungsart == 'LOWBAT_ALARM' || meldungsart == 'LOW_BAT_ALARM'){ if(status === 0){ status_text = 'Batterie ok'; } else if (status == 1){ status_text = 'Batterie niedrig'; } else if (status == 2){ status_text = 'Batterie ok'; } } else if(meldungsart == 'ERROR_NON_FLAT_POSITIONING_ALARM'){ if(status === 0){ status_text = 'Keine Meldung'; } else if(status === 1){ status_text = 'Gerät wurde angehoben.'; } else if(status === 2){ status_text = 'Gerät wurde angehoben. Bestätigt'; } } else if(meldungsart == 'CONFIG_PENDING_ALARM'){ if(status === 0){ status_text = 'keine Meldung'; } else if (status == 1){ status_text = 'Konfigurationsdaten stehen zur Übertragung an'; } else if (status == 2){ status_text = 'Konfigurationsdaten standen zur Übertragung an'; } } else if(meldungsart == 'UPDATE_PENDING_ALARM'){ if(status === 0){ status_text = 'kein Update verfügbar'; } else if (status == 1){ status_text = 'Update verfügbar'; } else if (status == 2){ status_text = 'Update wurde eingespielt'; } } else if(meldungsart == 'DEVICE_IN_BOOTLOADER_ALARM'){ if(status === 0){ status_text = 'Keine Meldung'; } else if(status === 1){ status_text = 'Gerät startet neu'; } else if(status === 2){ status_text = 'Gerät wurde neu getsartet'; } } else if(meldungsart == 'FAULT_REPORTING'){ if(native_type == 'HM-CC-RT-DN'){ if(status === 0){ status_text = 'keine Störung'; } else if(status == 1){ status_text = 'Ventil blockiert'; } else if(status == 2){ status_text = 'Einstellbereich Ventil zu groß'; } else if(status == 3){ status_text = 'Einstellbereich Ventil zu klein'; } else if(status == 4){ status_text = 'Kommunikationsfehler'; } else if(status == 6){ status_text = 'Spannung Batterien/Akkus gering'; } else if(status == 7){ status_text = 'Fehlstellung Ventil'; } else{ status_text = meldungsart+' mit dem Wert: ' +status; } } else{ status_text = meldungsart+' mit dem Wert: ' +status; } } return(status_text); } function Servicemeldung(obj) { var common_name; var obj; var id_name; var native_type; var meldungsart; var Gesamt = 0; var Gesamt_UNREACH = 0; var Gesamt_STICKY_UNREACH = 0; var Betroffen = 0; var Betroffen_no_observation = 0; var Betroffen_UNREACH = 0; var Betroffen_STICKY_UNREACH = 0; var id_UNREACH; var servicemeldung = []; var formatiert_servicemeldung = []; var log_manuell = false; SelectorUNREACH.each(function (id, i) { // Schleife für jedes gefundenen Element common_name = getObject(id.substring(0, id.lastIndexOf('.') - 2)).common.name; id_name = id.split('.')[2]; obj = getObject(id); native_type = getObject(id.substring(0, id.lastIndexOf('.') - 2)).native.TYPE; meldungsart = id.split('.')[4]; var id_STICKY_UNREACH = id.substring(0, id.lastIndexOf('.')+1) +'STICKY_UNREACH_ALARM'; log('id_Sticky_Unreach: ' +id_STICKY_UNREACH); if(native_type.substring(0, 3) == 'HM-'){ var statusSTICKY_UNREACH = getState(id_STICKY_UNREACH).val; } var status = getState(id).val; var status_text = func_translate_status(meldungsart, native_type, status); //var datum = formatDate(getState(id).lc, "TT.MM.JJ SS:mm:ss"); var datum_seit = 'x'; if(show_each_device){ log('Geräte Nr. ' +(i + 1) +' Name: '+ common_name +' ('+id_name+') --- '+native_type +' --- Typ: '+meldungsart +' --- Status: ' +status +' ' +status_text ); } }); } //Auslösen durch Zustandsänderung if(observation){ SelectorUNREACH.on(function(obj) { Servicemeldung(obj); }); } if(onetime){ //beim Start Servicemeldung(); }