HomeMatic-Skript: Inventar



Ein einfaches Skript zum Ablegen einiger Kenndaten in Systemvariablen, zum Erstellen von Ausgaben wie

428 Kanäle in 137 Geräten und 91 CUxD-Kanäle in 6 CUxD-Geräten

Systemvariablen

Skript

Dies ist ein Rohgerüst ohne Fehlerbehandlung. "Works for me", macht was draus.

string s_device;
object o_device;
integer i_devices = 0;
integer i_cdevices = 0;
string s_channel;
object o_channel;
integer i_channels = 0;
integer i_cchannels = 0;
string s_typelist = "";
string s_temp;

foreach(s_device, dom.GetObject(ID_DEVICES).EnumUsedIDs()) {
    var o_device = dom.GetObject(s_device);
    boolean is_cux = o_device.Address().Substr(0,3) == "CUX";
    if ((o_device.Address() != "BidCoS-Wir") && (o_device.Address() != "BidCoS-RF")) {
        if (is_cux) {
            i_cdevices = i_cdevices + 1;
            s_temp = i_cdevices.ToString();
        } else {
            i_devices = i_devices + 1;
            s_temp = i_devices.ToString();
        }
        if (i_devices < 10) { s_temp = " " # s_temp; }
        if (i_devices < 100) { s_temp = " " # s_temp; }
        if (is_cux) { s_temp = "C" # s_temp; }
        else { s_temp = " " # s_temp; }
        WriteLine(s_temp # " " # o_device.Address() # " " # o_device.HssType() # " (" # o_device.Name() # ")");
        if (is_cux) { s_typelist = s_typelist # o_device.Address().Substr(0,5) # "\t"; }
        else { s_typelist = s_typelist # o_device.HssType() # "\t"; }
        foreach(s_channel, o_device.Channels().EnumUsedIDs()) {
            if (is_cux) { i_cchannels = i_cchannels + 1; }
            else { i_channels = i_channels + 1; }
            o_channel = dom.GetObject(s_channel);
            s_temp = "               :" # o_channel.Address().StrValueByIndex(":",1);
            !WriteLine(s_temp # " " # o_channel.Name() );
        }
    }
}

Write(i_channels # " Kanäle in " # i_devices # " Geräten");
if (i_cdevices > 0) { Write(" und "#i_cchannels # " CUxD-Kanäle in " # i_cdevices # " CUxD-Geräten"); }

dom.GetObject("Anzahl_Geraete").State(i_devices);
dom.GetObject("Anzahl_Kanaele").State(i_channels);
dom.GetObject("Anzahl_CUxD_Geraete").State(i_cdevices);
dom.GetObject("Anzahl_CUxD_Kanaele").State(i_cchannels);

string s_typeidx;
string s_typeidx2;
string s_typechecked = "";
integer i_subcount;
foreach (s_typeidx, s_typelist) {
            if (s_typechecked.Find(s_typeidx # ", ") == -1) {
            i_subcount = 0;
            foreach (s_typeidx2, s_typelist) {
                if (s_typeidx2 == s_typeidx) {
                    i_subcount = i_subcount + 1; }
                }
                s_typechecked = s_typechecked # i_subcount # "x " # s_typeidx # ", ";
            }
        }

19 andere Seiten unter 'Technik & Elektronik'

Permalink CC BY-NC 4.0 DEED 2834 27.10.2023 27.10.2023