I am using the shelly pro 4 PM to switch valves of my floor heating on and off. Switching is done per http request but monitoring uses MQTT. That’s fine unless you want to know your daily energy usage. Therefore, you must read your energy data at midnight per http-request. I have both versions included in the flow. The picture shows the UI of my MQTT monitoring. These are the abbreviation I used (DGWZ: Top floor living room, DGSZ: Top floor bedroom, DGGZ: Top floor guestroom, DGBZ: Top floor bathroom)
[{"id":"8528f6385757181a","type":"tab","label":"Flow 1","disabled":false,"info":"","env":[]},{"id":"fc63440432bd74fe","type":"inject","z":"8528f6385757181a","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":160,"y":200,"wires":[["26b01df177335b0d"]]},{"id":"26b01df177335b0d","type":"http request","z":"8528f6385757181a","name":"http DG pro4pm","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://10.0.0.170/rpc/Shelly.GetStatus","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":320,"y":200,"wires":[["33c8c8ad426e2d72"]]},{"id":"a69c7e5a3d7fd20b","type":"json","z":"8528f6385757181a","name":"json-1","property":"payload","action":"","pretty":false,"x":610,"y":200,"wires":[["c67bb43fc8a3b120","5b55d8ab186c1f8f"]]},{"id":"c67bb43fc8a3b120","type":"debug","z":"8528f6385757181a","name":"debug 40","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":600,"y":160,"wires":[]},{"id":"da82b196bbaca3f0","type":"mqtt in","z":"8528f6385757181a","name":"shellypro4pm-94b97ec035e8/status/#","topic":"shellypro4pm-94b97ec035e8/status/#","qos":"0","datatype":"json","broker":"f5f6599b.7711a8","nl":false,"rap":true,"rh":0,"inputs":0,"x":330,"y":640,"wires":[["06b80f9c00189d15","6f584fead513616f"]]},{"id":"6f584fead513616f","type":"join","z":"8528f6385757181a","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":true,"timeout":"","count":"4","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":590,"y":640,"wires":[["9073f4c2691fabbc","ccb3997e96575bf8"]]},{"id":"9073f4c2691fabbc","type":"function","z":"8528f6385757181a","name":"shelly pro4pm MQTT","func":"let timestamp = Date.now();\n\nlet energy0 = msg.payload[\"shellypro4pm-94b97ec035e8/status/switch:0\"].aenergy.total;\nlet energy1 = msg.payload[\"shellypro4pm-94b97ec035e8/status/switch:1\"].aenergy.total;\nlet energy2 = msg.payload[\"shellypro4pm-94b97ec035e8/status/switch:2\"].aenergy.total;\nlet energy3 = msg.payload[\"shellypro4pm-94b97ec035e8/status/switch:3\"].aenergy.total;\n\nlet totalenergy = parseFloat(((energy0 + energy1 + energy2 + energy3)/1000).toFixed(3));\n\nlet power0 = msg.payload[\"shellypro4pm-94b97ec035e8/status/switch:0\"].apower;\nlet power1 = msg.payload[\"shellypro4pm-94b97ec035e8/status/switch:1\"].apower;\nlet power2 = msg.payload[\"shellypro4pm-94b97ec035e8/status/switch:2\"].apower;\nlet power3 = msg.payload[\"shellypro4pm-94b97ec035e8/status/switch:3\"].apower;\n\nlet totalpower = parseFloat((power0 + power1 + power2 + power3).toFixed(2));\n\nlet current0 = msg.payload[\"shellypro4pm-94b97ec035e8/status/switch:0\"].current;\nlet current1 = msg.payload[\"shellypro4pm-94b97ec035e8/status/switch:1\"].current;\nlet current2 = msg.payload[\"shellypro4pm-94b97ec035e8/status/switch:2\"].current;\nlet current3 = msg.payload[\"shellypro4pm-94b97ec035e8/status/switch:3\"].current;\n\nlet totalcurrent = parseFloat(((current0 + current1 + current2 + current3)/4).toFixed(3));\n\nlet voltage0 = msg.payload[\"shellypro4pm-94b97ec035e8/status/switch:0\"].voltage;\nlet voltage1 = msg.payload[\"shellypro4pm-94b97ec035e8/status/switch:1\"].voltage;\nlet voltage2 = msg.payload[\"shellypro4pm-94b97ec035e8/status/switch:2\"].voltage;\nlet voltage3 = msg.payload[\"shellypro4pm-94b97ec035e8/status/switch:3\"].voltage;\n\nlet totalvoltage = parseFloat(((voltage0 + voltage1 + voltage2 + voltage3)/4).toFixed(2));\n\nlet totaltemperature = parseFloat((msg.payload[\"shellypro4pm-94b97ec035e8/status/switch:0\"].temperature.tC).toFixed(2));\n\nlet stat0 = msg.payload[\"shellypro4pm-94b97ec035e8/status/switch:0\"].output === false ? '<font color=\"#000000\">off</font>' : '<font color=\"#ff0000\">on</font>';\nlet stat1 = msg.payload[\"shellypro4pm-94b97ec035e8/status/switch:1\"].output === false ? '<font color=\"#000000\">off</font>' : '<font color=\"#ff0000\">on</font>';\nlet stat2 = msg.payload[\"shellypro4pm-94b97ec035e8/status/switch:2\"].output === false ? '<font color=\"#000000\">off</font>' : '<font color=\"#ff0000\">on</font>';\nlet stat3 = msg.payload[\"shellypro4pm-94b97ec035e8/status/switch:3\"].output === false ? '<font color=\"#000000\">off</font>' : '<font color=\"#ff0000\">on</font>';\n\nreturn[\n {payload:timestamp},\n {payload:totalenergy},\n {payload:totalpower},\n {payload:totalcurrent},\n {payload:totalvoltage},\n {payload:totaltemperature}, \n {payload:stat0},\n {payload:stat1},\n {payload:stat2},\n {payload:stat3},\n {payload:power0, topic:\"DGWZ\"},\n {payload:power1, topic:\"DGSZ\"},\n {payload:power2, topic:\"DGGZ\"},\n {payload:power3, topic:\"DGBZ\"} \n];","outputs":14,"noerr":0,"initialize":"","finalize":"","libs":[],"x":800,"y":640,"wires":[["8d94366c53bf9312"],["7ab7ad35be485d58"],["ff35a2330dd21926"],["b890cc2a46adfb5d"],["94748e86d2b4afa8"],["6d87810f88630b7d"],["673547a91eb9aa2b"],["36b26feee1c191d8"],["79c2510a7d2ccf64"],["82ca04d9509ecf63"],["7ef526d2ba4cadd8"],["7ef526d2ba4cadd8"],["7ef526d2ba4cadd8"],["7ef526d2ba4cadd8"]],"outputLabels":["timestamp","totalernergy","power gauge","current","voltage","temperature","status 0","status 1","status 2","status 3","power 0","power 1","power 2","power 3"]},{"id":"8d94366c53bf9312","type":"moment","z":"8528f6385757181a","name":"HH:mm:ss DD-MM-YYYY","topic":"","input":"","inputType":"msg","inTz":"Europe/Berlin","adjAmount":0,"adjType":"days","adjDir":"add","format":"HH:mm:ss DD-MM-YYYY","locale":"de-DE","output":"payload","outputType":"msg","outTz":"Europe/Berlin","x":1130,"y":420,"wires":[["14d66e212b7665aa"]]},{"id":"5b55d8ab186c1f8f","type":"function","z":"8528f6385757181a","name":"shelly pro4pm http","func":"let timestamp = Date.now();\n\nlet energy0 = msg.payload[\"switch:0\"].aenergy.total;\nlet energy1 = msg.payload[\"switch:1\"].aenergy.total;\nlet energy2 = msg.payload[\"switch:2\"].aenergy.total;\nlet energy3 = msg.payload[\"switch:3\"].aenergy.total;\n\nlet totalenergy = parseFloat(((energy0 + energy1 + energy2 + energy3)/1000).toFixed(3)) + \" kWh\";\n\nlet power0 = msg.payload[\"switch:0\"].apower;\nlet power1 = msg.payload[\"switch:1\"].apower;\nlet power2 = msg.payload[\"switch:2\"].apower;\nlet power3 = msg.payload[\"switch:3\"].apower;\n\nlet totalpower = parseFloat((power0 + power1 + power2 + power3).toFixed(2)) + \" Watt\";\n\nlet current0 = msg.payload[\"switch:0\"].current;\nlet current1 = msg.payload[\"switch:1\"].current;\nlet current2 = msg.payload[\"switch:2\"].current;\nlet current3 = msg.payload[\"switch:3\"].current;\n\nlet totalcurrent = parseFloat(((current0 + current1 + current2 + current3)/4).toFixed(3)) + \" amp\";\n\nlet voltage0 = msg.payload[\"switch:0\"].voltage;\nlet voltage1 = msg.payload[\"switch:1\"].voltage;\nlet voltage2 = msg.payload[\"switch:2\"].voltage;\nlet voltage3 = msg.payload[\"switch:3\"].voltage;\n\nlet totalvoltage = parseFloat(((voltage0 + voltage1 + voltage2 + voltage3)/4).toFixed(2)) + \" Volt\";\n\nlet temperature0 = msg.payload[\"switch:0\"].temperature.tC;\nlet temperature1 = msg.payload[\"switch:1\"].temperature.tC;\nlet temperature2 = msg.payload[\"switch:2\"].temperature.tC;\nlet temperature3 = msg.payload[\"switch:3\"].temperature.tC;\n\nlet temperature = parseFloat(((temperature0 + temperature1 + temperature2 + temperature3) / 4).toFixed(2)) + \" °C\";\n\nreturn [\n {payload:timestamp},\n {payload:totalenergy},\n {payload:totalpower},\n {payload:totalcurrent},\n {payload:totalvoltage},\n {payload:temperature} \n ];","outputs":6,"noerr":0,"initialize":"","finalize":"","libs":[],"x":810,"y":200,"wires":[["82a9d94f95bac91e"],["6e5f2e12700986de"],["cbc18ef635a7668d"],["90ed0a06a4ad9ee2"],["dfeac06b4cc9e127"],["59e820f1bbeab395"]],"outputLabels":["timestamp","energy","power","current","voltage","temperature"]},{"id":"6e5f2e12700986de","type":"debug","z":"8528f6385757181a","name":"energy","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1070,"y":140,"wires":[]},{"id":"cbc18ef635a7668d","type":"debug","z":"8528f6385757181a","name":"power","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1070,"y":180,"wires":[]},{"id":"90ed0a06a4ad9ee2","type":"debug","z":"8528f6385757181a","name":"current","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1080,"y":220,"wires":[]},{"id":"dfeac06b4cc9e127","type":"debug","z":"8528f6385757181a","name":"voltage","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1080,"y":260,"wires":[]},{"id":"4c944aef2d5c4615","type":"debug","z":"8528f6385757181a","name":"timestamp","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1330,"y":100,"wires":[]},{"id":"82a9d94f95bac91e","type":"moment","z":"8528f6385757181a","name":"HH:mm:ss DD-MM-YYYY","topic":"","input":"","inputType":"msg","inTz":"Europe/Berlin","adjAmount":0,"adjType":"days","adjDir":"add","format":"HH:mm:ss DD:MM:YYYY","locale":"de-DE","output":"payload","outputType":"msg","outTz":"Europe/Berlin","x":1130,"y":100,"wires":[["4c944aef2d5c4615"]]},{"id":"14d66e212b7665aa","type":"ui_text","z":"8528f6385757181a","group":"df0f5cfff9c55580","order":1,"width":0,"height":0,"name":"","label":"","format":"{{msg.payload}}","layout":"row-center","className":"","x":1310,"y":420,"wires":[]},{"id":"ff35a2330dd21926","type":"ui_gauge","z":"8528f6385757181a","name":"power gauge","group":"df0f5cfff9c55580","order":2,"width":6,"height":3,"gtype":"gage","title":"","label":"Watt","format":"{{value}}","min":0,"max":"50","colors":["#00b500","#e6e600","#ca3838"],"seg1":"30","seg2":"40","className":"","x":1090,"y":500,"wires":[]},{"id":"7ef526d2ba4cadd8","type":"ui_chart","z":"8528f6385757181a","name":"power chart","group":"df0f5cfff9c55580","order":19,"width":6,"height":6,"label":"12h Verlauf","chartType":"line","legend":"true","xformat":"HH:mm:ss","interpolate":"linear","nodata":"","dot":false,"ymin":"0","ymax":"50","removeOlder":1,"removeOlderPoints":"","removeOlderUnit":"3600","cutout":0,"useOneColor":false,"useUTC":false,"colors":["#26f234","#f52933","#000000","#2c1ef1","#fafafa","#ffffff","#fdfcfc","#fcfcfd","#fcfcfc"],"outputs":1,"useDifferentColor":false,"className":"","x":1090,"y":820,"wires":[[]]},{"id":"ccb3997e96575bf8","type":"debug","z":"8528f6385757181a","name":"debug 41","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":600,"y":600,"wires":[]},{"id":"673547a91eb9aa2b","type":"ui_text","z":"8528f6385757181a","group":"df0f5cfff9c55580","order":14,"width":1,"height":1,"name":"Stat 0","label":"","format":"{{msg.payload}}","layout":"row-center","className":"","x":1070,"y":660,"wires":[]},{"id":"36b26feee1c191d8","type":"ui_text","z":"8528f6385757181a","group":"df0f5cfff9c55580","order":15,"width":1,"height":1,"name":"Stat 1","label":"","format":"{{msg.payload}}","layout":"row-center","className":"","x":1070,"y":700,"wires":[]},{"id":"79c2510a7d2ccf64","type":"ui_text","z":"8528f6385757181a","group":"df0f5cfff9c55580","order":16,"width":1,"height":1,"name":"Stat 2","label":"","format":"{{msg.payload}}","layout":"row-center","className":"","x":1070,"y":740,"wires":[]},{"id":"82ca04d9509ecf63","type":"ui_text","z":"8528f6385757181a","group":"df0f5cfff9c55580","order":17,"width":1,"height":1,"name":"Stat 3","label":"","format":"{{msg.payload}}","layout":"row-center","className":"","x":1070,"y":780,"wires":[]},{"id":"7ab7ad35be485d58","type":"ui_text","z":"8528f6385757181a","group":"df0f5cfff9c55580","order":4,"width":"3","height":"1","name":"totalenergy","label":"","format":"{{msg.payload}} kWh","layout":"row-center","className":"","x":1090,"y":460,"wires":[]},{"id":"94748e86d2b4afa8","type":"ui_text","z":"8528f6385757181a","group":"df0f5cfff9c55580","order":3,"width":"3","height":"1","name":"Voltage","label":"","format":"{{msg.payload}} Volt","layout":"row-center","className":"","x":1080,"y":580,"wires":[]},{"id":"b890cc2a46adfb5d","type":"ui_text","z":"8528f6385757181a","group":"df0f5cfff9c55580","order":5,"width":"3","height":"1","name":"Current","label":"","format":"{{msg.payload}} amp","layout":"row-center","className":"","x":1080,"y":540,"wires":[]},{"id":"634cd2c4056a81b0","type":"inject","z":"8528f6385757181a","name":"","props":[{"p":"payload"}],"repeat":"","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":570,"y":800,"wires":[["97f69ea94e381c40"]]},{"id":"aa0c70b4b3837733","type":"function","z":"8528f6385757181a","name":"init color/room","func":"node.send({\"topic\":\"DGWZ\",\"payload\":\"0.0\"});\nnode.send({\"topic\":\"DGSZ\",\"payload\":\"0.0\"});\nnode.send({\"topic\":\"DGGZ\",\"payload\":\"0.0\"});\nnode.send({\"topic\":\"DGBZ\",\"payload\":\"0.0\"});\nreturn null;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":820,"y":840,"wires":[["7ef526d2ba4cadd8"]]},{"id":"33c8c8ad426e2d72","type":"switch","z":"8528f6385757181a","name":"200","property":"statusCode","propertyType":"msg","rules":[{"t":"eq","v":"200","vt":"str"},{"t":"neq","v":"200","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":470,"y":200,"wires":[["a69c7e5a3d7fd20b"],["453c6f907ae3eef6"]]},{"id":"70a780d05f80ddf6","type":"mqtt out","z":"8528f6385757181a","name":"to Telegram out","topic":"Heizung-Telegram","qos":"0","retain":"","respTopic":"","contentType":"","userProps":"","correl":"","expiry":"","broker":"f5f6599b.7711a8","x":740,"y":1020,"wires":[]},{"id":"11bf993144b68fb9","type":"function","z":"8528f6385757181a","name":"","func":"msg.payload = \"Fehlerzeitpunkt: \" + msg.payload + \" / \" +\n \"Flow: Monitor shellyplug s\" + \" / \" +\n \"Fehlermeldung: \" + msg.error.message + \" / \" +\n \"Fehler ID: \"+ msg.error.source.id + \" / \" +\n \"Fehlertyp: \" + msg.error.source.type + \" / \" +\n \"Fehlernode: \" + msg.error.source.name + \" / \" + \n \"Fehlerzähler: \" + msg.error.source.count;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":520,"y":1040,"wires":[["70a780d05f80ddf6"]]},{"id":"056c05e9dad155d2","type":"moment","z":"8528f6385757181a","name":"HH:mm:ss DD:MM:YYYY","topic":"","input":"xyz","inputType":"flow","inTz":"Europe/Berlin","adjAmount":0,"adjType":"days","adjDir":"add","format":"HH:mm:ss DD:MM:YYYY","locale":"de_DE","output":"","outputType":"msg","outTz":"Europe/Berlin","x":330,"y":1040,"wires":[["11bf993144b68fb9"]]},{"id":"e02da1d559453e7d","type":"catch","z":"8528f6385757181a","name":"All errors","scope":null,"uncaught":false,"x":140,"y":1040,"wires":[["056c05e9dad155d2"]]},{"id":"97f69ea94e381c40","type":"change","z":"8528f6385757181a","name":"reset chart","rules":[{"t":"set","p":"payload","pt":"msg","to":"[]","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":830,"y":800,"wires":[["7ef526d2ba4cadd8","aa0c70b4b3837733"]]},{"id":"6d87810f88630b7d","type":"ui_text","z":"8528f6385757181a","group":"df0f5cfff9c55580","order":6,"width":"3","height":"1","name":"Temperature","label":"","format":"{{msg.payload}} °C","layout":"row-center","className":"","x":1090,"y":620,"wires":[]},{"id":"06b80f9c00189d15","type":"trigger","z":"8528f6385757181a","name":"","op1":"","op2":"","op1type":"nul","op2type":"date","duration":"10","extend":true,"overrideDelay":false,"units":"min","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":250,"y":700,"wires":[["d4749eb1d3e78361"]]},{"id":"d4749eb1d3e78361","type":"change","z":"8528f6385757181a","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"DG Shelly Pro 4 MQTT 5 min offline","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":420,"y":700,"wires":[["32f03196793e0597"]]},{"id":"453c6f907ae3eef6","type":"change","z":"8528f6385757181a","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"DG Shelly Pro 4 http-requestnicht erfolgreich","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":280,"wires":[["a33721178ee96205"]]},{"id":"59e820f1bbeab395","type":"debug","z":"8528f6385757181a","name":"temperatgure","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1090,"y":300,"wires":[]},{"id":"00964306ea477282","type":"link in","z":"8528f6385757181a","name":"error","links":["a33721178ee96205","32f03196793e0597"],"x":565,"y":1000,"wires":[["70a780d05f80ddf6"]]},{"id":"a33721178ee96205","type":"link out","z":"8528f6385757181a","name":"link out 5","mode":"link","links":["00964306ea477282"],"x":475,"y":280,"wires":[]},{"id":"32f03196793e0597","type":"link out","z":"8528f6385757181a","name":"link out 6","mode":"link","links":["00964306ea477282"],"x":535,"y":700,"wires":[]},{"id":"b3fdf367e012f73f","type":"ui_spacer","z":"8528f6385757181a","name":"spacer","group":"df0f5cfff9c55580","order":13,"width":1,"height":1},{"id":"9948302efc9c0953","type":"ui_spacer","z":"8528f6385757181a","name":"spacer","group":"df0f5cfff9c55580","order":18,"width":1,"height":1},{"id":"f5f6599b.7711a8","type":"mqtt-broker","broker":"10.0.0.43","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":4,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","willTopic":"","willQos":"0","willPayload":""},{"id":"df0f5cfff9c55580","type":"ui_group","name":"DG Shelly pro 4 pm","tab":"f71b0643ae027237","order":1,"disp":true,"width":"6","collapse":false,"className":""},{"id":"f71b0643ae027237","type":"ui_tab","name":"test shelly pro4pm","icon":"dashboard","order":1,"disabled":false,"hidden":false}]