diff --git a/mqtt2influx.py b/mqtt2influx.py index 2a875d92b2abd35aede0446c0a04662bff6b35d8..0742d4a49f71538a3a97aee3ce1197b58be7bd3d 100644 --- a/mqtt2influx.py +++ b/mqtt2influx.py @@ -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 = {}