smar000 / evoGateway

Python script for listening in and responding to evohome heating control radio messages
46 stars 17 forks source link

Path to evogateway.cfg as a parameter at startup #63

Open ericbieri opened 7 months ago

ericbieri commented 7 months ago

Hi, first of all thanks for the effort you have put into the evoGateway project!

I would like to run evoGateway in a docker container (docker compose). I would make the configuration files externally accessible as a volume. For this to work, the configuration file evogateway.cfg would have to be in a separate directory (not project root), e.g. /config/evogateway.cfg.

As far as I can see (I am not a python expert), the location is defined in the constant CONFIG_FILE = "evogateway.cfg" (https://github.com/smar000/evoGateway/blob/master/evogateway.py#L86).

Would it be possible for you to adapt the code so that the path of this file can be passed as a parameter when starting the application?

Cheers Eric

smar000 commented 7 months ago

Sure, I will look at adding it next time I do an update. In the meantime you could try replacing the line 68 with something like the following (not tested!):


import argparse
parser = argparse.ArgumentParser(description="evoGateway - MQTT Gateway for evohome")
parser.add_argument("-c","--config", help="Specify config file", required=False)
args=vars(parser.parse_args())

CONFIG_FILE = args["config"] if "config" in args else "evogateway.cfg"

The config file can be passed with e.g. -c evogateway.cfg

ericbieri commented 7 months ago

Hi smar000, cool thanks in advance for adding this feature and a happy and successful year 2024 to you. ;-)

smar000 commented 7 months ago

Most welcome, and happy new year to you too!