Hi everyone,
I want to use a Shelly 3EM as an electricity meter. Since we have a photovoltaik plant and the shelly measures all three phases separatly (offtake and injection, so six values), I need to calculate the sum of those six values and then add this sum to the Total_Offtake_Value, if it's positive, or to the Total_Injection_Value, if it is negative.
Does someone has an idea, how to do it?
I tried today for many hours but I'm really stuck. Here is what I got so far:
[{"id":"97f3fba943e984d6","type":"tab","label":"Shelly3EM-Saldierend","disabled":false,"info":"","env":[]},{"id":"51bea5337f7ade47","type":"poll-state","z":"97f3fba943e984d6","name":"Energy L1","server":"6f93cefd.a282a","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"60","updateIntervalType":"num","updateIntervalUnits":"seconds","outputinitially":false,"outputonchanged":false,"entity_id":"sensor.netzanschluss_energy_wh_l1","state_type":"num","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":140,"y":60,"wires":[["55a7ba6fef5947c8"]]},{"id":"0d7bb5def0c551c6","type":"poll-state","z":"97f3fba943e984d6","name":"Energy L2","server":"6f93cefd.a282a","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"60","updateIntervalType":"num","updateIntervalUnits":"seconds","outputinitially":false,"outputonchanged":false,"entity_id":"sensor.netzanschluss_energy_wh_l2","state_type":"num","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":140,"y":120,"wires":[["85b50c657fd727aa"]]},{"id":"25add2b98f92aadd","type":"poll-state","z":"97f3fba943e984d6","name":"Energy L3","server":"6f93cefd.a282a","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"60","updateIntervalType":"num","updateIntervalUnits":"seconds","outputinitially":false,"outputonchanged":false,"entity_id":"sensor.netzanschluss_energy_wh_l3","state_type":"num","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":140,"y":180,"wires":[["6c7deb5161590270"]]},{"id":"55a7ba6fef5947c8","type":"change","z":"97f3fba943e984d6","name":"","rules":[{"t":"set","p":"val1","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":60,"wires":[["79ab0d9e3e0694ad"]]},{"id":"85b50c657fd727aa","type":"change","z":"97f3fba943e984d6","name":"","rules":[{"t":"set","p":"val2","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":120,"wires":[["79ab0d9e3e0694ad"]]},{"id":"6c7deb5161590270","type":"change","z":"97f3fba943e984d6","name":"","rules":[{"t":"set","p":"val3","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":180,"wires":[["79ab0d9e3e0694ad"]]},{"id":"79ab0d9e3e0694ad","type":"function","z":"97f3fba943e984d6","name":"Add","func":"var val1 = parseFloat(flow.get(\"val1\") || \"0\");\nvar val2 = parseFloat(flow.get(\"val2\") || \"0\");\nvar val3 = parseFloat(flow.get(\"val3\") || \"0\");\nvar val4 = parseFloat(flow.get(\"val4\") || \"0\");\nvar val5 = parseFloat(flow.get(\"val5\") || \"0\");\nvar val6 = parseFloat(flow.get(\"val6\") || \"0\");\nmsg.payload = val1 + val2 + val3 + val4 + val5 + val6;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":630,"y":200,"wires":[["a6246f4fdf540a36"]]},{"id":"f039ce25dfaa94a9","type":"poll-state","z":"97f3fba943e984d6","name":"Energy Return L1","server":"6f93cefd.a282a","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"60","updateIntervalType":"num","updateIntervalUnits":"seconds","outputinitially":false,"outputonchanged":false,"entity_id":"sensor.netzanschluss_energy_returned_wh_l1","state_type":"num","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":160,"y":240,"wires":[["dc01b377799e8bd5"]]},{"id":"f930237ea5b7c5bb","type":"poll-state","z":"97f3fba943e984d6","name":"Energy Return L2","server":"6f93cefd.a282a","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"60","updateIntervalType":"num","updateIntervalUnits":"seconds","outputinitially":false,"outputonchanged":false,"entity_id":"sensor.netzanschluss_energy_returned_wh_l2","state_type":"num","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":160,"y":300,"wires":[["2ded69d63dbf27f0"]]},{"id":"6e5eb74e4bf8e2af","type":"poll-state","z":"97f3fba943e984d6","name":"Energy Return L3","server":"6f93cefd.a282a","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"60","updateIntervalType":"num","updateIntervalUnits":"seconds","outputinitially":false,"outputonchanged":false,"entity_id":"sensor.netzanschluss_energy_returned_wh_l3","state_type":"num","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":160,"y":360,"wires":[["0728d418a4a07c89"]]},{"id":"dc01b377799e8bd5","type":"change","z":"97f3fba943e984d6","name":"","rules":[{"t":"set","p":"val4","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":240,"wires":[["79ab0d9e3e0694ad"]]},{"id":"2ded69d63dbf27f0","type":"change","z":"97f3fba943e984d6","name":"","rules":[{"t":"set","p":"val5","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":300,"wires":[["79ab0d9e3e0694ad"]]},{"id":"0728d418a4a07c89","type":"change","z":"97f3fba943e984d6","name":"","rules":[{"t":"set","p":"val6","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":380,"y":360,"wires":[["79ab0d9e3e0694ad"]]},{"id":"a6246f4fdf540a36","type":"switch","z":"97f3fba943e984d6","name":"","property":"payload","propertyType":"msg","rules":[{"t":"gt","v":"0","vt":"num"},{"t":"lt","v":"0","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":810,"y":200,"wires":[["17d8b9d0d427e3f8"],["845ff3a026bb6513"]]},{"id":"cde7f47a96ac6a7f","type":"poll-state","z":"97f3fba943e984d6","name":"Offtake","server":"6f93cefd.a282a","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"60","updateIntervalType":"num","updateIntervalUnits":"seconds","outputinitially":false,"outputonchanged":false,"entity_id":"sensor.netzanschluss_netzbezug","state_type":"str","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":110,"y":500,"wires":[["f1dc7bef7ec597a5"]]},{"id":"2c4f82f82ffe30f9","type":"poll-state","z":"97f3fba943e984d6","name":"Injection","server":"6f93cefd.a282a","version":2,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"60","updateIntervalType":"num","updateIntervalUnits":"seconds","outputinitially":false,"outputonchanged":false,"entity_id":"sensor.netzanschluss_einspeisung","state_type":"str","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":120,"y":620,"wires":[["d757b26d77b1c6d8"]]},{"id":"f1dc7bef7ec597a5","type":"change","z":"97f3fba943e984d6","name":"","rules":[{"t":"set","p":"val2","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":500,"wires":[["625e598d3fe4b6a1"]]},{"id":"625e598d3fe4b6a1","type":"function","z":"97f3fba943e984d6","name":"Add","func":"var val1 = parseFloat(flow.get(\"val1\") || \"0\");\nvar val2 = parseFloat(flow.get(\"val2\") || \"0\");\nmsg.payload = val1 + val2;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":630,"y":460,"wires":[[]]},{"id":"17d8b9d0d427e3f8","type":"change","z":"97f3fba943e984d6","name":"","rules":[{"t":"set","p":"val1","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":460,"wires":[["625e598d3fe4b6a1"]]},{"id":"845ff3a026bb6513","type":"change","z":"97f3fba943e984d6","name":"","rules":[{"t":"set","p":"val1","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":580,"wires":[["ebafce8f102aeb61"]]},{"id":"d757b26d77b1c6d8","type":"change","z":"97f3fba943e984d6","name":"","rules":[{"t":"set","p":"val2","pt":"flow","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":340,"y":620,"wires":[["ebafce8f102aeb61"]]},{"id":"ebafce8f102aeb61","type":"function","z":"97f3fba943e984d6","name":"Add","func":"var val1 = parseFloat(flow.get(\"val1\") || \"0\");\nvar val2 = parseFloat(flow.get(\"val2\") || \"0\");\nmsg.payload = val1 + val2;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":630,"y":580,"wires":[[]]},{"id":"6f93cefd.a282a","type":"server","name":"Home Assistant","version":2,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true,"heartbeat":false,"heartbeatInterval":30}]```