 #include <Homie.h>
 
 #define FW_NAME "homie-sonoff-touch"
-#define FW_VERSION "0.0.5alpha"
+#define FW_VERSION "0.0.5"
 
 /* Magic sequence for Autodetectable Binary Upload */
 const char *__FLAGGED_FW_NAME = "\xbf\x84\xe4\x13\x54" FW_NAME "\x93\x44\x6b\xa7\x75";

  Homie.setLoopFunction(loopHandler);
  relayNode.subscribe("relayState", RelayHandler);
  Homie.registerNode(relayNode);
  Homie.setup();
}

void loop() {
  Homie.loop();
}

  return true;
}

void loopHandler() {
  int buttonState = debouncer.read();

  if (buttonState != lastbuttonState) {
     Serial.print("Button is now: ");
     Serial.println(buttonState ? "open" : "close");

     if (Homie.setNodeProperty(buttonNode, "open", buttonState ? "true" : "false", true)) {
       lastbuttonState = buttonState;
     } else {
       Serial.println("Sending failed");
     }
  }
}

void setup() {
  pinMode(PIN_RELAY, OUTPUT);
  digitalWrite(PIN_RELAY, LOW);

  pinMode(PIN_BUTTON, INPUT);
  digitalWrite(PIN_BUTTON, HIGH);
  debouncer.attach(PIN_BUTTON);
  debouncer.interval(50);

  Homie.setFirmware(FW_NAME, FW_VERSION);
  Homie.setLedPin(PIN_LED, HIGH); // Status LED
