UNPKG

node-red-contrib-tibber-api

Version:

Node Red module for integrating with Tibber api

322 lines 9.64 kB
[ { "id": "683fd7.e63da028", "type": "tab", "label": "Home Energy", "disabled": false, "info": "" }, { "id": "b970f3b0.3ff74", "type": "tibber-feed", "z": "683fd7.e63da028", "name": "", "active": true, "apiEndpointRef": "d4450078.a5f12", "homeId": "96a14971-525a-4420-aae9-e5aedaa129ff", "timestamp": "1", "power": "1", "lastMeterConsumption": "1", "accumulatedConsumption": "1", "accumulatedProduction": "1", "accumulatedConsumptionLastHour": true, "accumulatedProductionLastHour": true, "accumulatedCost": "1", "accumulatedReward": "1", "currency": "1", "minPower": "1", "averagePower": "1", "maxPower": "1", "powerProduction": "1", "minPowerProduction": "1", "maxPowerProduction": "1", "lastMeterProduction": "1", "powerFactor": "1", "voltagePhase1": "1", "voltagePhase2": "1", "voltagePhase3": "1", "currentL1": "1", "currentL2": "1", "currentL3": "1", "signalStrength": true, "x": 140, "y": 300, "wires": [ [ "1491f46.f317b0c" ] ] }, { "id": "4d0b020a.94fbac", "type": "debug", "z": "683fd7.e63da028", "name": "", "active": false, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 590, "y": 360, "wires": [] }, { "id": "2773a5f1.d99aca", "type": "tibber-query", "z": "683fd7.e63da028", "name": "", "active": true, "apiEndpointRef": "d4450078.a5f12", "x": 370, "y": 100, "wires": [ [ "4a25248d.5e506c" ] ] }, { "id": "983cd36.d80383", "type": "inject", "z": "683fd7.e63da028", "name": "Get Home Id", "props": [ { "p": "payload", "v": "{ viewer { homes { id address { address1 address2 address3 postalCode city country latitude longitude } } } }", "vt": "str" }, { "p": "topic", "v": "", "vt": "str" } ], "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "{ viewer { homes { id address { address1 address2 address3 postalCode city country latitude longitude } } } }", "payloadType": "str", "x": 150, "y": 100, "wires": [ [ "2773a5f1.d99aca" ] ] }, { "id": "4a25248d.5e506c", "type": "debug", "z": "683fd7.e63da028", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 550, "y": 100, "wires": [] }, { "id": "e0404127.1a2f8", "type": "http request", "z": "683fd7.e63da028", "name": "", "method": "POST", "ret": "txt", "paytoqs": false, "url": "http://influxdb:8086/write?precision=s&consistency=any&db=test", "tls": "", "proxy": "", "authType": "", "x": 590, "y": 300, "wires": [ [ "4d0b020a.94fbac" ] ] }, { "id": "1491f46.f317b0c", "type": "function", "z": "683fd7.e63da028", "name": "Transform payload", "func": "let p = msg.payload;\n\nif (!p.voltagePhase1)\n return null;\n\nfor (var prop in p) {\n if (!p[prop])\n p[prop] = 0;\n}\n\n// Meassurement\nlet data = \"power\";\n\n// Tag set\ndata += \",location=test\";\ndata += \",currency=\" + p.currency;\n\n// Field set\ndata += \" power=\" + p.power;\ndata += \",lastMeterConsumption=\" + p.lastMeterConsumption;\ndata += \",accumulatedConsumption=\" + p.accumulatedConsumption;\ndata += \",accumulatedProduction=\" + p.accumulatedProduction;\ndata += \",accumulatedCost=\" + p.accumulatedCost;\ndata += \",accumulatedReward=\" + p.accumulatedReward;\ndata += \",minPower=\" + p.minPower;\ndata += \",averagePower=\" + p.averagePower;\ndata += \",maxPower=\" + p.maxPower;\ndata += \",powerProduction=\" + p.powerProduction;\ndata += \",minPowerProduction=\" + p.minPowerProduction;\ndata += \",maxPowerProduction=\" + p.maxPowerProduction;\ndata += \",lastMeterProduction=\" + p.lastMeterProduction;\ndata += \",powerFactor=\" + p.powerFactor;\ndata += \",voltagePhase1=\" + p.voltagePhase1;\ndata += \",voltagePhase2=\" + p.voltagePhase2;\ndata += \",voltagePhase3=\" + p.voltagePhase3;\ndata += \",currentL1=\" + p.currentL1;\ndata += \",currentL2=\" + p.currentL2;\ndata += \",currentL3=\" + p.currentL3;\n\nmsg.payload = data;\n\nreturn msg;\n", "outputs": 1, "noerr": 0, "x": 390, "y": 300, "wires": [ [ "e0404127.1a2f8" ] ] }, { "id": "4286466c.a02e08", "type": "http request", "z": "683fd7.e63da028", "name": "", "method": "POST", "ret": "txt", "paytoqs": false, "url": "http://influxdb:8086/query?q=CREATE%20DATABASE%20%22test%22", "tls": "", "proxy": "", "authType": "", "x": 370, "y": 40, "wires": [ [ "d102d972.8fb0c8" ] ] }, { "id": "b24ffef4.c3ca", "type": "inject", "z": "683fd7.e63da028", "name": "Create test database", "repeat": "", "crontab": "", "once": false, "onceDelay": 0.1, "topic": "", "payload": "", "payloadType": "str", "x": 170, "y": 40, "wires": [ [ "4286466c.a02e08" ] ] }, { "id": "d102d972.8fb0c8", "type": "debug", "z": "683fd7.e63da028", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "false", "x": 550, "y": 40, "wires": [] }, { "id": "165b29ab.c7bef6", "type": "tibber-query", "z": "683fd7.e63da028", "name": "", "active": true, "apiEndpointRef": "d4450078.a5f12", "x": 370, "y": 180, "wires": [ [ "9f49c320.526db" ] ] }, { "id": "425b3d0d.8f10d4", "type": "inject", "z": "683fd7.e63da028", "name": "Daily energy prices", "props": [ { "p": "payload", "v": "{ viewer { homes { currentSubscription { priceInfo { today { total energy tax startsAt currency level } } } } } }", "vt": "str" }, { "p": "topic", "v": "", "vt": "str" } ], "repeat": "", "crontab": "30 00 * * *", "once": false, "onceDelay": 0.1, "topic": "", "payload": "{ viewer { homes { currentSubscription { priceInfo { today { total energy tax startsAt currency level } } } } } }", "payloadType": "str", "x": 180, "y": 180, "wires": [ [ "165b29ab.c7bef6" ] ] }, { "id": "810b8faa.9656a", "type": "debug", "z": "683fd7.e63da028", "name": "", "active": true, "tosidebar": true, "console": false, "tostatus": false, "complete": "payload", "targetType": "msg", "x": 550, "y": 240, "wires": [] }, { "id": "9f49c320.526db", "type": "function", "z": "683fd7.e63da028", "name": "Transform energy price", "func": "let pl = msg.payload;\n\nlet prices = pl.viewer.homes[0].currentSubscription.priceInfo.today;\n\n// Meassurement\nlet data = \"\";\n\nfor(let i = 0; i < prices.length; i++)\n{\n let p = prices[i];\n data += \"energy\";\n\n // Tag set\n data += \",location=test\";\n data += \",currency=\" + p.currency;\n \n // Field set\n data += \" total=\" + p.total;\n data += \",energy=\" + p.energy;\n data += \",tax=\" + p.tax;\n data += \",level=\\\"\" + p.level + \"\\\"\";\n data += \" \" + new Date(p.startsAt).getTime() / 1000 + \"\";\n data += \"\\n\";\n}\n\nmsg.payload = data;\n\nreturn msg;", "outputs": 1, "noerr": 0, "x": 590, "y": 180, "wires": [ [ "c478abbd.5715e8" ] ] }, { "id": "c478abbd.5715e8", "type": "http request", "z": "683fd7.e63da028", "name": "", "method": "POST", "ret": "txt", "paytoqs": false, "url": "http://influxdb:8086/write?precision=s&consistency=any&db=test", "tls": "", "proxy": "", "authType": "", "x": 370, "y": 240, "wires": [ [ "810b8faa.9656a" ] ] }, { "id": "d4450078.a5f12", "type": "tibber-api-endpoint", "queryUrl": "https://api.tibber.com/v1-beta/gql", "feedConnectionTimeout": "30", "feedTimeout": "60", "queryRequestTimeout": "30", "name": "Demo" } ]