if(strcmp(relay, "relay1") == 0){
if(strcmp(state, "LOW") == 0){
digitalWrite(relay1, LOW);
That will work. You'd normally use some sort of table:
cmdType NameToRelayNo[] = {
{"relay1", relay1},
{"relay2", relay2},
{"pump", relay2}, // another name for relay2
{"relay3", relay3},
{"lights", relay4} ...
}
If you really only want to accept names like "relayNN", you can convert the NN part to a number directly.
relayNo = atoi(&relay[5]); // parse number starting at 6th character.