Skip to content

Instantly share code, notes, and snippets.

@Phunkafizer
Created December 26, 2022 13:26
Show Gist options
  • Save Phunkafizer/650c8ce7e74ce92b76fc33feb77a137d to your computer and use it in GitHub Desktop.
Save Phunkafizer/650c8ce7e74ce92b76fc33feb77a137d to your computer and use it in GitHub Desktop.
Daily consumption and costs of energy

This flow calculates and visualizes the consumption and costs of the current day. Data input is a MQTT device, in this case the WLAN ACM-ESP gasmeter interface. In node "consumption to cost" you can adjust the parameters for the calculation of costs.

let Z = 0.93; // Zustandszahl
let H = 11.3; //Brennwert kWh / Nm³
let c = 14.32; // Cent / kWh
[{"id":"fc976a32.05c5d8","type":"tab","label":"Flow 2","disabled":false,"info":""},{"id":"7774c3a.676dc3c","type":"mqtt in","z":"fc976a32.05c5d8","name":"","topic":"home/acm-esp/38941273","qos":"2","datatype":"json","broker":"cebc4daa.87b768","x":150,"y":160,"wires":[["6a25e30d.fe0734"]]},{"id":"6a25e30d.fe0734","type":"change","z":"fc976a32.05c5d8","name":"m³","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.values[0].value_scaled","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":160,"wires":[["2e405597.1f7372","7b3b8862.c2d13","17b0e0a0.b4055f"]]},{"id":"2e405597.1f7372","type":"change","z":"fc976a32.05c5d8","name":"set current","rules":[{"t":"set","p":"volume","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":470,"y":100,"wires":[[]]},{"id":"ce991f81.aee358","type":"inject","z":"fc976a32.05c5d8","name":"newday","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 00 * * *","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":120,"y":240,"wires":[["ea23b72c.4a8bb"]]},{"id":"ea23b72c.4a8bb","type":"change","z":"fc976a32.05c5d8","name":"set day start","rules":[{"t":"set","p":"day_start_volume","pt":"flow","to":"volume","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":280,"y":240,"wires":[["7b3b8862.c2d13"]]},{"id":"7b3b8862.c2d13","type":"function","z":"fc976a32.05c5d8","name":"calc consumption of today","func":"if (!flow.get(\"day_start_volume\"))\n flow.set(\"day_start_volume\", flow.get(\"volume\"));\n \nmsg.payload = flow.get(\"volume\") - flow.get(\"day_start_volume\");\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":520,"y":240,"wires":[["2637601d.7bd238","1b43f673.cd5282"]]},{"id":"2637601d.7bd238","type":"ui_text","z":"fc976a32.05c5d8","group":"d15c50bb.6b0f38","order":0,"width":0,"height":0,"name":"day consumption","label":"Tagesverbrauch","format":"{{msg.payload | number:3}} m³","layout":"row-spread","x":790,"y":240,"wires":[]},{"id":"1b43f673.cd5282","type":"function","z":"fc976a32.05c5d8","name":"consumption to cost","func":"let Z = 0.93; // Zustandszahl\nlet H = 11.3; //Brennwert kWh / Nm³\nlet c = 14.32; // Cent / kWh\nmsg.payload = msg.payload * Z * H * c / 100;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":500,"y":320,"wires":[["e3bb58af.2e109"]]},{"id":"e3bb58af.2e109","type":"ui_text","z":"fc976a32.05c5d8","group":"d15c50bb.6b0f38","order":0,"width":0,"height":0,"name":"day costs","label":"Tageskosten","format":"{{msg.payload | number:2}} €","layout":"row-spread","x":700,"y":320,"wires":[]},{"id":"17b0e0a0.b4055f","type":"ui_text","z":"fc976a32.05c5d8","group":"d15c50bb.6b0f38","order":0,"width":0,"height":0,"name":"Meter","label":"Zählerstand","format":"{{msg.payload | number:3}} m³","layout":"row-spread","x":690,"y":160,"wires":[]},{"id":"cebc4daa.87b768","type":"mqtt-broker","name":"","broker":"koepi.fritz.box","port":"1883","clientid":"","usetls":false,"compatmode":false,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"d15c50bb.6b0f38","type":"ui_group","name":"Energie","tab":"3c9b4e17.5d49ea","order":7,"disp":true,"width":"6","collapse":false},{"id":"3c9b4e17.5d49ea","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment