ESP8266 operation

OK. I did an 'atoi' test sketch and the ON/OFF characters always evaluate to 0 which in your case equals OFF.

So try the 'if' code and see if it works for you.

Maybe one of the more advanced members will come along and explain the 'atoi' not evaluating.