I was hoping you may be able to help me condense 3 function nodes into 1. I am 80% sure the function node is correct, I just cant figure out what to put in the call service nodes, as I keep getting an API error. The morning commute sensor is just an integer representing the travel time in minutes (from waze)
Fixed it: Changed the function node to the code below and added an additional ouput
var msgA={};
var msgB={};
if(msg.payload < 19){
msgA= {"payload" : { "data": {"brightness_pct": "100","color_name": "green"}}};
return [msgA, null];
} else if(msg.payload > 18 && msg.payload < 26)
{
msgA= {"payload" : { "data": {"brightness_pct": "100","color_name": "orange"}}};
msgB= {"payload" : { "data": {"message": "Current traffic is slightly worse than normal. It could take up to 25 minutes to get to work today."}}};
return [msgA, msgB];
} else if(msg.payload > 25){
msgA= {"payload" : { "data": {"brightness_pct": "100","color_name": "red"}}};
msgB= {"payload" : { "data": {"message" : "Traffic is significantly worse than normal. It will take more than 30 minutes to get to work today."}}};
return [msgA, msgB];
}
return [ null, null ];