Skip to content
Snippets Groups Projects
Commit e98f298f authored by Dennis Eisold's avatar Dennis Eisold
Browse files

Update mqtt2influx.py

parent 97a23248
No related branches found
No related tags found
No related merge requests found
......@@ -22,27 +22,18 @@ config_set = "mqtt_to_influx"
mqtt_server = config[config_set]['mqtt_setting']
influx_server = config[config_set]['influxdb_setting']
def iterate(dictionary):
for key, value in dictionary.items():
if isinstance(value, dict):
iterate(value)
continue
print('key {!r} -> value {!r}'.format(key, value))
def on_connect(client, userdata, flags, rc):
client.subscribe(config[mqtt_server]['subscribe'])
def on_message(client, userdata, msg):
# Use utc as timestamp
loaded_json = json.loads(msg.payload.decode("utf-8"))
isfloatValue=False
if("wetterstation" in msg.topic and "SENSOR" in msg.topic):
print("write to influxDB: wetterstation")
print("Sensor: " + msg.topic.split("/wetterstation/")[1].split("/SENSOR")[0])
for key in loaded_json.keys():
if("PressureUnit" not in key and "TempUnit" not in key and "Time" not in key):
if("Unit" not in key and "Time" not in key):
print("Key: " + key)
fields = {}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment