I've been looking for such a function for quite some time now and I now found it. I use Cloud-Matic to remotely connect to my smart home (CCU2). I've asked them if it was possible to have the service massages pushed to my phone (with the EASY app), and they came with a version of your script, which I will add below. However I can't get it to work. I currently have to low battery messages of two HM-TC-IT-WM-W-EU devices but the script doesn't push them to my phone. (Other scripts with EASY Push work, so that is not the problem. Could you please have a look at the script to see where things go wrong? Thanks in advance!
O I translated the messages to dutch, so that might also be a source of error. And I removed my API-key for the EASY_Push.
Thanks,
Jeroen
Code: Alles auswählen
! Servicemeldungen auslesen, verarbeiten und per Nachricht versenden
! v2.0 (c) by EASY SmartHome GmbH
! https://homematic-forum.de/forum/viewtopic.php?f=31&t=24618&hilit=servicemeldung+all+in+one
!++++++ SETUP ++++++
! Bitte in Ruhe die naechsten Zeilen durcharbeiten
! WITHTIME - Wenn ja, wird die Zeit der Servicemeldung versendet
var WITHTIME = "ja";
! ACCK - Wenn ja, werden Meldungen "Kommunikation war gestoert" bestaetigt
var ACCK = "ja";
! BLOCK - Hier koennen Sie Seriennummern von Geraeten eintragen, welche von diesem Skript ignoriert werden sollen
var BLOCK = "";
!+++++++ Setup CloudMatic Benachrichtigungen ++++++
! ONLYNEW - Wenn ja, werden Benachrichtigungen nur bei neuen Servicemeldungen versendet
var ONLYNEW = "ja";
! USE_EASY_MAIL - Wenn ja, werden die Servicemeldungen per Mail gesendet
var USE_EASY_MAIL = "nein";
! MAIL_EMPFAENGER - Hier die Mail-Adresse angeben, an welche die Meldungen ggf. gesendet werden sollen
string MAIL_EMPFAENGER = "bjkluft@gmail.com";
! USE_EASY_PUSH - Wenn ja, werden die Servicemeldungen per Push gesendet
var USE_EASY_PUSH = "ja";
! API_KEY1, API_KEY2, API_KEY3 - Hier die API-Keys der Geraete angeben, an welche die Meldungen ggf. gesendet werden sollen
var API_KEY1 = "";
var API_KEY2 = "";
var API_KEY3 = "";
!+++++++ Systemvariablen Setup ++++++
! Zum Speichern der Servicemeldungen in eine Systemvariable benoetigt
! Soll diese Funktion genutzt werden, muss auf der Zentrale eine Systemvariable vom Typ "Zeichenkette" angelegt werden
! USE_SYSVAR - Wenn ja, werden die Servicemeldungen in einer Systemvariable gespeichert
var USE_SYSVAR = "nein";
! SYSVAR_NAME - Hier die Bezeichnung der Systemvariable angeben, in welcher die Meldungen ggf. gespeichert werden sollen
var SYSVAR_NAME = "CustomService";
!+++++++ Eigentlich schon fertig mit dem Setup +++++++++++
!+++++ Batteriezuweisungen inklusive Anzahl - Bitte helfen und fehlende Geraete posten ++++++++++++++++
!+++++ Noch nicht integrierte Geraete werden mit unbekannt ausgegeben ++++++++++++++++
string cr2016 = "HM-RC-4\tHM-RC-4-B\tHM-RC-Key3\tHM-RC-Key3-B\tHM-RC-P1\tHM-RC-Sec3\tHM-RC-Sec3-B";
string cr2032 = "HM-PB-2-WM\tHM-PB-4-WM\tHM-PBI-4-FM\tHM-SCI-3-FM\tHM-Sec-TiS\tHM-SwI-3-FM\tHM-Sec-TiS";
string lr14x2 = "HM-Sec-Sir-WM\tHM-OU-CFM-TW";
string lr44x2 = "HM-Sec-SC\tHM-Sec-SC2\tHM-Sec-SC-2\tHM-Sec-RHS";
string lr6x2 = "HM-CC-VD\tHM-CC-RT-DN\tHM-Sec-WDS\tHM-Sec-WDS-2\tHM-CC-TC\tHM-Dis-TD-T\tHB-UW-Sen-THPL-I\tHM-TC-IT-WM-W-EU\tHM-WDS40-TH-I\tHM-WDS40-TH-I-2\tHM-WDS10-TH-O\tHmIP-SMI\tHMIP-eTRV\tHM-WDS30-OT2-SM-2\tHmIP-SMO\tHmIP-SMO-A\tHmIP-SPI\tHmIP-STHD";
string lr6x3 = "HM-Sec-MDIR\tHM-Sec-MDIR-2\tHM-Sec-SD\tHM-Sec-Key\tHM-Sec-Key-S\tHM-Sec-Key-O\tHM-Sen-Wa-Od\tHM-Sen-MDIR\tHM-Sen-MDIR-O\tHM-Sen-MDIR-O-2\tHM-WDS100-C6-O\tHM-WDS100-C6-O-2\tHM-WDS100-C6-O-2\tHmIP-ASIR";
string lr6x4 = "HM-CCU-1\tHM-ES-TX-WM\tHM-WDC7000";
string lr3x1 = "HM-RC-4-2\tHM-RC-4-3\tHM-RC-Key4-2\tHM-RC-Key4-3\tHM-RC-Sec4-2\tHM-RC-Sec4-3\tHM-Sec-RHS-2\tHM-Sec-SCo\tHmIP-KRC4\tHmIP-KRCA\tHmIP-RC8\tHmIP-SRH\tHMIP-SWDO";
string lr3x2 = "HM-Dis-WM55\tHM-Dis-EP-WM55\tHM-PB-2-WM55\tHM-PB-2-WM55-2\tHM-PB-6-WM55\tHM-PBI-2-FM\tHM-RC-8\tHM-Sen-DB-PCB\tHM-Sen-EP\tHM-Sen-MDIR-SM\tHM-Sen-MDIR-WM55\tHM-TC-IT-WM-W-EU\tHM-WDS30-T-O\tHM-WDS30-OT2-SM\tHmIP-STH\tHMIP-WRC2\tHMIP-WRC6\tHMIP-WTH\tHMIP-WTH-2";
string lr3x3 = "HM-PB-4Dis-WM\tHM-PB-4Dis-WM-2\tHM-RC-Dis-H-x-EU\tHM-Sen-LI-O";
string lr3x3a = "HM-RC-19\tHM-RC-19-B\tHM-RC-12\tHM-RC-12-B\tHM-RC-12-W";
string block9 = "HM-LC-Sw1-Ba-PCB\tHM-LC-Sw4-PCB\tHM-MOD-EM-8\tHM-MOD-Re-8\tHM-Sen-RD-O\tHM-OU-CM-PCB\tHM-LC-Sw4-WM";
string fixed = "HM-Sec-SD-2\tHMIP-SWSD";
string recharge = "HM-Sec-Win\tHM-Sec-SFA-SM";
!+++++++++ Setup nun aber wirklich zu Ende - ab hier Finger weg ;-) ++++++++++++++++++
string stdout;
string stderr;
system.Exec("logger -t script -p user.debug [CloudMatic Servicemeldung Skript Start]", &stdout, &stderr);
string TITLE = "Servicemeldingen";
boolean GO = true;
string slist = "";
if(ONLYNEW == "ja") {
if(!(dom.GetObject(41).Value() > dom.GetObject(41).LastValue())) { GO = false; }
TITLE = "Nieuwe Servicemelding";
}
object oTmpArray = dom.GetObject(ID_SERVICES);
if(oTmpArray) {
string sTmp;
string sdesc;
string stest;
foreach(sTmp, oTmpArray.EnumIDs()) {
object oTmp = dom.GetObject(sTmp);
if(oTmp) {
if(oTmp.IsTypeOf(OT_ALARMDP) && (oTmp.AlState() == asOncoming)) {
boolean collect = true;
object trigDP = dom.GetObject(oTmp.AlTriggerDP());
object och = dom.GetObject((trigDP.Channel()));
object odev = dom.GetObject((och.Device()));
var ival = trigDP.Value();
time sftime = oTmp.AlOccurrenceTime(); ! erste Meldezeit
time sltime = oTmp.LastTriggerTime(); ! letze Meldezeit
var sdesc = trigDP.HssType();
var sserial = odev.Address();
if((sdesc == "STICKY_UNREACH") && (ACCK == "ja")) {
oTmp.AlReceipt(); collect = false;
}
if((BLOCK.Find(sserial) < 0) && (collect)) {
! Uebersetzen der Fehlermeldungen
if(sdesc == "CONFIG_PENDING") { sdesc = "Configuratiedata wordt verzonden"; }
if(sdesc == "LOWBAT") { sdesc = "Laag batterijniveau"; }
if(sdesc == "STICKY_UNREACH") { sdesc = "Communicatie mislukt"; }
if(sdesc == "UNREACH") { sdesc = "Communicatie gelukt"; }
if(sdesc == "DEVICE_IN_BOOTLOADER") { sdesc = "Apparaat opnieuw gestart"; }
if(sdesc == "UPDATE_PENDING") { sdesc = "Update beschikbaar"; }
if(sdesc == "U_SOURCE_FAIL") { sdesc = "Netstroom uitgevallen"; }
if(sdesc == "USBH_POWERFAIL") { sdesc = "USB-Host uitgeschakeld"; }
if(sdesc == "ERROR_SABOTAGE") { sdesc = "Sabotage"; }
if(sdesc == "STICKY_SABOTAGE") { sdesc = "Sabotagemelding geweest"; }
if(sdesc == "ERROR_REDUCED") {sdesc = "Kritische temperatuur (vermogensreductie)"; }
! Sonderfehler
if(sdesc == "ERROR") {
if((odev.HssType() == "HM-Sec-RHS") || (odev.HssType() == "HM-Sec-SC") || (odev.HssType() == "HM-Sec-SC-2") || (odev.HssType() == "HM-Sec-SCo") || (odev.HssType() == "HM-Sec-MD") || (odev.HssType() == "HM-Sec-MDIR") || (odev.HssType() == "HM-Sec-MDIR-2") || (odev.HssType() == "HM-Sec-Sir-WM")) {
if(ival == 7) { sdesc = "Sabotage"; }
}
if((odev.HssType() == "HM-Sec-Key") || (odev.HssType() == "HM-Sec-Key-S") || (odev.HssType() == "HM-Sec-Key-O")) {
if(ival == 1) { sdesc = "Loskoppelen mislukt"; }
if(ival == 2) { sdesc = "Motorbeweging afgebroken"; }
}
if(odev.HssType() == "HM-CC-VD") {
if(ival == 1) { sdesc = "Ventiel geblokkeerd"; }
if(ival == 2) { sdesc = "Ventiel niet gemonteerd"; }
if(ival == 3) { sdesc = "Instelbereik te klein"; }
if(ival == 4) { sdesc = "Laag batterijniveau"; }
}
}
if(sdesc == "FAULT_REPORTING") {
if(odev.HssType() == "HM-CC-RT-DN") {
if(ival == 1) { sdesc = "Ventiel geblokkeerd."; }
if(ival == 2) { sdesc = "Instelbereik te groot"; }
if(ival == 3) { sdesc = "Instelbereik te klein"; }
if(ival == 4) { sdesc = "Communicatie mislukt"; }
if(ival == 6) { sdesc = "Laag batterijniveau"; }
if(ival == 7) { sdesc = "Ventiel fout afgesteld"; }
}
}
if(sdesc == "Laag batterijniveau") {
string batlink = "onbekent";
string index;
foreach(index, cr2016) {
if(index == odev.HssType()) { batlink = "1 lege CR2016"; }
}
foreach(index, cr2032) {
if(index == odev.HssType()) { batlink = "1 lege CR2032"; }
}
foreach(index, lr14x2) {
if(index == odev.HssType()) { batlink = "2 leeg LR14"; }
}
foreach(index, lr44x2) {
if(index == odev.HssType()) { batlink = "2 lege LR44/AG13"; }
}
foreach(index, lr6x2) {
if(index == odev.HssType()) { batlink = "2 lege LR6/AA"; }
}
foreach(index, lr6x3) {
if(index == odev.HssType()) { batlink = "3 lege LR6/AA"; }
}
foreach(index, lr6x4) {
if(index == odev.HssType()) { batlink = "4 lege LR6/AA"; }
}
foreach(index, lr3x1) {
if(index == odev.HssType()) { batlink = "1 lege LR3/AAA"; }
}
foreach(index, lr3x2) {
if(index == odev.HssType()) { batlink = "2 lege LR3/AAA"; }
}
foreach(index, lr3x3) {
if(index == odev.HssType()) { batlink = "3 lege LR3/AAA"; }
}
foreach(index, lr3x3a) {
if(index == odev.HssType()) { batlink = "3 lege AAA Accus - opladen a.u.b."; }
}
foreach(index, block9) {
if(index == odev.HssType()) { batlink = "9 Volt Block leeg of onbekend"; }
}
foreach(index, fixed) {
if(index == odev.HssType()) { batlink = "Interne batterij leeg"; }
}
foreach(index, recharge) {
if(index == odev.HssType()) { batlink = "Accu leeg - opladen a.u.b."; }
}
slist = slist # odev.Name() # ": " # batlink;
if(WITHTIME == "ja") {
slist = slist # " seit: " # sftime.Format("%d-%m-%y %H:%M");
}
}
else {
slist = slist # odev.Name() # ": " # sdesc;
if(WITHTIME == "ja") {
slist = slist # " seit: " # sftime.Format("%d-%m-%y %H:%M");
}
}
}
}
}
}
if(slist.Length() == 20) {
string stdout;
string stderr;
system.Exec("logger -t script -p user.debug [CloudMatic Servicemeldung Skript Abbruch BLOCK]", &stdout, &stderr);
quit;
}
! Verarbeiten der Daten zum Versand
if(GO) {
if(USE_EASY_MAIL == "ja") {
string stdout;
string stderr;
string teilstr;
string sendmail = "";
string sendbetreff = "";
string mailto = "";
foreach(teilstr, TITLE.Split(" ")) {
sendbetreff = sendbetreff # "+" # teilstr;
}
foreach(teilstr, slist.Split(" ")) {
sendmail = sendmail # "+" # teilstr;
}
foreach(teilstr, MAIL_EMPFAENGER.Split(" ")) {
mailto = mailto # "+" # teilstr;
}
system.Exec("logger -t script -p user.debug [CloudMatic Servicemeldung Skript - MAIL text " # slist # "]", &stdout, &stderr);
system.Exec("logger -t script -p user.debug [CloudMatic Servicemeldung Skript - MAIL title " # sendbetreff # "]", &stdout, &stderr);
system.Exec("logger -t script -p user.debug [CloudMatic Servicemeldung Skript - MAIL to " # mailto # "]", &stdout, &stderr);
system.Exec("/bin/sh /etc/config/addons/mh/email.sh " # sendbetreff # " " # sendmail # " " # mailto, &stdout, &stderr);
}
if(USE_EASY_PUSH == "ja") {
string stdout;
string stderr;
string teilstr;
string sendtext = "";
string sendevent = "";
foreach(teilstr, TITLE.Split(" ")) {
sendevent = sendevent # "+" # teilstr;
}
foreach(teilstr, slist.Split(" ")) {
sendtext = sendtext # "+" # teilstr;
}
system.Exec("logger -t script -p user.debug [CloudMatic Servicemeldung Skript - PUSH wird gesendet]", &stdout, &stderr);
if(API_KEY1 != "") { system.Exec("/bin/sh /etc/config/addons/mh/prowl.sh " # "ESY:" # API_KEY1 # " " # sendevent # " " # sendtext, &stdout, &stderr); }
if(API_KEY2 != "") { system.Exec("/bin/sh /etc/config/addons/mh/prowl.sh " # "ESY:" # API_KEY2 # " " # sendevent # " " # sendtext, &stdout, &stderr); }
if(API_KEY3 != "") { system.Exec("/bin/sh /etc/config/addons/mh/prowl.sh " # "ESY:" # API_KEY3 # " " # sendevent # " " # sendtext, &stdout, &stderr); }
}
}
if((USE_SYSVAR == "ja") && (dom.GetObject(ID_SYSTEM_VARIABLES)).Get(SYSVAR_NAME)) {
(dom.GetObject(ID_SYSTEM_VARIABLES)).Get(SYSVAR_NAME).State(slist);
}
}
WriteLine(slist);