if (MyItem.state == ON || MyItem.state == NULL) MyItem.sendCommand(OFF)
else MyItem.sendCommand(ON)
The NULL
check is in case your MyItem
is not initialized and then we send on OFF command otherwise it would be turned ON by the else
clause which may be unsafe.
The ||
mean or