reformat
[svn42.git] / sensorvalues-to-json-zmq.py
index fa6e7f5..2d42b54 100755 (executable)
@@ -40,13 +40,13 @@ class UWSConfig:
     self.config_parser.add_section('json')
     self.config_parser.set('json','write_path',"/dev/shm/wget/r3sensors.json")
     self.config_parser.set('json','moveto_path',"/dev/shm/www/r3sensors.json")
-    self.config_parser.set('json','backup_path',"/home/guests/realraum.wirdorange.org/public_html/r3sensors.json.bak")
+    self.config_parser.set('json','backup_path',"/home/guests/realraum.wirdorange.org/r3sensors.json.bak")
     self.config_parser.set('json','backup_every',"50")
     self.config_parser.set('json','limit_list_len',"10000")
     self.config_parser.set('json','updateinterval',"30")
     self.config_parser.add_section('zmq')
-    self.config_parser.set('zmq','remote_uri',"tcp://wuzzler.realraum.at:4244")
-    self.config_parser.set('zmq','sshtunnel',"realraum@wuzzler.realraum.at:22000")
+    self.config_parser.set('zmq','remote_uri',"tcp://torwaechter.realraum.at:4244")
+    self.config_parser.set('zmq','sshtunnel',"realraum@torwaechter.realraum.at:22000")
     self.config_parser.set('zmq','sshkeyfile',"/home/guests/realraum.wirdorange.org/id_rsa")
     self.config_parser.set('zmq','subscribe',"TempSensorUpdate IlluminationSensorUpdate DustSensorUpdate RelativeHumiditySensorUpdate MovementSensorUpdate")
     self.config_parser.add_section('debug')
@@ -228,6 +228,12 @@ def addEventsToStore():
             sensor_store_[structname].insert(0,[time_column_name_] + list(map(lambda n: "Sensor %d"%n,range(0,sensor_cols_num_[structname]))))
 
         # add values
+        try:
+            # if latest values are identical, just update timestamp
+            if sensor_store_[structname][-1][1:] == latest_values_[structname] and sensor_store_[structname][-1][1:] == sensor_store_[structname][-2][1:]:
+                sensor_store_[structname].pop()
+        except:
+            pass
         sensor_store_[structname].append([ts] + latest_values_[structname])
 
         #cap list lenght