arnonym/ha-plugins

Issues with .env.example

Closed this issue · 6 comments

Hi, I try to get the standalone version running but the .env.example did has some issues.

Most env vars are specified with ". But the config parser did not remove them.

So in example:

COMMAND_SOURCE="mqtt"

in code this failes:

config.COMMAND_SOURCE.lower().strip() == "mqtt"

cause the result string is '"mqtt"' and not 'mqtt'.

Seems also be the case for ports and co.

Maybe the .env.example should be changed or the config should use .strip('"')

Hi, looks like docker-compose does handle .env-files differently than the python package dotenv, which removes the quotes. Running locally outside docker with the provided .env.example is working perfectly fine.

I think it would make more sense to mount the .env file into the container and read the config from there instead of working around the docker-compose way of handling .env files. I will look into this if I have some time.

Thanks for the report!

Well I can not say if docker-compose env would remove that. I added the env vars directly do my docker-compse file.

I would suggest to simply change the config.py and add an .strip('"') to each line. This should handle that cases for all.

That's a bit too magically for my taste. There might be passwords starting or ending with quotes. If the docker-compose file does handle quotes differently, I would just remove them from there. If this was hard to debug, I could add a note to the docs.

Then it might be better to remove the " from the example config.

I've just tested this, and it's working when using the .env file. It's just that the format is different if providing the environment variables in the docker-compose file directly, and you need to adapt to that.

Oh ok then its truly my fault.

I would suggest to add a warning or maybe just remove the ". I am not sure, but I would expect the " are pointless here.