Ich bin neu im Bereich Programmierung u TCL, Habe mir das Buch Hausautomation mit Homematic gekauft und Probier mich durch und hänge fest. Das Script scheint Fehlerfrei zu sein, aber ich kann kein passendes TCL Script finden. Kann mir jemand bitte helfen, im vorraus mal schönen Dank.
Hier das Script auf der Homematic
Code: Alles auswählen
var myAssembly = dom.GetObject("Batterie betrieben");
string itemID;
string text = "";
integer counter = 0;
foreach(itemID, myAssembly.EnumUsedIDs()) {
var item = dom.GetObject(itemID);
var device = dom.GetObject(item.Device());
var interface = dom.GetObject(item.Interface());
string interface_name = interface.Name();
string device_address = device.Address();
device_address = device_address.StrValueByIndex(":", 0);
boolean condition = false;
if ( device.HssType().Find("HM-CC-RT-DN")>=0)
{
string channel_name = interface_name # "." # device_address # ":4.FAULT_REPORTING";
var channel = dom.GetObject(channel_name);
if ( (channel.State() == 6) )
{
condition = true;
}
else
{
condition = false;
}
}
else
{
string channel_name = interface_name # "." # device_address # ":0.LOWBAT";
var channel = dom.GetObject(channel_name);
if ( (channel.State() == true) && (channel.Value() == true) )
{
condition = true;
}
else
{
condition = false;
}
}
if (condition == true) {
text = text # "- " # item.Name() # ": Bitte austauschen!\r\n";
counter = counter + 1;
}
else
{
text = text # "- " # item.Name() # ": OK!\r\n";
}
}
if ( counter > 0 ) {
string MailText;
string sDate = system.Date("%d.%m.%Y");
MailText = "Prüfung des Ladestandes der Batterien vom " # sDate # ".\r\n";
MailText = MailText # "Der Ladezustand folgender Batterien ist niedrig: \r\n\r\n" # text;
MailText = MailText # "\r\nBitte tauschen Sie die Batterien zeitnah aus.";
string stdout;
string stderr;
system.Exec("/etc/config/addons/email/email 06 ,"+MailText+"",&stdout,&stderr);
dom.GetObject("Batt_Mldg").State(MailText);
}
else
{
string MailText;
string sDate = system.Date("%d.%m.%Y");
MailText = "Pruefung des Ladezustandes der Batterien vom " # sDate #".\r\n";
MailText = MailText # " Der Ladezustand aller Batterien ist gut:\r\n\r\n" # text;
string stdout;
string stdout;
string stderr;
system.Exec("/etc/config/addons/email/email 06 ,"+MailText+"",&stdout,&stderr);
dom.GetObject("Batt_Mldg").State(MailText);
}
Danke