Pretty sure that my programming skills are not yet there, so I did something wrong.
from influxdb import InfluxDBClient
client = InfluxDBClient('10.0.1.181', 8086, '', '', 'speedcamdb')
client.create_database('speedcamdb')
speed_data_influx_json = [{
"log_idx": log_idx,
"log_date": log_date,
"log_hour": log_hour,
"log_minute": log_minute,
"camera": camera,
"ave_speed": ave_speed,
"speed_units": speed_units,
"filename": filename,
"image_width": image_width,
"image_height": image_height,
"image_bigger": image_bigger,
"travel_direction": travel_direction,
"plugin_name": plugin_name,
"track_x": track_x,
"track_y": track_y,
"track_w": track_w,
"track_h": track_h,
"m_area": m_area,
"x_left": x_left,
"x_right": x_right,
"y_upper": y_upper,
"y_lower": y_lower,
"max_speed_over": max_speed_over,
"min_area": MIN_AREA,
"track_counter": track_counter,
"cal_obj_px": cal_obj_px,
"cal_obj_mm": cal_obj_mm
}]
But unsuccessful. I get:
2020-01-03 14:54:52 INFO db_check Success: sqlite3 Connected to DB /home/pi/speed-camera/data/speed_cam.db
Traceback (most recent call last):
File "./speed-cam.py", line 1661, in <module>
speed_camera() # run main speed camera processing loop
File "./speed-cam.py", line 1407, in speed_camera
client.write_points(speed_data_influx_json)
File "/usr/local/lib/python2.7/dist-packages/influxdb/client.py", line 530, in write_points
consistency=consistency)
File "/usr/local/lib/python2.7/dist-packages/influxdb/client.py", line 598, in _write_points
protocol=protocol
File "/usr/local/lib/python2.7/dist-packages/influxdb/client.py", line 331, in write
data = make_lines(data, precision).encode('utf-8')
File "/usr/local/lib/python2.7/dist-packages/influxdb/line_protocol.py", line 156, in make_lines
for field_key, field_value in sorted(iteritems(point['fields'])):
KeyError: u'fields'
I'll keep investigating the code and influxdb puthon integration documentation.
Thank you for a great piece of software. I would really like to make it work with influxdb and grafana so I can make better visual for local neighborhood and maybe even for local authorities if they are interested in speeding drivers and statistics.