forked from ragingcomputer/amridm2mqtt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
settings_docker.py
58 lines (50 loc) · 1.86 KB
/
settings_docker.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
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
"""Get our settings from os.environ to facilitate running in Docker.
"""
import os
# Sanity checks
all_keys_found = True
for key in ['WATCHED_METERS']:
if key not in os.environ:
all_keys_found = False
print("Can't find key {0}, did you pass `-e {0}=<value>` to `docker run`?".format(key))
if not all_keys_found:
print("\nPlease set the environment variables above.")
exit(1)
# List of the Meter IDs to watch
# Use empty brackets to read all meters - []
# List may contain only one entry - [12345678]
# or multiple entries - [12345678, 98765432, 12340123]
power_meters = os.environ['WATCHED_METERS'].replace(',', ' ').split(' ')
WATCHED_METERS = [int(meter_id) for meter_id in power_meters]
# multiplier to get reading to Watt Hours (Wh)
# examples:
# for meter providing readings in kWh
# MULTIPLIER = 1000
# for meter providing readings in kWh
# with 2 extra digits of precision
# MULTIPLIER = 10
# MULTIPLIER needs to be a number
WH_MULTIPLIER = int(os.environ.get('WH_MULTIPLIER', 1000))
# number of IDM intervals per hour reported by the meter
# examples:
# for meter providing readings every 5 minutes
# or 12 times every hour
# READINGS_PER_HOUR = 12
# for meter providing readings every 15 minutes
# or 12 times every hour
# READINGS_PER_HOUR = 4
READINGS_PER_HOUR = int(os.environ.get('READINGS_PER_HOUR', 12))
# MQTT Server settings
# MQTT_HOST needs to be a string
# MQTT_PORT needs to be an int
# MQTT_USER needs to be a string
# MQTT_PASSWORD needs to be a string
# If no authentication, leave MQTT_USER and MQTT_PASSWORD empty
MQTT_HOST = os.environ.get('MQTT_HOST', '127.0.0.1')
MQTT_PORT = int(os.environ.get('MQTT_PORT', 1883))
MQTT_USER = os.environ.get('MQTT_USER', '')
MQTT_PASSWORD = os.environ.get('MQTT_PASSWORD', '')
# path to rtlamr
RTLAMR = '/root/go/bin/rtlamr'
# path to rtl_tcp
RTL_TCP = '/usr/bin/rtl_tcp'