Initial commit

This commit is contained in:
Thomas Klaehn
2021-04-19 07:57:29 +02:00
commit d30a15567b
13 changed files with 305 additions and 0 deletions

43
config/_Config.py Normal file
View File

@@ -0,0 +1,43 @@
import os
import json
class Config():
def __init__(self):
self.__config_file = os.path.join(os.path.expanduser('~'), ".config/sauna/config.json")
self.__config = None
try:
with open(self.__config_file, "r") as handle:
self.__config = json.load(handle)
except FileNotFoundError:
os.makedirs(os.path.dirname(self.__config_file), exist_ok=True)
self.__config = {
"target_temperature": "80",
"temperature_step": "5",
"max_temperature": "120",
"runtime": "2:30",
"heat_pin": "26"
}
with open(self.__config_file, "w") as handle:
json.dump(self.__config, handle)
def target_temperature(self):
return self.__config['target_temperature']
def temperature_step(self):
res =self.__config['temperature_step']
print(res)
return res
def heat_pin(self):
return self.__config['heat_pin']
def runtime(self):
return self.__config['runtime']
def update_target_temperature(self, temperature: int):
if temperature <= int(self.__config['max_temperature']):
self.__config['target_temperature'] = str(temperature)
with open(self.__config_file, "w") as handle:
json.dump(self.__config, handle)

1
config/__init__.py Normal file
View File

@@ -0,0 +1 @@
from ._Config import Config