 }
 
 void loopHandler() {
+  // Ideally this would be handled by an interrupt, but it seems to make Homie hang.
   int buttonState = debouncer.read();
 
   if (buttonState != lastbuttonState) {
+     timestamp = millis();
+     singletimer = timestamp;
+     doubletimer = timestamp;
+     tripletimer = timestamp;
+
      Serial.print("Button is now: ");
-     Serial.println(buttonState ? "open" : "close");
+     Serial.println(buttonState ? "pressed" : "released");
 
-     if (Homie.setNodeProperty(buttonNode, "open", buttonState ? "true" : "false", true)) {
+     if (Homie.setNodeProperty(buttonNode, "state", buttonState ? "pressed" : "released", true)) {
        lastbuttonState = buttonState;
      } else {
        Serial.println("Sending failed");

/* WARNING: untested */

#include <Homie.h>


const int PIN_LED = 13;
const int PIN_BUTTON = 0;

volatile unsigned long timestamp = 0;
volatile unsigned long singletimer = 0;
volatile unsigned long doubletimer = 0;
volatile unsigned long tripletimer = 0;


int lastbuttonState = -1;

Bounce debouncer = Bounce(); // Bounce is built into Homie, so you can use it without including it first

HomieNode relayNode("relay", "relay");
HomieNode buttonNode("button", "button");
