arnonym / ha-plugins

Home-Assistant SIP Gateway
Apache License 2.0
171 stars 22 forks source link

Issues with .env.example #109

Closed lanwin closed 3 months ago

lanwin commented 3 months ago

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('"')

arnonym commented 3 months ago

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!

lanwin commented 3 months ago

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.

arnonym commented 3 months ago

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.

lanwin commented 3 months ago

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

arnonym commented 3 months ago

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.

lanwin commented 3 months ago

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.