         let formatter = NSDateFormatter()
         formatter.dateStyle = .ShortStyle
         formatter.timeStyle = .ShortStyle
-        smappeeController.sendServiceLocationRequest { r in
-            r.flatMap({ valueOrError($0.first, "No service locations found")
-            }).flatMap(self.smappeeController.sendServiceLocationInfoRequest) { r in
-                switch r {
-                case .Success(let box):
-                    let info = box.unbox
-                    self.smappeeController.sendConsumptionRequest(info.serviceLocation, from: NSDate(timeIntervalSinceNow: -3600*24*100), to: NSDate(), aggregation: .Monthly) { r in
-                        if let consumptions = r.value {
-                            for consumption in consumptions {
-                                let date = formatter.stringFromDate(consumption.timestamp)
-                                println("Event: \(consumption.consumption) - \(consumption.alwaysOn) - \(date)")
-                            }
-                        }
+        getServiceLocationInfo { r in
+            r.flatMap(self.getConsumptionFromInfo) { r in
+                if let consumptions = r.value {
+                    for consumption in consumptions {
+                        let date = formatter.stringFromDate(consumption.timestamp)
+                        println("Event: \(consumption.consumption) - \(consumption.alwaysOn) - \(date)")
                     }
-                    
-                    self.actuator = info.actuators.first
-                    println("Success")
-                case .Failure(let box):
-                    let errorMessage = box.unbox
-                    println(errorMessage)
                 }
-                self.updateButtonStates()
-            }
-        }
-    }
-
-    
+            }
+        }
+    }
     
     func actuatorOn(actuator: Actuator) {
         smappeeController.sendTurnOnRequest(actuator, duration: .FiveMinutes) { result in }

        let formatter = NSDateFormatter()
        formatter.dateStyle = .ShortStyle
        formatter.timeStyle = .ShortStyle
        smappeeController.sendServiceLocationRequest { r in
            r.flatMap({ valueOrError($0.first, "No service locations found")
            }).flatMap(self.smappeeController.sendServiceLocationInfoRequest) { r in
                switch r {
                case .Success(let box):
                    let info = box.unbox
                    self.smappeeController.sendEventsRequest(info.serviceLocation, appliances: info.appliances.filter({$0.name == "Nespresso"}), maxNumber: 10, from: NSDate(timeIntervalSinceNow: -3600*24), to: NSDate()) { r in
                        if let events = r.value {
                            for event in events {
                                let date = formatter.stringFromDate(event.timestamp)
                                println("Event: \(event.appliance.name) - \(event.activePower) - \(date)")
                            }
                        }
                        }
                    
                    self.actuator = info.actuators.first
                    println("Success")
                case .Failure(let box):
                    let errorMessage = box.unbox
                    println(errorMessage)
                }
                self.updateButtonStates()
            }
        }
    }


    
    // MARK: SmappeeKit calls

    func getFirstServiceLocation(completion: (Result<ServiceLocation, String>) -> Void) {
        if let location = self.serviceLocation {
            completion(success(location))
        }
        else {
            smappeeController.sendServiceLocationRequest { r in
                let first = r.flatMap({ valueOrError($0.first, "No service locations found")})
                self.serviceLocation = first.value
                completion(first)
                self.updateButtonStates()
            }
        }
    }

    func getServiceLocationInfo(completion: (Result<ServiceLocationInfo, String>) -> Void) {
        if let locationInfo = self.serviceLocationInfo {
            completion(success(locationInfo))
        }
        else {
            getFirstServiceLocation { r in
                r.flatMap(self.smappeeController.sendServiceLocationInfoRequest) { r in
                    self.serviceLocationInfo = r.value
                    completion(r)
                }
            }
        }
    }


    func getActuator() {
        getServiceLocationInfo { r in
            self.actuator = r.value?.actuators.first
            self.updateButtonStates()
        }
    }
    
    func getEventsFromInfo(info: ServiceLocationInfo, completion: Result<[ApplianceEvent], String> -> Void) {
        self.smappeeController.sendEventsRequest(info.serviceLocation, appliances: info.appliances.filter({$0.name == "Nespresso"}), maxNumber: 10, from: NSDate(timeIntervalSinceNow: -3600*24), to: NSDate()) { r in
            completion(r)
        }
    }
    
