Skip to content
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
37 lines (31 sloc) 1010 Bytes
from w1thermsensor import W1ThermSensor
from influxdb import InfluxDBClient
import datetime
import platform
import json
dbclient = InfluxDBClient(
host="{{ influxdb_host }}",
username="{{ influxdb_user }}",
password="{{ influxdb_pass }}",
port={{ influxdb_port }},
database="{{ influxdb_dbname }}"
with open('sensors.json') as f:
sensor_tags = json.load(f)
measurements = []
for sensor in W1ThermSensor.get_available_sensors():
temp = sensor.get_temperature()
if temp < 80: # 85 is an errorcode
tags = sensor_tags.get(, {})
tags["sensor_id"] =
tags["host"] = platform.node()
"measurement": "temperature",
"time": datetime.datetime.utcnow().isoformat() + 'Z',
"tags": tags,
"fields": {
"value": temp
print json.dumps(measurements, indent=4, sort_keys=True)
if measurements: dbclient.write_points(measurements)
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.