mppsolar.conf import option
sante85 opened this issue · 2 comments
Hi friend,
is possible in mppsolar.conf make nested import file?
Eg.
[SETUP]
pause=5
mqtt_broker=localhost
import inverter1.conf
and inside inverter1.conf
[Inverter_ID]
port=/dev/ttyUSB0
protocol=PI30
command=QID
tag=ID
outputs=mqtt
[SERIAL_REPLACE_status]
port=/dev/ttyUSB0
protocol=PI30
command=get_status
tag=tagtest
outputs=mqtt
I have readed this article
https://stackoverflow.com/questions/4029946/multiple-configuration-files-with-python-configparser
If you add array to read function
if args.configfile:
import configparser
log.debug(f"args.configfile is true: {args.configfile}")
config = configparser.ConfigParser()
try:
**config.read(args.configfile)**
** config1.ini **
[shared]
prop_uniue1 = 1
prop_shared = 10
[unique1]
test_unique = 101
and config2.ini:
** config2.ini **
[shared]
prop_uniue2 = 2
prop_shared = 14
[unique2]
test_unique = 102
Then if I run the following I can see how the configs get updated (outputs are shown as comments after the respective print statements):
import ConfigParser
config = ConfigParser.ConfigParser()
config.read(['config1.ini', 'config2.ini'])
print config.sections() # ['shared', 'unique1', 'unique2']
print config.get("shared", "prop_uniue1") # 1
print config.get("shared", "prop_shared") # 14
print config.get("unique1", "test_unique") # 101
print config.get("shared", "prop_uniue2") # 2
print config.get("unique2", "test_unique") # 102