Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Ruuvitag to influxdb
#!/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