var chk_state; if (msg.payload[0] =="on" && msg.payload[1] =="on" && msg.payload[2] =="on") { chk_state = "on" } else { chk_state ="off" } msg.payload = chk_state; return msg;