 // The colours are a transition r - g - b - back to r.
 uint32_t Wheel(byte WheelPos) {
   if(WheelPos < 85) {
-   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
+    return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
   } else if(WheelPos < 170) {
-   WheelPos -= 85;
-   return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
+    WheelPos -= 85;
+    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
   } else {
-   WheelPos -= 170;
-   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
+    WheelPos -= 170;
+    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
   }
 }
 

    Particle.connect();
  }
  Particle.process();
  
  if (doorState == 1) {
    fireRing(200);
  } else if (doorState == 0) {
    iceRing(200);
  }
}

void eventHandler(const char *event, const char *data) {
    // Parse the event as json into something structured so we can react to it.
    // Saved by example!
    // https://github.com/glowfishAPI/glowfish-particle/blob/master/firmware/examples/anomaly-detect-webhook/anomaly-detect-webhook.ino
    int len = strlen(data);
    char dataCopy[len+1];
    strcpy(dataCopy, data);

    StaticJsonBuffer<200> jsonBuffer;
    JsonObject& json = jsonBuffer.parseObject(dataCopy);
    
    if (json["door_open"] == true) {
        Serial.println("door is open.");
        doorState = 1;
    }

    if (json["door_open"] == false) {
        Serial.println("door is closed.");
        doorState = 0;
    }

}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}

void fireRing(uint16_t wait) {
  uint16_t i, j;
  int colorStart = 95;  // a pure red
  int colorEnd = 125;    // the led starts to blink purple

  for(j=colorStart; j<colorEnd; j++) {
    for(i=0; i<strip.numPixels(); i++) {


int doorState = -1;

// don't run during "the day", define what that means here
int blackoutStart = 3;  // 3am
int blackoutEnd  = 21; // 6pm
// I'd love to use the positive inflection here but it's too hard to
// implement without a real time/date library.  You can't easily
// represent like 3am -- meaning the next day with a number.


void setup() {
  // Serial.begin(9600);

  Time.zone(-7);  // PDT

  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
  Particle.subscribe("squarism/garage/open", eventHandler);

  // Serial.println("I'm booted!");
}

void loop() {
