def _on_message(self, client, userdata, msg): #print "[Debug] %s\t%s" % (msg.topic, msg.payload) if msg.topic in MQTT_TOPICS.keys(): data = mqtt_parse_message(MQTT_TOPICS[msg.topic], msg.topic, msg.payload) if data != None: self._dbmanager.insert_message(data['time'], msg.topic, data['value'])
def _on_message(self, client, userdata, msg): #print "[Debug] %s\t%s" % (msg.topic, msg.payload) if msg.topic in MQTT_TOPICS.keys(): data = mqtt_parse_message(MQTT_TOPICS[msg.topic], msg.topic, msg.payload) if data != None: timestamp = js_timestamp(data['time']) self._socketio.emit("mqtt_message", {'topic' : msg.topic, 'time': timestamp, 'value': data['value']})
def start(self, threadded = True): for topic in MQTT_TOPICS.keys(): self._dbmanager.insert_topic(topic) super(MQTTDatabaseRunner, self).start(threadded)
def _on_connect(self, client, userdata, flags, rc): for topic in MQTT_TOPICS.keys(): print "[Info] Subscribing to %s" % topic client.subscribe(topic)