   (om/update! data [:projects :fetching] :fetching)
   (GET (str "/4/programmes/" programme-id "/projects/")
        {:handler  (fn [x]
-                    (println "Fetching data for programme: " programme-id)
+                    (println "Fetching projects for programme: " programme-id)
                     (om/update! data [:projects :data] (mapv slugify-project x))
                     (om/update! data [:projects :fetching] (if (empty? x) :no-data :has-data))
                     (om/update! data [:projects :selected] nil))

             (om/build properties-div data)
             (om/build property-details-div data)
             ;; (om/build devices-div data)
             ;; (om/build device-detail devices)
             ;; (om/build sensors-div data)
             ;; (om/build sensor/define-data-set-button data)

             ]))))

        :response-format :text}))

(defn flatten-device [device]
  (println "Flattening: " device)
  (let [device-keys (->> device keys (remove #(= % :readings)))
            parent-device (select-keys device device-keys)
            readings (:readings device)] 
        (map #(assoc % :parent-device parent-device) readings)))

(defn extract-sensors [devices]
  (println "Devices to extract sensors from: " devices)
  (let [sensors (vec (mapcat flatten-device devices))]
    (println "Flattened sensors: " sensors)
    sensors))

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; History loop - this drives the fetches and clear downs
