-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfigFileParser.py
More file actions
33 lines (29 loc) · 1.47 KB
/
ConfigFileParser.py
File metadata and controls
33 lines (29 loc) · 1.47 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
import configparser
class ConfigFileParser:
DEFAULT_MIN_TEMP = 15
DEFAULT_MAX_TEMP = 30
DEFAULT_MAX_HUMIDITY = 80
DEFAULT_REFRESH_RATE = 1
def __init__(self, config_file_path):
config = configparser.ConfigParser()
config.read(config_file_path)
self.fanPin = config.getint('Sensor', 'fanPin')
self.heatherPin, self.heatherFanPin = config.get(
'Sensor', 'heatherPin').split(',')
self.remoteRelayPin = config.getint('Sensor', 'remoteRelayPin')
self.rpiFanPin = config.getint('Sensor', 'rpiFanPin')
self.dhtPinInternal = config.getint('Sensor', 'dhtPinInternal')
self.dhtPinExternal = config.getint('Sensor', 'dhtPinExternal')
self.minTemp = self.DEFAULT_MIN_TEMP
self.maxTemp = self.DEFAULT_MAX_TEMP
self.maxHumidity = self.DEFAULT_MAX_HUMIDITY
self.externalTempOffset = config.getint('Sensor', 'externalTempOffset')
self.internalTempOffset = config.getint('Sensor', 'internalTempOffset')
self.refreshRate = config.getint(
'Sensor', 'refreshRate') or self.DEFAULT_REFRESH_RATE
self.mqttActive = config.getboolean('MQTT', 'mqttActive')
self.mqttUser = config.get('MQTT', 'user')
self.mqttPassword = config.get('MQTT', 'password')
self.mqttHost = config.get('MQTT', 'host')
self.remoteRelayTopic = config.get('MQTT', 'remoteRelayTopic')
self.chickenPenTopic = config.get('MQTT', 'chickenPenTopic')