mirror of
https://github.com/alexhopeoconnor/SunGather.git
synced 2026-10-04 02:48:12 +10:00
Merge pull request #92 from norrland/registersfile
This commit is contained in:
@@ -122,6 +122,7 @@ usage: python3 sungather.py [options]
|
||||
|
||||
Commandline arguments override any config file settings
|
||||
**-c config.yaml** - Specify config file.
|
||||
**-r registersfile.yaml** - Specify registersfile.
|
||||
**-v 30** - Logging Level, 10 = Debug, 20 = Info, 30 = Warning (default), 40 = Error
|
||||
**--runonce** - Run once then exit
|
||||
**-h** - print this help message and exit (also --help)
|
||||
|
||||
+14
-10
@@ -429,10 +429,11 @@ class SungrowInverter():
|
||||
|
||||
def main():
|
||||
configfilename = 'config.yaml'
|
||||
registersfilename = 'registers-sungrow.yaml'
|
||||
logfolder = ''
|
||||
|
||||
try:
|
||||
opts, args = getopt.getopt(sys.argv[1:],"hc:l:v:", "runonce")
|
||||
opts, args = getopt.getopt(sys.argv[1:],"hc:r:l:v:", "runonce")
|
||||
except getopt.GetoptError:
|
||||
logging.debug(f'No options passed via command line')
|
||||
|
||||
@@ -443,16 +444,19 @@ def main():
|
||||
print(f'usage: python3 sungather.py [options]')
|
||||
print(f'\nCommandling arguments override any config file settings')
|
||||
print(f'Options and arguments:')
|
||||
print(f'-c config.yaml : Specify config file.')
|
||||
print(f'-l /logs/ : Specify folder to store logs.')
|
||||
print(f'-v 30 : Logging Level, 10 = Debug, 20 = Info, 30 = Warning (default), 40 = Error')
|
||||
print(f'--runonce : Run once then exit')
|
||||
print(f'-h : print this help message and exit (also --help)')
|
||||
print(f'-c config.yaml : Specify config file.')
|
||||
print(f'-r registers-file.yaml : Specify registers file.')
|
||||
print(f'-l /logs/ : Specify folder to store logs.')
|
||||
print(f'-v 30 : Logging Level, 10 = Debug, 20 = Info, 30 = Warning (default), 40 = Error')
|
||||
print(f'--runonce : Run once then exit')
|
||||
print(f'-h : print this help message and exit (also --help)')
|
||||
print(f'\nExample:')
|
||||
print(f'python3 sungather.py -c /full/path/config.yaml\n')
|
||||
sys.exit()
|
||||
elif opt == '-c':
|
||||
configfilename = arg
|
||||
elif opt == '-r':
|
||||
registersfilename = arg
|
||||
elif opt == '-l':
|
||||
logfolder = arg
|
||||
elif opt == '-v':
|
||||
@@ -481,12 +485,12 @@ def main():
|
||||
sys.exit(f"Failed Loading config, missing Inverter settings")
|
||||
|
||||
try:
|
||||
registersfile = yaml.safe_load(open('registers-sungrow.yaml', encoding="utf-8"))
|
||||
logging.info(f"Loaded registers: {os.getcwd()}/registers-sungrow.yaml")
|
||||
registersfile = yaml.safe_load(open(registersfilename, encoding="utf-8"))
|
||||
logging.info(f"Loaded registers: {registersfilename}")
|
||||
logging.info(f"Registers file version: {registersfile.get('version','UNKNOWN')}")
|
||||
except Exception as err:
|
||||
logging.error(f"Failed: Loading registers: {os.getcwd()}/registers-sungrow.yaml {err}")
|
||||
sys.exit(f"Failed: Loading registers: {os.getcwd()}/registers-sungrow.yaml {err}")
|
||||
logging.error(f"Failed: Loading registers: {registersfilename} {err}")
|
||||
sys.exit(f"Failed: Loading registers: {registersfilename} {err}")
|
||||
|
||||
config_inverter = {
|
||||
"host": configfile['inverter'].get('host',None),
|
||||
|
||||
Reference in New Issue
Block a user