-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInflux.py
25 lines (22 loc) · 864 Bytes
/
Influx.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from influxdb_client import InfluxDBClient, Point
from influxdb_client.client.write_api import SYNCHRONOUS
from influxdb_client.domain.write_precision import *
from FritzActor import *
def writeInfluxDBPoint(influxDbClient, bucket, fritzActor):
with influxDbClient.write_api() as write_api:
dict_structure = {
"measurement": "ains",
"tags": {
"ain": fritzActor.ain,
"name": fritzActor.name
},
"fields": {
"temperature": fritzActor.temp,
"power": fritzActor.power,
"energy": fritzActor.energy,
"state": fritzActor.state
},
"time": fritzActor.timestamp
}
point = Point.from_dict(dict_structure, WritePrecision.MS)
write_api.write(bucket=bucket, record=point)