Greetings,
I have been struggling to put together this logic.
If pvwatts >= 800 and soc >= 80 then 2 (turn on inverter) else 3 (turn off inverter). I have tried with the javascript below but it never works...as it never combines both inputs.
var soc = Number(msg.payload.soc);
var pvwatts = Number(msg.payload.pvwatts);
if (pvwatts >= 800 && soc >= 80) {
msg.payload = 2;
}
else {
msg.payload = 3;
}
return msg;
Then i tried with switch nodes and change nodes but i dont know how to merge the two, like if SoC and PVwatts match then true.
[{"id":"eec3780d.de5d48","type":"switch","z":"fbf7f30b.ec577","name":"SoC Switch","property":"payload.value","propertyType":"msg","rules":[{"t":"gt","v":"80","vt":"num"},{"t":"lt","v":"30","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":610,"y":1300,"wires":[["c2b5ec31.cc86b"],["b2fe8568.be5b08"]]},{"id":"c2b5ec31.cc86b","type":"change","z":"fbf7f30b.ec577","name":"Turn Inverter On","rules":[{"t":"set","p":"payload","pt":"msg","to":"2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":1280,"wires":[["6198a44a.3b204c"]]},{"id":"b2fe8568.be5b08","type":"change","z":"fbf7f30b.ec577","name":"Turn Inverter Off","rules":[{"t":"set","p":"payload","pt":"msg","to":"3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":1320,"wires":[[]]},{"id":"73f256c0.29d388","type":"switch","z":"fbf7f30b.ec577","name":"PVWatts Switch","property":"payload.value","propertyType":"msg","rules":[{"t":"gt","v":"800","vt":"num"},{"t":"lt","v":"800","vt":"num"}],"checkall":"true","repair":false,"outputs":2,"x":620,"y":1340,"wires":[["764190a2.3832b"],["ba10e458.b736b8"]]},{"id":"764190a2.3832b","type":"change","z":"fbf7f30b.ec577","name":"Turn Inverter On","rules":[{"t":"set","p":"payload","pt":"msg","to":"2","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":1380,"wires":[["6198a44a.3b204c"]]},{"id":"ba10e458.b736b8","type":"change","z":"fbf7f30b.ec577","name":"Turn Inverter Off","rules":[{"t":"set","p":"payload","pt":"msg","to":"3","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":880,"y":1420,"wires":[[]]}]