Intelligent communication between EVs and the grid