Skip to content

Instantly share code, notes, and snippets.

@Elwell
Created January 15, 2018 13:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Elwell/d05dcd01412a419ba4dc57cd5ca23ded to your computer and use it in GitHub Desktop.
Save Elwell/d05dcd01412a419ba4dc57cd5ca23ded to your computer and use it in GitHub Desktop.
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