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

Improve connection #215

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ test.py
*.sublime-workspace
dist
MANIFEST
.python_hue
lights.json
.venv
2 changes: 1 addition & 1 deletion examples/flicker.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import random
from time import sleep
from phue import Bridge
b = Bridge('192.168.0.23')
b = Bridge()
b.connect()
lights = b.lights

Expand Down
1 change: 1 addition & 0 deletions examples/hue-rainbow.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# in the time specified in totalTime
from phue import Bridge
import random
from time import sleep

b = Bridge() # Enter bridge IP here.

Expand Down
4 changes: 3 additions & 1 deletion phue.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,12 +621,14 @@ def __init__(self, ip=None, username=None, config_file_path=None):

if config_file_path is not None:
self.config_file_path = config_file_path
elif os.access(os.path.join(os.getcwd(), '.python_hue'), os.R_OK):
self.config_file_path = os.path.join(os.getcwd(), '.python_hue')
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')
logger.exception('Could not retrieve bridge connection configuration.')

self.ip = ip
self.username = username
Expand Down