Created
January 15, 2018 13:13
-
-
Save Elwell/d05dcd01412a419ba4dc57cd5ca23ded to your computer and use it in GitHub Desktop.
Ruuvitag to influxdb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python3 | |
from influxdb import InfluxDBClient | |
from ruuvitag_sensor.ruuvi import RuuviTagSensor | |
tags = {'F6:B4:FB:E9:7C:A8':'incubator'} | |
client = InfluxDBClient(host="localhost", port=8086, database="sensors") | |
def handle_data(found_data): | |
json_body = [ | |
{ | |
"measurement": "ruuvitag", | |
"tags": { | |
"mac": found_data[0], | |
"location" : tags[found_data[0]] | |
}, | |
"fields": found_data[1] | |
} | |
] | |
#print(json_body) | |
client.write_points(json_body) | |
RuuviTagSensor.get_datas(handle_data, tags.keys()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment