Archivierung je nach Profil automatisch aktivieren (für viele Variablen)

Für einen Kunden wollte ich sehr viele Variablen von M-Bus Zählern loggen und hatte keine Lust alles per Hand (>1000 Variablen) zu aktivieren. Deshalb dieses Skript, welches dies je nach Profil automatisch übernimmt :slight_smile:

<?php

$acID = 20131;
$ids = IPS_GetVariableList();
foreach($ids as $id) {
    $v = IPS_GetVariable($id);

    if ($v['VariableCustomProfile'] != '') {
        $profileName = $v['VariableCustomProfile'];
    } else {
        $profileName = $v['VariableProfile'];
    }

    if ($profileName !== "" && IPS_VariableProfileExists($profileName)) {
        $profile = IPS_GetVariableProfile($profileName);
        switch(trim($profile["Suffix"])) {
            case "°C":
            case "K":
            case "kW":
            case "m³/h":
                if (!AC_GetLoggingStatus($acID, $id)) {
                    AC_SetLoggingStatus($acID, $id, true);
                    AC_SetAggregationType($acID, $id, 0);
                    AC_ReAggregateVariable($acID, $id);
                }
                break;
            case "Wh":
            case "kWh":
            case "m³":
                if (!AC_GetLoggingStatus($acID, $id)) {
                    AC_SetLoggingStatus($acID, $id, true);
                    AC_SetAggregationType($acID, $id, 1);
                    AC_ReAggregateVariable($acID, $id);
                }
                break;
            case "":
                break;
            default:
                echo trim($profile["Suffix"]) . PHP_EOL;
        }
    }
}
6 „Gefällt mir“

Hi,
Faulheit ist bei mir auch der Grund für einige Scripte :rofl:

Ralf