Digital Input using a button doesn't work properly when using it to control a relay
You have to invalidate the ‘state’ variable when Serial is not available, otherwise you will produce strange behaviours.

if(Serial1.available() > 0){
       state = Serial1.read();
  } else {
       state =-1; // not valid
    }

Also, you have to check ‘1’ and ‘0’ characters and not 1 and 0 values. ‘if (state == ‘1’)..’