luftdaten: fix timestamp

This commit is contained in:
Astro 2020-04-04 01:38:33 +02:00
parent 4562ce72a1
commit 2a910050ef

View File

@ -8,6 +8,7 @@ SENSOR_LOCATIONS = {
44132 => "Wurzelwerk Tunnel",
44133 => "Wurzelwerk Tunnel",
}
TIME_PRECISION = 's'
data = JSON.parse open("https://data.sensor.community/static/v2/data.json").read()
@ -27,10 +28,10 @@ data.each do |d|
sensor_type: d["sensor"]["sensor_type"]["name"],
},
values: values,
timestamp: Time.new(d["timestamp"]).to_i
timestamp: InfluxDB.convert_timestamp(Time.parse(d["timestamp"] + " UTC"), TIME_PRECISION),
})
end
end
db = InfluxDB::Client.new(url: "http://grafana.hq.c3d2.de:8086/luftdaten")
db.write_points points, 's'
db.write_points points, TIME_PRECISION