-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path__init__.py
More file actions
40 lines (35 loc) · 1.03 KB
/
__init__.py
File metadata and controls
40 lines (35 loc) · 1.03 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from influxdb_client import InfluxDBClient, Point, WritePrecision
from influxdb_client.client.write_api import SYNCHRONOUS
import models.mqtt as mqtt
import configparser
import os
# this init file will load necessary global variables on startup
#region CONFIG
# load in the configuration file
config = configparser.ConfigParser()
config.read("./config/config.ini")
#endregion
#region ARGS
# general arguments
ARG = os.environ.get('DEBUG', 0)
try:
debug = int(ARG)
except:
debug = 0
disconnect_endpoint = config.get("endpoints", "disconnected")
#endregion
#region MQTT
# set mqtt variables
client = mqtt.MyClient()
host_address = config.get("mqtt", "host")
topic = config.get("mqtt", "topic")
#endregion
#region INFLUXDB
# set influx database variables
token = config.get("influxdb", "token")
url = config.get("influxdb", "url")
organization = config.get("influxdb", "org")
bucket = config.get("influxdb", "bucket")
influx_client = InfluxDBClient(url=url, token=token)
write_api = influx_client.write_api(write_options=SYNCHRONOUS)
#endregion