Tibber Pulse - Home energy monitor

Tibber Pulse - Home energy monitor

General

Use this flow as an example for how to monitor home energy consumtion using Tibber Pulse, Node-Red and Grafana.

For more information, see node-red-contrib-tibber-api

Resources

[{"id":"683fd7.e63da028","type":"tab","label":"Home Energy","disabled":false,"info":""},{"id":"b970f3b0.3ff74","type":"tibber-feed","z":"683fd7.e63da028","name":"","active":true,"apiEndpointRef":"8a80f84f.0cbd98","homeId":"c70dcbe5-4485-4821-933d-a8a86452737b","timestamp":"1","power":"1","lastMeterConsumption":"1","accumulatedConsumption":"1","accumulatedProduction":"1","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","currentPhase1":"1","currentPhase2":"1","currentPhase3":"1","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":"8a80f84f.0cbd98","x":370,"y":100,"wires":[["4a25248d.5e506c"]]},{"id":"983cd36.d80383","type":"inject","z":"683fd7.e63da028","name":"Get Home Id","topic":"","payload":"{   viewer {     homes {       id       address {         address1         address2         address3         postalCode         city         country         latitude         longitude                }     }   } }","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"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 += \",currentPhase1=\" + p.currentPhase1;\ndata += \",currentPhase2=\" + p.currentPhase2;\ndata += \",currentPhase3=\" + p.currentPhase3;\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","topic":"","payload":"","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"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":"8a80f84f.0cbd98","x":370,"y":180,"wires":[["9f49c320.526db"]]},{"id":"425b3d0d.8f10d4","type":"inject","z":"683fd7.e63da028","name":"Daily energy prices","topic":"","payload":"{   viewer {     homes {       currentSubscription {         priceInfo {           today {             total             energy             tax             startsAt             currency             level           }         }       }     }   } }","payloadType":"str","repeat":"","crontab":"30 00 * * *","once":false,"onceDelay":0.1,"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":"8a80f84f.0cbd98","type":"tibber-api-endpoint","z":"","feedUrl":"wss://api.tibber.com/v1-beta/gql/subscriptions","queryUrl":"https://api.tibber.com/v1-beta/gql","apiKey":"d1007ead2dc84a2b82f0de19451c5fb22112f7ae11d19bf2bedb224a003ff74a","name":"Demo"}]

Collection Info

next

Flow Info

Created 5 years ago
Updated 3 years, 11 months ago
Rating: not yet rated

Owner

Actions

Rate:

Node Types

Core
  • debug (x4)
  • function (x2)
  • http request (x3)
  • inject (x3)
Other

Tags

  • tibber
  • pulse
  • home-automation
  • iot
  • power
  • energy
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option