 
 void mqtt_callback(char* topic, byte* payload_theirs, unsigned int length);
 
-typedef enum { LED_OFF, LED_SLOW, LED_FAST, LED_ON } ledstate;
+typedef enum { LED_OFF, LED_SLOW, LED_FAST, LED_FLASH, LED_HICK, LED_PANIC, LED_ON, NEVERSET } ledstate;
 ledstate red;
-
-const unsigned int DFAST = 100;      // 10 times/second - swap/flash
-const unsigned int DSLOW  = 5 * DFAST; // twice a second.
-const unsigned int DMAX  = 1000;     // we in effect for updates every second - even when in steady state.
 
 WiFiClient espClient;
 PubSubClient client(espClient);

    case SWERROR:
    case NOCONN:
    case NOTINUSE:
      red = LED_FAST;
      break;
    case WRONGFRONTSWITCHSETTING:
      red = LED_SLOW;
      break;
    case WAITINGFORCARD:
      red = LED_OFF;
      break;
    case CHECKING:
      red = LED_OFF;
      if (millis() - laststatechange > CHECK_TO)
        machinestate = WAITINGFORCARD;
      break;
    case DENIED:
      red = LED_FAST;
      if (millis() - laststatechange > 500)
        machinestate = WAITINGFORCARD;
      break;
    case ENERGIZED:
      red = LED_ON;
      if (laststatechange < ENERGIZED) {
        send("event energized");
      };

  static char hex[2 * HASH_LENGTH + 1];
  const char q2c[] = "0123456789abcdef";
  char * p = hex;
  
  for (int i = 0; i < HASH_LENGTH; i++) {
    *p++ = q2c[hmac[i] >> 4];
    *p++ = q2c[hmac[i] & 15];
