changeset 305:6614416dd2c3

influx output for arduino, update web lib path Ignore-this: 76b7fb15db86563ed3fa1ec5322b918c
author drewp@bigasterisk.com
date Fri, 16 Sep 2016 01:16:12 -0700
parents e7cbf250188a
children 6aad04b34231
files service/arduinoNode/arduinoNode.py service/arduinoNode/config/bang.n3 service/arduinoNode/config/config.n3 service/arduinoNode/config/slash.n3 service/arduinoNode/devices.py service/arduinoNode/static/output-widgets.html
diffstat 6 files changed, 45 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/service/arduinoNode/arduinoNode.py	Fri Sep 16 00:55:04 2016 -0700
+++ b/service/arduinoNode/arduinoNode.py	Fri Sep 16 01:16:12 2016 -0700
@@ -160,8 +160,10 @@
         if elapsed > 1.0:
             log.warn('poll took %.1f seconds' % elapsed)
 
-        self._influx.exportToInflux(
-            set.union([set(v) for v in self._statementsFromInputs.values()]))
+        stmts = set()
+        for v in self._statementsFromInputs.values():
+            stmts.update(v)
+        self._influx.exportToInflux(stmts)
 
     def _sendOneshot(self, oneshot):
         body = (' '.join('%s %s %s .' % (s.n3(), p.n3(), o.n3())
--- a/service/arduinoNode/config/bang.n3	Fri Sep 16 00:55:04 2016 -0700
+++ b/service/arduinoNode/config/bang.n3	Fri Sep 16 01:16:12 2016 -0700
@@ -28,8 +28,14 @@
 board0pin:d8 :pinNumber 8 .
 
 
-board0pin:d3 :connectedTo sensor:motion0 .
-sensor:motion0 a :MotionSensor;
+board0pin:d3 :connectedTo sensor:motionStorage .
+sensor:motionStorage a :MotionSensor;
+  :influxMeasurement [
+    :measurement "presence";
+    :predicate :sees;
+    :tag [:key "host"; :value "bang"],
+      [:key "sensor"; :value "motion"],
+      [:key "location"; :value "storage"]];
   :sees houseLoc:storage .
 
 board0pin:d4 :connectedTo :heater .
@@ -46,7 +52,10 @@
   :connectedTo board0ow:dev-1052790f02080086 .
 board0ow:dev-1052790f02080086 a :TemperatureSensor;
   :position :storage;
-  :graphiteName "system.house.temp.storage" .
+  :influxMeasurement [
+    :measurement "temperatureF";
+    :predicate :temperatureF;
+    :tag [:key "host"; :value "bang"], [:key "location"; :value "storage"]] .
 
 
 ha:boardTest a :ArduinoBoard;
--- a/service/arduinoNode/config/config.n3	Fri Sep 16 00:55:04 2016 -0700
+++ b/service/arduinoNode/config/config.n3	Fri Sep 16 01:16:12 2016 -0700
@@ -68,6 +68,12 @@
     
 board2pin:d3 :pinNumber 3; :connectedTo sensor:motionAriDesk .
 sensor:motionAriDesk a :MotionSensor;
+  :influxMeasurement [
+    :measurement "presence";
+    :predicate :sees;
+    :tag [:key "host"; :value "brace"],
+    [:key "sensor"; :value "motion"],
+    [:key "location"; :value "ariDesk"]];
   :sees houseLoc:ariDesk .
 
 board2pin:d4 :pinNumber 4; :connectedTo sensor:buttonAriBed .
@@ -79,7 +85,11 @@
   :connectedTo board2ow:dev-2813bea50300003d .
 board2ow:dev-2813bea50300003d a :TemperatureSensor;
   :position houseLoc:ariUnderBed;
-  :graphiteName "system.house.temp.ariUnderBed" .
+  :influxMeasurement [
+    :measurement "temperatureF";
+    :predicate :temperatureF;
+    :tag [:key "host"; :value "brace"], [:key "location"; :value "ariUnderBed"]] .
+
 
 board2pin:d6 :pinNumber 6; :connectedTo :starTrekLight .
 :starTrekLight a :LedOutput;
@@ -87,4 +97,10 @@
 
 board2pin:d7 :pinNumber 7; :connectedTo sensor:motionAriBed .
 sensor:motionAriBed a :MotionSensor;
+  :influxMeasurement [
+    :measurement "presence";
+    :predicate :sees;
+    :tag [:key "host"; :value "brace"],
+      [:key "sensor"; :value "motion"],
+      [:key "location"; :value "ariBed"]];
   :sees houseLoc:ariBed .
--- a/service/arduinoNode/config/slash.n3	Fri Sep 16 00:55:04 2016 -0700
+++ b/service/arduinoNode/config/slash.n3	Fri Sep 16 01:16:12 2016 -0700
@@ -41,7 +41,10 @@
   :connectedTo shopOw:dev-28bf08d101000026 .
 shopOw:dev-28bf08d101000026 a :TemperatureSensor;
   :position :workshop;
-  :graphiteName "system.house.temp.workshop" .
+  :influxMeasurement [
+    :measurement "temperatureF";
+    :predicate :temperatureF;
+    :tag [:key "host"; :value "slash"], [:key "location"; :value "workshop"]].
 
 shopPwm:roomLights a :PwmBoard;
   :scl shopPwm:scl;
--- a/service/arduinoNode/devices.py	Fri Sep 16 00:55:04 2016 -0700
+++ b/service/arduinoNode/devices.py	Fri Sep 16 01:16:12 2016 -0700
@@ -286,6 +286,7 @@
     DS18S20 pin 1: ground, pin 2: data and pull-up with 4.7k.
     """
     deviceType = ROOM['OneWire']
+    pollPeriod = 2
     def hostStateInit(self):
         # eliminate this as part of removing watchPrefixes
         self._knownTempSubjects = set()
@@ -343,6 +344,12 @@
             addr = struct.unpack('>Q', read(8))[0]
             tempF = struct.unpack('<f', read(4))[0]
             sensorUri = URIRef(os.path.join(self.uri, 'dev-%s' % hex(addr)[2:]))
+            if tempF > 180:
+                stmts.extend([
+                    (self.uri, ROOM['connectedTo'], sensorUri),
+                    (sensorUri, RDF.type, ROOM['FailingTemperatureReading']),
+                    ])
+                continue
             stmts.extend([
                 (self.uri, ROOM['connectedTo'], sensorUri),
                 # rounding may be working around a bug where the
--- a/service/arduinoNode/static/output-widgets.html	Fri Sep 16 00:55:04 2016 -0700
+++ b/service/arduinoNode/static/output-widgets.html	Fri Sep 16 01:16:12 2016 -0700
@@ -1,7 +1,7 @@
 <link rel="import" href="/lib/polymer/1.0.9/iron-ajax/iron-ajax.html">
 <link rel="import" href="/lib/polymer/1.0.9/polymer/polymer.html">
 <link rel="import" href="/lib/polymer/1.0.9/color-picker-element/dist/color-picker.html">
-<link rel="import" href="/room/ari/static/rdf-uri.html">
+<link rel="import" href="/rdf/rdf-uri.html">
 
 <dom-module id="output-sender">
   <template>