You don't even need to create the x variable msg.payload = parseInt(msg.payload) will do the trick nicely
msg.payload = parseInt(msg.payload)