 
 const int CMD_WAIT = 0;
 const int CMD_BUTTON_CHANGE = 1;
+const int CMD_INPUT_CHANGE = 2;
 
 int cmd = CMD_WAIT;
 //int relayState = HIGH;

  pinMode(SONOFF_BUTTON, INPUT);
  attachInterrupt(SONOFF_BUTTON, toggleState, CHANGE);

  //setup relay
  //TODO multiple relays
  pinMode(SONOFF_RELAY_PINS[0], OUTPUT);


void toggleState() {
  cmd = CMD_BUTTON_CHANGE;
}

void toggleInputState() {
  cmd = CMD_INPUT_CHANGE;
}

//flag for saving data
