         :headers {"Accept" "application/edn"}
         :response-format :text}))
 
+(defn flatten-device [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]
+  (mapcat flatten-device devices))
+
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; History loop - this drives the fetches and clear downs
 (defn history-loop [history-channel data]

      (println "New Programmes: " programmes " New Projects: " projects " New Properties: " properties)
      (println "New Active Components: " (-> nav-event :args :ids))

      ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
      ;; Clear down
      (when (and old-programmes
                 (nil? programmes))

        (om/update! data [:sensors :data] [])
        (om/update! data [:measurements :data] []))

      ;; Fetchers
      (when-not programmes
        (om/update! data [:programmes :selected] nil)
