[{"id":"e742210cee3c9419","type":"change","z":"061b2effa3b62ee6","name":"COP calc.","rules":[{"t":"set","p":"payload","pt":"msg","to":"$round(kamstrup.powerinstvalue/youless.powers0, 2)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":400,"y":120,"wires":[["e3aa83424a2ba324"]]},{"id":"a9d7ab5131376508","type":"mqtt out","z":"061b2effa3b62ee6","name":"COP MQTT","topic":"cop","qos":"","retain":"","broker":"b9513c19.e5ca6","x":1110,"y":40,"wires":[]},{"id":"950e1d197f3067ac","type":"change","z":"061b2effa3b62ee6","name":"Set payloads","rules":[{"t":"move","p":"payload","pt":"msg","to":"payload.copcurrent","tot":"msg"},{"t":"set","p":"payload.standbydailyekwh","pt":"msg","to":"standbydailyekwh","tot":"flow"},{"t":"set","p":"payload.standbymonthlyekwh","pt":"msg","to":"standbymonthlyekwh","tot":"flow"},{"t":"set","p":"payload.dhwdailytkwh","pt":"msg","to":"dhwdailytkwh","tot":"flow"},{"t":"set","p":"payload.dhwmonthlytkwh","pt":"msg","to":"dhwmonthlytkwh","tot":"flow"},{"t":"set","p":"payload.heatingdailytkwh","pt":"msg","to":"heatingdailytkwh","tot":"flow"},{"t":"set","p":"payload.heatingmonthlytkwh","pt":"msg","to":"heatingmonthlytkwh","tot":"flow"},{"t":"set","p":"payload.coolingdailytkwh","pt":"msg","to":"coolingdailytkwh","tot":"flow"},{"t":"set","p":"payload.coolingmonthlytkwh","pt":"msg","to":"coolingmonthlytkwh","tot":"flow"},{"t":"set","p":"payload.defrostdailytkwh","pt":"msg","to":"defrostdailytkwh","tot":"flow"},{"t":"set","p":"payload.defrostmonthlytkwh","pt":"msg","to":"defrostmonthlytkwh","tot":"flow"},{"t":"set","p":"payload.dhwdailyekwh","pt":"msg","to":"dhwdailyekwh","tot":"flow"},{"t":"set","p":"payload.dhwmonthlyekwh","pt":"msg","to":"dhwmonthlyekwh","tot":"flow"},{"t":"set","p":"payload.heatingdailyekwh","pt":"msg","to":"heatingdailyekwh","tot":"flow"},{"t":"set","p":"payload.heatingmonthlyekwh","pt":"msg","to":"heatingmonthlyekwh","tot":"flow"},{"t":"set","p":"payload.coolingdailyekwh","pt":"msg","to":"coolingdailyekwh","tot":"flow"},{"t":"set","p":"payload.coolingmonthlyekwh","pt":"msg","to":"coolingmonthlyekwh","tot":"flow"},{"t":"set","p":"payload.defrostdailyekwh","pt":"msg","to":"defrostdailyekwh","tot":"flow"},{"t":"set","p":"payload.defrostmonthlyekwh","pt":"msg","to":"defrostmonthlyekwh","tot":"flow"},{"t":"set","p":"payload.dhwdailycop","pt":"msg","to":"dhwdailycop","tot":"flow"},{"t":"set","p":"payload.dhwmonthlycop","pt":"msg","to":"dhwmonthlycop","tot":"flow"},{"t":"set","p":"payload.heatingdailycop","pt":"msg","to":"heatingdailycop","tot":"flow"},{"t":"set","p":"payload.heatingmonthlycop","pt":"msg","to":"heatingmonthlycop","tot":"flow"},{"t":"set","p":"payload.coolingdailycop","pt":"msg","to":"coolingdailycop","tot":"flow"},{"t":"set","p":"payload.coolingmonthlycop","pt":"msg","to":"coolingmonthlycop","tot":"flow"},{"t":"set","p":"payload.defrostdailycop","pt":"msg","to":"defrostdailycop","tot":"flow"},{"t":"set","p":"payload.defrostmonthlycop","pt":"msg","to":"defrostmonthlycop","tot":"flow"}],"action":"","property":"","from":"","to":"","reg":false,"x":730,"y":120,"wires":[["09fc75118a475c5b","a9d7ab5131376508"]]},{"id":"09fc75118a475c5b","type":"function","z":"061b2effa3b62ee6","name":"Filter","func":"const _msg = {\n payload: []\n};\n\n_msg.payload=\n {\n measurement: \"cop\",\n\t\tfields: {\n\t\t\tcopcurrent: msg.payload.copcurrent||0,\n\t\t\tstandbydailyekwh: msg.payload.standbydailyekwh||0,\n\t\t\tstandbymonthlyekwh: msg.payload.standbymonthlyekwh||0,\n\t\t\tdhwdailytkwh: msg.payload.dhwdailytkwh||0,\n\t\t\tdhwmonthlytkwh: msg.payload.dhwmonthlytkwh||0,\n\t\t\theatingdailytkwh: msg.payload.heatingdailytkwh||0,\n\t\t\theatingmonthlytkwh: msg.payload.heatingmonthlytkwh||0,\n\t\t\tcoolingdailytkwh: msg.payload.coolingdailytkwh||0,\n\t\t\tcoolingmonthlytkwh: msg.payload.coolingmonthlytkwh||0,\n\t\t\tdefrostdailytkwh: msg.payload.defrostdailytkwh||0,\n\t\t\tdefrostmonthlytkwh: msg.payload.defrostmonthlytkwh||0,\n\t\t\tdhwdailyekwh: msg.payload.dhwdailyekwh||0,\n\t\t\tdhwmonthlyekwh: msg.payload.dhwmonthlyekwh||0,\n\t\t\theatingdailyekwh: msg.payload.heatingdailyekwh||0,\n\t\t\theatingmonthlyekwh: msg.payload.heatingmonthlyekwh||0,\n\t\t\tcoolingdailyekwh: msg.payload.coolingdailyekwh||0,\n\t\t\tcoolingmonthlyekwh: msg.payload.coolingmonthlyekwh||0,\n\t\t\tdefrostdailyekwh: msg.payload.defrostdailyekwh||0,\n\t\t\tdefrostmonthlyekwh: msg.payload.defrostmonthlyekwh||0,\n\t\t\tdhwdailycop: msg.payload.dhwdailycop||0,\n\t\t\tdhwmonthlycop: msg.payload.dhwmonthlycop||0,\n\t\t\theatingdailycop: msg.payload.heatingdailycop||0,\n\t\t\theatingmonthlycop: msg.payload.heatingmonthlycop||0,\n\t\t\tcoolingdailycop: msg.payload.coolingdailycop||0,\n\t\t\tcoolingmonthlycop: msg.payload.coolingmonthlycop||0,\n\t\t\tdefrostdailycop: msg.payload.defrostdailycop||0,\n\t\t\tdefrostmonthlycop: msg.payload.defrostmonthlycop||0,\n\t\t\t\t\t},\n\t\ttags:{\n\t\t device: \"cop_calculation\",\n\t\t },\n\t\ttimestamp: new Date(),\n\t}\n\nreturn _msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":470,"y":180,"wires":[["591dd46f9a718dd1","839514148836468d"]]},{"id":"591dd46f9a718dd1","type":"join","z":"061b2effa3b62ee6","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"5","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":630,"y":180,"wires":[["2263313a4cd50617"]]},{"id":"2263313a4cd50617","type":"influxdb batch","z":"061b2effa3b62ee6","influxdb":"d9c81848.1fd1d8","precision":"","retentionPolicy":"","name":"","database":"","retentionPolicyV18Flux":"","org":"","bucket":"","x":840,"y":180,"wires":[]},{"id":"e3aa83424a2ba324","type":"switch","z":"061b2effa3b62ee6","name":"<10","property":"payload","propertyType":"msg","rules":[{"t":"lt","v":"10","vt":"num"}],"checkall":"true","repair":false,"outputs":1,"x":550,"y":120,"wires":[["950e1d197f3067ac"]]},{"id":"a0883419ec2d5dcd","type":"mqtt in","z":"061b2effa3b62ee6","name":"kamstrup","topic":"kamstrup","qos":"2","datatype":"json","broker":"b9513c19.e5ca6","inputs":0,"x":80,"y":120,"wires":[["26822961bad0e488"]]},{"id":"9224851098a7370e","type":"mqtt in","z":"061b2effa3b62ee6","name":"youless","topic":"youless","qos":"2","datatype":"json","broker":"b9513c19.e5ca6","inputs":0,"x":70,"y":60,"wires":[["efd9974a9652600d"]]},{"id":"efd9974a9652600d","type":"change","z":"061b2effa3b62ee6","name":"","rules":[{"t":"set","p":"youless","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":60,"wires":[[]]},{"id":"26822961bad0e488","type":"change","z":"061b2effa3b62ee6","name":"2x flow","rules":[{"t":"set","p":"youless","pt":"msg","to":"youless","tot":"flow"},{"t":"set","p":"kamstrup","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":120,"wires":[["e742210cee3c9419"]]},{"id":"540f4f02e7d293c7","type":"function","z":"061b2effa3b62ee6","name":"DHW t-kWh counter","func":"//Grab previous value from flow variable for total usage\nvar previousvalue = flow.get(\"dhwrunningtkwh\")||msg.payload.heatcountertkwh;\n\n//How much usage since the last update\nvar periodvalue = msg.payload.heatcountertkwh - previousvalue;\n\n//Grab previous value from global variable for daily usage\nvar dailyvalue = flow.get(\"dhwdailytkwh\")||0;\nvar monthlyvalue = flow.get(\"dhwmonthlytkwh\")||0;\n\ndailyvalue = dailyvalue + periodvalue;\nmonthlyvalue = monthlyvalue + periodvalue;\n\n//Update the global variables.\nflow.set(\"dhwdailytkwh\",dailyvalue );\nflow.set(\"dhwrunningtkwh\",msg.payload.heatcountertkwh);\nflow.set(\"dhwmonthlytkwh\",monthlyvalue);\n\nmsg.payload = Number(parseFloat(dailyvalue).toFixed(3))\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":820,"y":280,"wires":[["f1d4d0ad36ea5fb0"]]},{"id":"d6d20a8570e07a1e","type":"switch","z":"061b2effa3b62ee6","name":"Check operating mode","property":"mitsubishi.operation_mode","propertyType":"msg","rules":[{"t":"eq","v":"Stop","vt":"str"},{"t":"eq","v":"Hot Water","vt":"str"},{"t":"eq","v":"Heating","vt":"str"},{"t":"eq","v":"Cooling","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":500,"y":320,"wires":[["86d587a30e75a2b5"],["540f4f02e7d293c7","78c98e5bb5830d5d"],["8ce099914659ef73","ba327dcc3a1a3b5e"],["6de12e8c31fe3ce2","ea5ccdd5245b3b02"]]},{"id":"18860af7f4effe47","type":"mqtt in","z":"061b2effa3b62ee6","name":"","topic":"mitsubishi","qos":"2","datatype":"json","broker":"b9513c19.e5ca6","inputs":0,"x":80,"y":280,"wires":[["90f052b992859e10"]]},{"id":"90f052b992859e10","type":"change","z":"061b2effa3b62ee6","name":"","rules":[{"t":"set","p":"mitsubishi","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":250,"y":280,"wires":[[]]},{"id":"6de12e8c31fe3ce2","type":"function","z":"061b2effa3b62ee6","name":"Cooling t-kWh counter","func":"//Grab previous value from flow variable for total usage\nvar previousvalue = flow.get(\"coolingrunningtkwh\")||msg.payload.coolcountertkwh;\n\n//How much usage since the last update\nvar periodvalue = msg.payload.coolcountertkwh - previousvalue;\n\n//Grab previous value from global variable for daily usage\nvar dailyvalue = flow.get(\"coolingdailytkwh\")||0;\nvar monthlyvalue = flow.get(\"coolingmonthlytkwh\")||0;\n\ndailyvalue = dailyvalue + periodvalue;\nmonthlyvalue = monthlyvalue + periodvalue;\n\n//Update the global variables.\nflow.set(\"coolingdailytkwh\",dailyvalue );\nflow.set(\"coolingrunningtkwh\",msg.payload.coolcountertkwh);\nflow.set(\"coolingmonthlytkwh\",monthlyvalue);\n\nmsg.payload = Number(parseFloat(dailyvalue).toFixed(3))\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":820,"y":440,"wires":[["07ab270d572073b1"]]},{"id":"ba327dcc3a1a3b5e","type":"function","z":"061b2effa3b62ee6","name":"Heating t-kWh counter","func":"//Grab previous value from flow variable for total usage\nvar previousvalue = flow.get(\"heatingrunningtkwh\")||msg.payload.heatcountertkwh;\n\n//How much usage since the last update\nvar periodvalue = msg.payload.heatcountertkwh - previousvalue;\n\n//Grab previous value from global variable for daily usage\nvar dailyvalue = flow.get(\"heatingdailytkwh\")||0;\nvar monthlyvalue = flow.get(\"heatingmonthlytkwh\")||0;\n\ndailyvalue = dailyvalue + periodvalue;\nmonthlyvalue = monthlyvalue + periodvalue;\n\n//Update the global variables.\nflow.set(\"heatingdailytkwh\",dailyvalue );\nflow.set(\"heatingrunningtkwh\",msg.payload.heatcountertkwh);\nflow.set(\"heatingmonthlytkwh\",monthlyvalue);\n\nmsg.payload = Number(parseFloat(dailyvalue).toFixed(3))\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":820,"y":360,"wires":[["fa7bc63acc92ba20"]]},{"id":"4d809151054236e2","type":"function","z":"061b2effa3b62ee6","name":"Defrost t-kWh counter","func":"//Grab previous value from flow variable for total usage\nvar previousvalue = flow.get(\"defrostrunningtkwh\")||msg.payload.coolcountertkwh;\n\n//How much usage since the last update\nvar periodvalue = msg.payload.coolcountertkwh - previousvalue;\n\n//Grab previous value from global variable for daily usage\nvar dailyvalue = flow.get(\"defrostdailytkwh\")||0;\nvar monthlyvalue = flow.get(\"defrostmonthlytkwh\")||0;\n\ndailyvalue = dailyvalue + periodvalue;\nmonthlyvalue = monthlyvalue + periodvalue;\n\n//Update the global variables.\nflow.set(\"defrostdailytkwh\",dailyvalue );\nflow.set(\"defrostrunningtkwh\",msg.payload.coolcountertkwh);\nflow.set(\"defrostmonthlytkwh\",monthlyvalue);\n\nmsg.payload = Number(parseFloat(dailyvalue).toFixed(3))\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":820,"y":520,"wires":[["c9c67fe0c1f5cfed"]]},{"id":"59c72ec41b6c5f6c","type":"mqtt in","z":"061b2effa3b62ee6","name":"kamstrup","topic":"kamstrup","qos":"2","datatype":"json","broker":"b9513c19.e5ca6","inputs":0,"x":80,"y":320,"wires":[["995701ccdea87da5"]]},{"id":"995701ccdea87da5","type":"change","z":"061b2effa3b62ee6","name":"3x flow","rules":[{"t":"set","p":"mitsubishi","pt":"msg","to":"mitsubishi","tot":"flow"},{"t":"set","p":"kamstrup","pt":"msg","to":"payload","tot":"msg"},{"t":"set","p":"youless","pt":"msg","to":"youless","tot":"flow"},{"t":"set","p":"payload.counters0","pt":"msg","to":"$number(youless.counters0)","tot":"jsonata"},{"t":"set","p":"payload.heatcountertkwh","pt":"msg","to":"$number(kamstrup.totalheatenergy)","tot":"jsonata"},{"t":"set","p":"payload.coolcountertkwh","pt":"msg","to":"$number(kamstrup.totalcoolenergy)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":240,"y":320,"wires":[["d6d20a8570e07a1e","036dfb9b1c9acafe","4a3ae3c5ddd62c58","91477a721c6c2d1e"]]},{"id":"86d587a30e75a2b5","type":"function","z":"061b2effa3b62ee6","name":"Standby e-kWh counter","func":"//Grab previous value from flow variable for total usage\nvar previousvalue = flow.get(\"standbyrunningekwh\")||msg.payload.counters0;\n\n//How much usage since the last update\nvar periodvalue = msg.payload.counters0 - previousvalue;\n\n//Grab previous value from global variable for daily usage\nvar dailyvalue = flow.get(\"standbydailyekwh\")||0;\nvar monthlyvalue = flow.get(\"standbymonthlyekwh\")||0;\n\ndailyvalue = dailyvalue + periodvalue;\nmonthlyvalue = monthlyvalue + periodvalue;\n\n//Update the global variables.\nflow.set(\"standbydailyekwh\",dailyvalue );\nflow.set(\"standbyrunningekwh\", msg.payload.counters0);\nflow.set(\"standbymonthlyekwh\",monthlyvalue);\n\nmsg.payload = Number(parseFloat(dailyvalue).toFixed(3))\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":830,"y":240,"wires":[[]]},{"id":"036dfb9b1c9acafe","type":"switch","z":"061b2effa3b62ee6","name":"Check operating mode to reset on !=","property":"mitsubishi.operation_mode","propertyType":"msg","rules":[{"t":"neq","v":"Stop","vt":"str"},{"t":"neq","v":"Hot Water","vt":"str"},{"t":"neq","v":"Heating","vt":"str"},{"t":"neq","v":"Cooling","vt":"str"}],"checkall":"true","repair":false,"outputs":4,"x":190,"y":560,"wires":[["dcb9791d78437e90"],["02dc544dbc78e77f"],["5bd683b32ec54fc9"],["9d21639d34549a2d"]]},{"id":"dcb9791d78437e90","type":"change","z":"061b2effa3b62ee6","name":"Standby reset flow running != ","rules":[{"t":"set","p":"standbyrunningekwh","pt":"flow","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":520,"wires":[[]]},{"id":"02dc544dbc78e77f","type":"change","z":"061b2effa3b62ee6","name":"DHW reset flow running !=","rules":[{"t":"set","p":"dhwrunningtkwh","pt":"flow","to":"0","tot":"num"},{"t":"set","p":"dhwrunningekwh","pt":"flow","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":560,"wires":[[]]},{"id":"5bd683b32ec54fc9","type":"change","z":"061b2effa3b62ee6","name":"Heating reset flow running !=","rules":[{"t":"set","p":"heatingrunningtkwh","pt":"flow","to":"0","tot":"num"},{"t":"set","p":"heatingrunningekwh","pt":"flow","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":600,"wires":[[]]},{"id":"9d21639d34549a2d","type":"change","z":"061b2effa3b62ee6","name":"Cooling reset flow running !=","rules":[{"t":"set","p":"coolingrunningtkwh","pt":"flow","to":"0","tot":"num"},{"t":"set","p":"coolingrunningekwh","pt":"flow","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":640,"wires":[[]]},{"id":"e833e01d963800b8","type":"change","z":"061b2effa3b62ee6","name":"Defrost reset flow running !=","rules":[{"t":"set","p":"defrostrunningtkwh","pt":"flow","to":"0","tot":"num"},{"t":"set","p":"defrostrunningekwh","pt":"flow","to":"0","tot":"num"}],"action":"","property":"","from":"","to":"","reg":false,"x":540,"y":680,"wires":[[]]},{"id":"78c98e5bb5830d5d","type":"function","z":"061b2effa3b62ee6","name":"DHW e-kWh counter","func":"//Grab previous value from flow variable for total usage\nvar previousvalue = flow.get(\"dhwrunningekwh\")||msg.payload.counters0;\n\n//How much usage since the last update\nvar periodvalue = msg.payload.counters0 - previousvalue;\n\n//Grab previous value from global variable for daily usage\nvar dailyvalue = flow.get(\"dhwdailyekwh\")||0;\nvar monthlyvalue = flow.get(\"dhwmonthlyekwh\")||0;\n\ndailyvalue = dailyvalue + periodvalue;\nmonthlyvalue = monthlyvalue + periodvalue;\n\n//Update the global variables.\nflow.set(\"dhwdailyekwh\",dailyvalue );\nflow.set(\"dhwrunningekwh\", msg.payload.counters0);\nflow.set(\"dhwmonthlyekwh\",monthlyvalue);\n\nmsg.payload = Number(parseFloat(dailyvalue).toFixed(3))\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":820,"y":320,"wires":[[]]},{"id":"ea5ccdd5245b3b02","type":"function","z":"061b2effa3b62ee6","name":"Cooling e-kWh counter","func":"//Grab previous value from flow variable for total usage\nvar previousvalue = flow.get(\"coolingrunningekwh\")||msg.payload.counters0;\n\n//How much usage since the last update\nvar periodvalue = msg.payload.counters0 - previousvalue;\n\n//Grab previous value from global variable for daily usage\nvar dailyvalue = flow.get(\"coolingdailyekwh\")||0;\nvar monthlyvalue = flow.get(\"coolingmonthlyekwh\")||0;\n\ndailyvalue = dailyvalue + periodvalue;\nmonthlyvalue = monthlyvalue + periodvalue;\n\n//Update the global variables.\nflow.set(\"coolingdailyekwh\",dailyvalue );\nflow.set(\"coolingrunningekwh\", msg.payload.counters0);\nflow.set(\"coolingmonthlyekwh\",monthlyvalue);\n\nmsg.payload = Number(parseFloat(dailyvalue).toFixed(3))\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":830,"y":480,"wires":[[]]},{"id":"5aaa6df10aef098b","type":"function","z":"061b2effa3b62ee6","name":"Defrost e-kWh counter","func":"//Grab previous value from flow variable for total usage\nvar previousvalue = flow.get(\"defrostrunningekwh\")||msg.payload.counters0;\n\n//How much usage since the last update\nvar periodvalue = msg.payload.counters0 - previousvalue;\n\n//Grab previous value from global variable for daily usage\nvar dailyvalue = flow.get(\"defrostdailyekwh\")||0;\nvar monthlyvalue = flow.get(\"defrostmonthlyekwh\")||0;\n\ndailyvalue = dailyvalue + periodvalue;\nmonthlyvalue = monthlyvalue + periodvalue;\n\n//Update the global variables.\nflow.set(\"defrostdailyekwh\",dailyvalue );\nflow.set(\"defrostrunningekwh\", msg.payload.counters0);\nflow.set(\"defrostmonthlyekwh\",monthlyvalue);\n\nmsg.payload = Number(parseFloat(dailyvalue).toFixed(3))\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":820,"y":560,"wires":[[]]},{"id":"fa7bc63acc92ba20","type":"change","z":"061b2effa3b62ee6","name":"Calculate COP's","rules":[{"t":"set","p":"heatingdailytkwh","pt":"msg","to":"heatingdailytkwh","tot":"flow"},{"t":"set","p":"heatingdailyekwh","pt":"msg","to":"heatingdailyekwh","tot":"flow"},{"t":"set","p":"heatingdailycop","pt":"flow","to":"$round(msg.heatingdailytkwh/msg.heatingdailyekwh,2)","tot":"jsonata"},{"t":"set","p":"heatingmonthlytkwh","pt":"msg","to":"heatingmonthlytkwh","tot":"flow"},{"t":"set","p":"heatingmonthlyekwh","pt":"msg","to":"heatingmonthlyekwh","tot":"flow"},{"t":"set","p":"heatingmonthlycop","pt":"flow","to":"$round(msg.heatingmonthlytkwh/msg.heatingmonthlyekwh,2)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1080,"y":360,"wires":[[]]},{"id":"8ce099914659ef73","type":"function","z":"061b2effa3b62ee6","name":"Heating e-kWh counter","func":"//Grab previous value from flow variable for total usage\nvar previousvalue = flow.get(\"heatingrunningekwh\")||msg.payload.counters0;\n\n//How much usage since the last update\nvar periodvalue = msg.payload.counters0 - previousvalue;\n\n//Grab previous value from global variable for daily usage\nvar dailyvalue = flow.get(\"heatingdailyekwh\")||0;\nvar monthlyvalue = flow.get(\"heatingmonthlyekwh\")||0;\n\ndailyvalue = dailyvalue + periodvalue;\nmonthlyvalue = monthlyvalue + periodvalue;\n\n//Update the global variables.\nflow.set(\"heatingdailyekwh\",dailyvalue );\nflow.set(\"heatingrunningekwh\", msg.payload.counters0);\nflow.set(\"heatingmonthlyekwh\",monthlyvalue);\n\nmsg.payload = Number(parseFloat(dailyvalue).toFixed(3))\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":830,"y":400,"wires":[[]]},{"id":"f1d4d0ad36ea5fb0","type":"change","z":"061b2effa3b62ee6","name":"Calculate COP's","rules":[{"t":"set","p":"dhwdailytkwh","pt":"msg","to":"dhwdailytkwh","tot":"flow"},{"t":"set","p":"dhwdailyekwh","pt":"msg","to":"dhwdailyekwh","tot":"flow"},{"t":"set","p":"dhwdailycop","pt":"flow","to":"$round(msg.dhwdailytkwh/msg.dhwdailyekwh,2)","tot":"jsonata"},{"t":"set","p":"dhwmonthlytkwh","pt":"msg","to":"dhwmonthlytkwh","tot":"flow"},{"t":"set","p":"dhwmonthlyekwh","pt":"msg","to":"dhwmonthlyekwh","tot":"flow"},{"t":"set","p":"dhwmonthlycop","pt":"flow","to":"$round(msg.dhwmonthlytkwh/msg.dhwmonthlyekwh,2)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1080,"y":280,"wires":[[]]},{"id":"07ab270d572073b1","type":"change","z":"061b2effa3b62ee6","name":"Calculate COP's","rules":[{"t":"set","p":"coolingdailytkwh","pt":"msg","to":"coolingdailytkwh","tot":"flow"},{"t":"set","p":"coolingdailyekwh","pt":"msg","to":"coolingdailyekwh","tot":"flow"},{"t":"set","p":"coolingdailycop","pt":"flow","to":"$round(msg.coolingdailytkwh/msg.coolingdailyekwh,2)","tot":"jsonata"},{"t":"set","p":"coolingmonthlytkwh","pt":"msg","to":"coolingmonthlytkwh","tot":"flow"},{"t":"set","p":"coolingmonthlyekwh","pt":"msg","to":"coolingmonthlyekwh","tot":"flow"},{"t":"set","p":"coolingmonthlycop","pt":"flow","to":"$round(msg.coolingmonthlytkwh/msg.coolingmonthlyekwh,2)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1080,"y":440,"wires":[[]]},{"id":"c9c67fe0c1f5cfed","type":"change","z":"061b2effa3b62ee6","name":"Calculate COP's","rules":[{"t":"set","p":"defrostdailytkwh","pt":"msg","to":"defrostdailytkwh","tot":"flow"},{"t":"set","p":"defrostdailyekwh","pt":"msg","to":"defrostdailyekwh","tot":"flow"},{"t":"set","p":"defrostdailycop","pt":"flow","to":"$round(msg.defrostdailytkwh/msg.defrostdailyekwh,2)","tot":"jsonata"},{"t":"set","p":"defrostmonthlytkwh","pt":"msg","to":"defrostmonthlytkwh","tot":"flow"},{"t":"set","p":"defrostmonthlyekwh","pt":"msg","to":"defrostmonthlyekwh","tot":"flow"},{"t":"set","p":"defrostmonthlycop","pt":"flow","to":"$round(msg.defrostmonthlytkwh/msg.defrostmonthlyekwh,2)","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":1080,"y":520,"wires":[[]]},{"id":"4a3ae3c5ddd62c58","type":"switch","z":"061b2effa3b62ee6","name":"Check defrost status","property":"mitsubishi.defrost","propertyType":"msg","rules":[{"t":"eq","v":"Defrost","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":500,"y":380,"wires":[["4d809151054236e2","5aaa6df10aef098b"]]},{"id":"91477a721c6c2d1e","type":"switch","z":"061b2effa3b62ee6","name":"Check defrost status to reset on !=","property":"mitsubishi.defrost","propertyType":"msg","rules":[{"t":"neq","v":"Defrost","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":180,"y":640,"wires":[["e833e01d963800b8"]]},{"id":"839514148836468d","type":"debug","z":"061b2effa3b62ee6","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":580,"y":260,"wires":[]},{"id":"b9513c19.e5ca6","type":"mqtt-broker","name":"MQTT","broker":"core-mosquitto","port":"1883","clientid":"","autoConnect":true,"usetls":false,"protocolVersion":"4","keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","birthMsg":{},"closeTopic":"","closeQos":"0","closePayload":"","closeMsg":{},"willTopic":"","willQos":"0","willPayload":"","willMsg":{},"sessionExpiry":""},{"id":"d9c81848.1fd1d8","type":"influxdb","hostname":"127.0.0.1","port":"8086","protocol":"http","database":"energy","name":"","usetls":false,"tls":"","influxdbVersion":"1.x","url":"","rejectUnauthorized":false}]