Timer the Switch with mysql database

That's because inside the if, you set msg.payload to true.

Do what I said and change the assignment = to comparison ==