Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python Hue Config File Location #183

Open
KikeMendez opened this issue Apr 5, 2021 · 4 comments
Open

Python Hue Config File Location #183

KikeMendez opened this issue Apr 5, 2021 · 4 comments

Comments

@KikeMendez
Copy link

KikeMendez commented Apr 5, 2021

Hi There, I would like to have .python_hue in different location rather that the home default one.

Ideally something like this would be awesome to have:

hue_bridge_config = "home/.folder/python_hue"

bridge = Bridge(ip=bridge_ip, config_file_path=hue_bridge_config)

So instead of saving it on the home directory, saves it wherever the config_file_path is set to, if config_file_path is not set then use the default as it is at the moment.

Does the library have already something to achieve this? I have been looking but no luck so far.

Thanks

@natcl
Copy link
Member

natcl commented Apr 6, 2021

This should already work, see

phue/phue.py

Line 608 in 6882829

if config_file_path is not None:

@KikeMendez
Copy link
Author

KikeMendez commented Apr 9, 2021

Hi natcl thank you for coming back, yeah I though that would work but it doesn't, actually i ended with an empty file.
Setting the config_file_path means you need to have it pre configure before hand?
Thanks again

@KikeMendez KikeMendez reopened this Apr 9, 2021
@natcl
Copy link
Member

natcl commented Apr 9, 2021 via email

@bmedicke
Copy link

I just had the same issue before I figured out my error. Note that you should not pass the path alone, but the filename as well. For your example, it would be:
config_file_path = "home/.folder/python_hue/.python_hue".

See:

phue/phue.py

Lines 608 to 615 in 6882829

if config_file_path is not None:
self.config_file_path = config_file_path
elif os.getenv(USER_HOME) is not None and os.access(os.getenv(USER_HOME), os.W_OK):
self.config_file_path = os.path.join(os.getenv(USER_HOME), '.python_hue')
elif 'iPad' in platform.machine() or 'iPhone' in platform.machine() or 'iPad' in platform.machine():
self.config_file_path = os.path.join(os.getenv(USER_HOME), 'Documents', '.python_hue')
else:
self.config_file_path = os.path.join(os.getcwd(), '.python_hue')

For all the other cases, the filename is joined. I would rename the parameter config_file_path to config_file to avoid confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants