Tigo Energy PV combined API to InfluxDB

So Thanks to @Colin we have Integration with Tigo Energy and InfluxDB.

Below flow pulls Daily Total, Power summary 1min interval, Power per panel 1min interval, Voltage per panel 1min interval.

[
    {
        "id": "d0455530.3d0f68",
        "type": "tab",
        "label": "TIGO",
        "disabled": false,
        "info": ""
    },
    {
        "id": "9979f3db.00052",
        "type": "http request",
        "z": "d0455530.3d0f68",
        "name": "Tigo - GET combined every minute",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "body",
        "url": "https://api2.tigoenergy.com/api/v3/data/combined?system_id=52705&agg=mi",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "bearer",
        "x": 260,
        "y": 140,
        "wires": [
            [
                "92e981db.9e502"
            ]
        ]
    },
    {
        "id": "fa203d66.3f5e2",
        "type": "debug",
        "z": "d0455530.3d0f68",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "true",
        "targetType": "full",
        "statusVal": "",
        "statusType": "auto",
        "x": 570,
        "y": 300,
        "wires": []
    },
    {
        "id": "a58a338e.020f1",
        "type": "inject",
        "z": "d0455530.3d0f68",
        "name": "Tigo combined 1min - GET every 5min",
        "props": [
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "*/5 4-21 * * *",
        "once": false,
        "onceDelay": 0.1,
        "topic": "pv_pin",
        "payloadType": "str",
        "x": 240,
        "y": 80,
        "wires": [
            [
                "9979f3db.00052"
            ]
        ]
    },
    {
        "id": "dafb110a.c7652",
        "type": "influxdb batch",
        "z": "d0455530.3d0f68",
        "influxdb": "8c468c1f.45eef",
        "precision": "ms",
        "retentionPolicy": "",
        "name": "",
        "database": "database",
        "precisionV18FluxV20": "ms",
        "retentionPolicyV18Flux": "",
        "org": "organisation",
        "bucket": "bucket",
        "x": 1530,
        "y": 320,
        "wires": []
    },
    {
        "id": "92e981db.9e502",
        "type": "function",
        "z": "d0455530.3d0f68",
        "name": "Converting to influxdb format",
        "func": "let measurement = \"PV_Production\"  // set this to your measurement\n// convert to array by splitting on newline\nlet values = msg.payload.split(\"\\n\")\n// discard the first one which is not required\nvalues.shift()\n// and the last which is empty\nvalues.pop()\n// map the array elements to the format required by influx batch node\nvalues = values.map(function(value) {\n    let splits = value.split(\",\")\n    //node.send({payload: value})\n    return {\n        measurement: measurement, \n        fields: { value: Number(splits[1]) },\n        timestamp: Date.parse(splits[0])\n    }\n})\n\nmsg.payload = values\nreturn msg;\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 280,
        "y": 200,
        "wires": [
            [
                "fa203d66.3f5e2",
                "dafb110a.c7652"
            ]
        ]
    },
    {
        "id": "c255d714.cc71f8",
        "type": "http request",
        "z": "d0455530.3d0f68",
        "name": "Tigo - GET combined Day Total",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "body",
        "url": "https://api2.tigoenergy.com/api/v3/data/combined?system_id=xxxxx&agg=d",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "bearer",
        "x": 270,
        "y": 320,
        "wires": [
            [
                "ceb9933c.3d21a",
                "fa203d66.3f5e2"
            ]
        ]
    },
    {
        "id": "ceb9933c.3d21a",
        "type": "function",
        "z": "d0455530.3d0f68",
        "name": "Converting to influxdb format",
        "func": "let measurement = \"PV_Day_Total\"  // set this to your measurement\n// convert to array by splitting on newline\nlet values = msg.payload.split(\"\\n\")\n// discard the first one which is not required\nvalues.shift()\n// and the last which is empty\nvalues.pop()\n// map the array elements to the format required by influx batch node\nvalues = values.map(function(value) {\n    let splits = value.split(\",\")\n    //node.send({payload: value})\n    return {\n        measurement: measurement, \n        fields: { value: Number(splits[1]) },\n        timestamp: Date.now()\n    }\n})\n\nmsg.payload = values\nreturn msg;\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 280,
        "y": 380,
        "wires": [
            [
                "dafb110a.c7652",
                "fa203d66.3f5e2"
            ]
        ]
    },
    {
        "id": "9211e53e.693cb8",
        "type": "inject",
        "z": "d0455530.3d0f68",
        "name": "Tigo Day Total - GET every 1min",
        "props": [
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "*/1 4-21 * * *",
        "once": false,
        "onceDelay": 0.1,
        "topic": "day_total",
        "payloadType": "str",
        "x": 260,
        "y": 260,
        "wires": [
            [
                "c255d714.cc71f8"
            ]
        ]
    },
    {
        "id": "7a36b24d.c39dbc",
        "type": "http request",
        "z": "d0455530.3d0f68",
        "name": "API",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "body",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "bearer",
        "x": 830,
        "y": 440,
        "wires": [
            [
                "64c4d4c4.7cc16c"
            ]
        ]
    },
    {
        "id": "7f02a72e.cc05f8",
        "type": "inject",
        "z": "d0455530.3d0f68",
        "name": "Tigo per panel POWER 1min - GET every 5min",
        "props": [
            {
                "p": "ulr",
                "v": "",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "*/5 4-21 * * *",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payloadType": "str",
        "x": 240,
        "y": 440,
        "wires": [
            [
                "2e3c58b3.166778"
            ]
        ]
    },
    {
        "id": "64c4d4c4.7cc16c",
        "type": "function",
        "z": "d0455530.3d0f68",
        "name": "Converting all columns to influxDB",
        "func": "let measurement = \"Panels\"  // set this to your measurement\n// convert to array by splitting on newline\nlet values = msg.payload.split(\"\\n\")\n// discard the first one which is not required\nvalues.shift()\n// and the last which is empty\nvalues.pop()\n// map the array elements to the format required by influx batch node\nvalues = values.map(function(value) {\n    let splits = value.split(\",\")\n    //node.send({payload: value})\n    return {\n        measurement: measurement, \n        fields: { Panel1: Number(splits[1]), Panel2: Number(splits[2]), Panel3: Number(splits[3]), Panel4: Number(splits[4]), Panel5: Number(splits[5]), Panel6: Number(splits[6]), Panel7: Number(splits[7]), Panel8: Number(splits[8]), Panel9: Number(splits[9]), Panel10: Number(splits[10]), Panel11: Number(splits[11]), Panel12: Number(splits[12])},\n        timestamp: Date.parse(splits[0])\n    }\n})\n\nmsg.payload = values\nreturn msg;\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 260,
        "y": 500,
        "wires": [
            [
                "dafb110a.c7652",
                "fa203d66.3f5e2"
            ]
        ]
    },
    {
        "id": "2e3c58b3.166778",
        "type": "function",
        "z": "d0455530.3d0f68",
        "name": "Unject date NOW to the URL",
        "func": "// get todays date as YYYY-MM-DDT by extracting first 11 characters of ISO format current date/time\nlet day = new Date().toISOString().substr(0,11)\n// build the url\nmsg.url = `https://api2.tigoenergy.com/api/v3/data/aggregate?system_id=xxxxx&agg=mi&start=${day}00:00:00&end=${day}23:59:59&level=min&param=Pin`\nreturn msg;\n\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 600,
        "y": 440,
        "wires": [
            [
                "7a36b24d.c39dbc"
            ]
        ]
    },
    {
        "id": "bc6659c.e2452a8",
        "type": "http request",
        "z": "d0455530.3d0f68",
        "name": "API",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "body",
        "url": "",
        "tls": "",
        "persist": false,
        "proxy": "",
        "authType": "bearer",
        "x": 850,
        "y": 580,
        "wires": [
            [
                "9171d37e.db874"
            ]
        ]
    },
    {
        "id": "2581dd43.28fa72",
        "type": "inject",
        "z": "d0455530.3d0f68",
        "name": "Tigo per panel VOLTAGE 1min - GET every 5min",
        "props": [
            {
                "p": "ulr",
                "v": "",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "*/5 4-21 * * *",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payloadType": "str",
        "x": 250,
        "y": 580,
        "wires": [
            [
                "e963b4bb.3e5df8"
            ]
        ]
    },
    {
        "id": "9171d37e.db874",
        "type": "function",
        "z": "d0455530.3d0f68",
        "name": "Converting all columns to influxDB",
        "func": "let measurement = \"Panels_Voltage\"  // set this to your measurement\n// convert to array by splitting on newline\nlet values = msg.payload.split(\"\\n\")\n// discard the first one which is not required\nvalues.shift()\n// and the last which is empty\nvalues.pop()\n// map the array elements to the format required by influx batch node\nvalues = values.map(function(value) {\n    let splits = value.split(\",\")\n    //node.send({payload: value})\n    return {\n        measurement: measurement, \n        fields: { Panel1v: Number(splits[1]), Panel2v: Number(splits[2]), Panel3v: Number(splits[3]), Panel4v: Number(splits[4]), Panel5v: Number(splits[5]), Panel6v: Number(splits[6]), Panel7v: Number(splits[7]), Panel8v: Number(splits[8]), Panel9v: Number(splits[9]), Panel10v: Number(splits[10]), Panel11v: Number(splits[11]), Panel12v: Number(splits[12])},\n        timestamp: Date.parse(splits[0])\n    }\n})\n\nmsg.payload = values\nreturn msg;\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 280,
        "y": 640,
        "wires": [
            [
                "dafb110a.c7652",
                "fa203d66.3f5e2"
            ]
        ]
    },
    {
        "id": "e963b4bb.3e5df8",
        "type": "function",
        "z": "d0455530.3d0f68",
        "name": "Unject date NOW to the URL",
        "func": "// get todays date as YYYY-MM-DDT by extracting first 11 characters of ISO format current date/time\nlet day = new Date().toISOString().substr(0,11)\n// build the url\nmsg.url = `https://api2.tigoenergy.com/api/v3/data/aggregate?system_id=xxxxx&agg=mi&start=${day}00:00:00&end=${day}23:59:59&level=min&param=Vin`\nreturn msg;\n\n\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 620,
        "y": 580,
        "wires": [
            [
                "bc6659c.e2452a8"
            ]
        ]
    },
    {
        "id": "8c468c1f.45eef",
        "type": "influxdb",
        "hostname": "192.168.10.22",
        "port": "8086",
        "protocol": "http",
        "database": "hassio",
        "name": "IngluxDB-HassioDB",
        "usetls": false,
        "tls": "",
        "influxdbVersion": "1.x",
        "url": "http://192.168.10.22:8086",
        "rejectUnauthorized": true
    }
]

In the flow above you have to specify your system ID in each node with URL and your auth token.

To get token run below command

curl -v -u "{username}:{password}" "https://api2.tigoenergy.com/api/v3/users/login"

In the answer you will receive your auth token.

1 Like