-
Notifications
You must be signed in to change notification settings - Fork 30
/
config.py.dist
144 lines (127 loc) · 4.43 KB
/
config.py.dist
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import sys
# simple check if python 3 is used
if not (sys.version_info.major == 3 and sys.version_info.minor >= 5):
print("This script requires Python 3.5 or higher!")
print("You are using Python {}.{}.".format(sys.version_info.major, sys.version_info.minor))
sys.exit(1)
## all requirements
try:
import os
import time
import os.path
import sys
from datetime import datetime
except Exception as e:
print('Import error {}, check requirements.txt'.format(e))
sys.exit(1)
now = datetime.now()
# date and time formats
DATEFORMAT_TIMESTAMP = '%Y-%m-%dT%H:%M:%SZ'
DATEFORMAT_CURRENT = '%Y-%m-%d %H:%M:%S.%f'
DATEFORMAT_HOUR = '%H'
DATEFORMAT_DAY = '%Y-%m-%d'
DATEFORMAT_MONTH = '%Y-%m'
DATEFORMAT_YEAR = '%Y'
TIME_FORMAT = '%H:%M:%S'
# application settings
SMARTMETER_ID = '1234556' # internal used smartmeter identification
SMARTMETER_NAME = 'Wasserzähler Haus' # Name of the smartmeter
APPS_VERSION = '1.0.3' # Application version
# Datafile, if defined every hour the data will be stored as csv to this location
DATAFILE = os.path.join(os.path.dirname(__file__), 'data/' + SMARTMETER_ID + ".json")
# Reportfile, if defined every end of month data will be saved to this location
DAYREPORTFILE = os.path.join(os.path.dirname(__file__), 'data/' + SMARTMETER_ID + "-day-report.csv")
# Reportfile, if defined every end of month data will be saved to this location
REPORTFILE = os.path.join(os.path.dirname(__file__), 'data/' + SMARTMETER_ID + "-report.csv")
# all for the mqtt brocker
MQTT_HOST = 'localhost' # mqtt brocker host ! must be a string
MQTT_PORT = 1883 # mqtt brocker port ! must be a number
MQTT_APPID = 'pi' # mqtt brocker user name
MQTT_PASSWORD = 'raspberry' # mqtt brocker user password
MQTT_KEEPALIVE = 60 # mqtt brocker keep alive time
# all topic settings
# test: mosquitto_sub -h localhost -p 1883 -u 'pi' -P 'raspberry' -v -t 'tele/wasser/verbrauch'
MQTT_TOPIC = 'tele/wasser/verbrauch' # listen to this wmbusmeters topic
# all application publish topics
MQTT_TOPIC_NAME = 'IZAR'
MQTT_PUBLISH_TOPIC = 'tele/' + MQTT_TOPIC_NAME + '/wasser' # used for publishing new data
MQTT_STATE_TOPIC = 'tele/' + MQTT_TOPIC_NAME + '/wasser/status' # mqtt state topic
MQTT_AVAILABILITY_TOPIC = 'tele/' + MQTT_TOPIC_NAME + '/LWT' # mqtt availability topic Online | Offline
MQTT_ENABLE_LOGGING = False # enable | disable debug logging mqtt
# switch logging
LOG_LEVEL = 10 # DEBUG: 10
# LOG_LEVEL = 20 # INFO: 20
# LOG_LEVEL = 30 # WARNING: 30
# LOG_LEVEL = 40 # ERROR: 40
# LOG_LEVEL = 50 # CRITICAL: 50
# LOG_LEVEL = 100 # DISABLED: 100
LOG_DIR = './logs/'
DEBUG_DATA = False
# write summary data to console
DATALOG_ENABLED = True # enable True | False, writes datalog to console
DATALOG_FILENAME = './logs/data.csv' # output folder for data log
# data model application status
APP_STATEINFO = {
"hostname": os.uname().nodename,
"state": 'Online',
"smartmeter": SMARTMETER_NAME,
"time": time.ctime(),
"timestamp": "",
"uptime": "-1",
"lastdata": "-1",
"synctime": -1,
"version": APPS_VERSION,
"attribution": "Data provided by Peter Siebler"
}
# data model smartmeter
WATERMETER_DATA = {
"name": SMARTMETER_NAME,
"device": "watermeter",
"deviceid": SMARTMETER_ID,
"date": "",
"time": "",
"total_m3": 0.00,
"ratio": 0.00,
"m3": {
"current": 0.000,
"hour": 0.000,
"day": 0.000,
"month": 0.000,
"year": 0.000
},
"liter": {
"current": 0.000,
"hour": 0.000,
"day": 0.000,
"month": 0.000,
"year": 0.000
},
"last_total": {
"hour": "2020-14-09",
"hour_m3": 0.000,
"day": "2020-07-14",
"day_m3": 0.000,
"month": "2020-07",
"month_m3": 0.000,
"year": "2019-12-31",
"year_m3": 0.000
},
"wmbusmeter": "",
"alarm": "No alarm",
"last_alarm": "No alarm",
"periode": now.strftime(DATEFORMAT_DAY),
"month": now.strftime(DATEFORMAT_MONTH),
"year": now.strftime(DATEFORMAT_YEAR),
"timestamp": now.strftime(DATEFORMAT_TIMESTAMP),
"last_update": now.strftime(DATEFORMAT_CURRENT),
"elapsed_time": 0,
"icon": "mdi:billboard",
"unit_of_measurement": u"\u33A5",
"last_reset": "1970-01-01T00:00:00+00:00",
"state_class": "measurement",
"device_class": "energy",
"version": APPS_VERSION,
"attribution": "Data provided by Peter Siebler"
}