Hi,

da sich bei mir einige Geräte im Heimnetz tummeln, die sich per MQTT mitteilen, wollte ich diese möglichst einfach in VZ speichern lassen (bzw. in eine InfluxDB). Z.B. gibt es ein paar Steckdosen, auf denen Tasmota läuft und die so ihre Werte per MQTT (JSON) übertragen:

{"Time":"2020-03-31T10:12:36","ENERGY":{"TotalStartTime":"2020-02-27T20:27:49","Total":24.950,"Yesterday":0.766,"Today":0.332,"Period":0,"Power":77,"ApparentPower":86,"ReactivePower":39,"Factor":0.89,"Voltage":226,"Current":0.380}}

Da mein MQTT Server auf einem Raspberry neben dem vzlogger läuft (incl. mosquitto_sub Kommando), dachte ich mir, man kann sicher das exec Protokoll dafür nutzen.
Für die DB brauche ich nur "Power", also reicht

mosquitto_sub -C 1 -t /SmartHome/Topic/ZumGeraet/SENSOR | jq -r '.ENERGY.Power'

-C 1 läßt das Kommando einfach warten, bis 1 Antwort zurück kommt.

Hier die Konfiguration aus vzlogger.conf (influxdb ist optional):

    { // MQTTsubscriber
      "enabled": true,
      "allowskip": true,
      "interval": 10,        //Achtung: alle 10 Sekunden, eventuell erhöhen
      "aggtime": -1,
      "aggfixedinterval": false,
      "channels": [
        {
          "api": "volkszaehler",
          "uuid": "96e43280-1234-1122-aabb-g527bd5f1607",
          "identifier": "",
//          "middleware": "http://127.0.0.1/middleware.php";,
          "middleware" : "http://127.0.0.1:8080";,
          "aggmode": "none",
          "duplicates": 0
        },
        {  // nochmal in die InfluxDB, ACHTUNG: das ist komplett optional und für die meisten unnötig
          "api": "influxdb", // use the InfluxDB api
          "uuid": "96e43280-1234-1122-aabb-g527bd5f1607",
          "identifier" : "",
          "host": "127.0.0.1:8086",     // This assumes that InfluxDB is running on localhost           "database": "volkszaehler",     // Optional: make sure this database exists in InfluxDB           "measurement_name": "data",     // Optional: It is recommended that all your meters have the same InfluxDB measurement name           "tags": "title=Gefrierschrank,type=powersensor",    // Optional: Additional tags to append when inserting data           "username": "username",      // Optional: When InfluxDB Auth is enabled you need to set the correct user and password
          "password": "password",
          //"max_batch_inserts": 4500,     // Optional: Max number of measurements per request. No need to change this           //"max_buffer_size": 450000,     // Optional: Max number of measurements to be cached when InfluxDB is not available           //"timeout": 30,     // Optional: Time in seconds after which requests to InfluxDB time out           //"send_uuid": false,     // Optional: Disables the sending of the UUID to the InfluxDB server           //"ssl_verifypeer": false,     // Optional: Disables the certificate verification for https connections
          "aggmode" : "none"
        }
      ],
      "*protocol": "exec",*
*"command": "mosquitto_sub -C 1 -t **/SmartHome/Topic/ZumGeraet/SENSOR | jq -r '.ENERGY.Power'",*
      //"format": "$v"
    },


Funktioniert sehr gut so weit.

Viele Grüße
Sirko

Antwort per Email an