Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. ioBroker Allgemein
    4. Für viele Objekte InfluxDB inkl. Aliase aktivieren

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    Für viele Objekte InfluxDB inkl. Aliase aktivieren

    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      cedric last edited by

      Hi zusammen,

      ich habe sehr viele Homematic-IP (hmip) Instanzen, mit ganz vielen Thermostate und Fenstersensoren und möchte gerne für bestimmte Merkmale (windowOpen, lowBat, ...) InfluxDB aktivieren.
      Allerdings möchte ich auch Aliase nutzen, die natürlich jeweils individuell sind, also eigentlich immer Objekt-Name + "." + Merkmal.

      Wie bekomme ich sowas hin, ohne das für hunderte manuell durchzuführen?

      Danke
      Cedric

      C 1 Reply Last reply Reply Quote 1
      • C
        cedric @cedric last edited by

        Falls es noch jemand anderes braucht, ich habe mir ein Script erstellt:

        // returns device id of state, device or channel-id
        function getDeviceId(id) {
            return id.match(/(.+[a-zA-Z0-9]{24})/g);
        }
        
        
        // check if id has influx enabled
         function isInfluxEnabled(fullList, id, checkAliasToo) {
        
            if(fullList[id] != undefined && fullList[id].enabled && (checkAliasToo == null || checkAliasToo == fullList[id].aliasId)) {
                console.log("angeschaltet: " + getObject(getDeviceId(id)).common.name);
                return true;
            }    
                    
            // default
            return false;
        }
        
        // enable influxdb
        function enableInflux(id, alias) {
            sendTo('influxdb.0', 'enableHistory', {
                id: id,
                options: {
                    changesOnly:  true,
                    debounceTime:     0,
                    blockTime:    0,
        			changesRelogInterval: 0,
                    retention:    31536000,
                    maxLength:    3,
                    changesMinDelta: 0,
                    aliasId: alias
                }
            }, function (result) {
                if (result.error) {
                    console.log(result.error);
                }
                if (result.success) {
                    // successfully enabled
                }
            });
        }
        
        // disable infludb
        function disableInflux(id) {
             sendTo('influxdb.0', 'disableHistory', {
                id: id,
                }, function (result) {
                    if (result.error) {
                        console.log(result.error);
                    }
                    if (result.success) {
                        // successfully disabled
                    }
             });
        }
        
        const deviceBase = "hmip.*.devices.*"; // hmip.0.devices.3014F711A000201D89AC42E3
        const dataPoints = {".channels.1.valveActualTemperature" : 1, ".channels.1.temperatureOffset" : 0, ".channels.0.lowBat" : 0}; // 0=disable; 1=enable
        
        
        // get full list of enabled influx datapoints
        sendTo('influxdb.0', 'getEnabledDPs', {}, function (fullList) {
            //console.log(fullList);
        
            // loop through all datapoints
            for (const [dataPoint, enable] of Object.entries(dataPoints)) {
        
                // get all devices
                var devices = $('state[id=' +deviceBase+dataPoint+']');
        
                console.log("Number of Devices found: " + devices.length);
        
                // loop through all devices
                devices.each(function (id, i){
        
                    // alias
                    var aliasId = getObject(getDeviceId(id)).common.name + dataPoint;
        
                    if( enable == 1) {
                        // enable influx
                        if( !isInfluxEnabled(fullList, id, aliasId)) {
                            console.log("ENABLE: " + aliasId);
                            enableInflux(id, aliasId)
                        }
                    } else {
                        // disable influx
                        console.log("DISABLE: " + aliasId);
                        disableInflux(id);
                    }
                    
        
                }); // devices
        
            } // datapoints
        
        });
        
        1 Reply Last reply Reply Quote 1
        • First post
          Last post

        Support us

        ioBroker
        Community Adapters
        Donate
        FAQ Cloud / IOT
        HowTo: Node.js-Update
        HowTo: Backup/Restore
        Downloads
        BLOG

        952
        Online

        31.9k
        Users

        80.2k
        Topics

        1.3m
        Posts

        1
        2
        208
        Loading More Posts
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes
        Reply
        • Reply as topic
        Log in to reply
        Community
        Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
        The ioBroker Community 2014-2023
        logo