         }
     }
     
-    func devicesForHouse(house: House, completion: [Device]? -> Void) {
-        self.dataTask("/house/\(house.id)/device") { data, response, error in
-            if data == nil || error != nil {
-                return completion(nil)
-            }
-            
-            if let json = NSJSONSerialization.JSONObjectWithData(data!, options: .allZeros, error: nil) as? [[String: AnyObject]] {
-                var devices: [Device] = []
-                for entry in json {
-                    devices += [
-                        Device(
-                            house: house,
-                            id: entry.cast("id", def: 0),
-                            name: entry.cast("name", def: ""),
-                            code: entry.cast("code", def: 0)
-                        )
-                    ]
-                }
-                
-                return completion(devices)
-            }
-            
-            return completion(nil)
-        }
-    }
-    
     private func dataTask(path: String, completion: (NSData?, NSURLResponse?, NSError?) -> Void) {
         self.sharedSession.dataTaskWithURL(NSURL(scheme: "http", host: self.host, path: path)!, completionHandler: completion).resume()
     }

    }
    
    func houses(completion: [House]? -> Void) {
        self.dataTask("/house") { data, response, error in
            if data == nil || error != nil {
                return completion(nil)
            }

        var name: String
        var code1: Int
        var code2: Int
        var devices: [Device]
        
        private init(fromJSON: [String: AnyObject]) {
            self.id = fromJSON.cast("id", def: 0)
            self.name = fromJSON.cast("name", def: "")
            self.code1 = fromJSON.cast("code1", def: 1111)
            self.code2 = fromJSON.cast("code2", def: 1111)
            
            self.devices = []
            for device in fromJSON.cast("devices", def: [[String: AnyObject]]()) {
                self.devices += [Device(fromJSON: device)]
            }
        }
    }
    
    struct Device {
        //var house: House
        var id: Int
        var name: String
        var code: Int
        
        private init(fromJSON: [String: AnyObject]) {
            self.id = fromJSON.cast("id", def: 0)
            self.name = fromJSON.cast("name", def: "")
            self.code = fromJSON.cast("code", def: 0)
        }
    }
    
    var host: String
