Skip to content

Commit bb718a7

Browse files
authored
fixing bug where unused lighting provider would cause errors when trying to load channel
1 parent 6d1807c commit bb718a7

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

Contents/Code/__init__.py

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,15 @@ def MainMenu(header=NAME, message=""):
6565
oc.add(InputDirectoryObject(key=Callback(CreateRoom), title='Create a Room', prompt='Please enter a room name'))
6666

6767
if Client.Product == 'Plex Web' and not ROOM_HANDLER.rooms:
68-
oc.add(DirectoryObject(key=Callback(MainMenu), title='You\'re using Plex Web. Please type a room name into the search field to add your first room.'))
68+
oc.add(DirectoryObject(key=Callback(MainMenu), title='You\'re using Plex Web. Please type a room name into the search field and hit enter to add your first room.'))
6969

7070
for room_uuid, room in ROOM_HANDLER.rooms.iteritems():
7171
oc.add(DirectoryObject(key=Callback(EditRoom, room_uuid=room_uuid), title=room['name']))
7272

7373
# This function is specific to Hue
74-
if not automation_services[hue.name].has_username():
75-
oc.add(DirectoryObject(key=Callback(ConnectHueBridge), title="Press button on Hue hub and then click here"))
74+
if is_hue_enabled():
75+
if not automation_services[hue.name].has_username():
76+
oc.add(DirectoryObject(key=Callback(ConnectHueBridge), title="Press button on Hue hub and then click here"))
7677

7778
for name, service in automation_services.iteritems():
7879
if not service.is_authenticated():
@@ -228,11 +229,14 @@ def ValidatePrefs():
228229
wink = WinkAutomation(Prefs['WINK_CLIENT_ID'], Prefs['WINK_CLIENT_SECRET'], Prefs['WINK_USERNAME'], Prefs['WINK_PASSWORD'])
229230
hue = PhilipsHueAutomation(Prefs['HUE_IP_ADDRESS'])
230231

231-
automation_services[wink.name] = wink
232-
automation_services[hue.name] = hue
232+
if is_wink_enabled():
233+
automation_services[wink.name] = wink
234+
235+
if is_hue_enabled():
236+
automation_services[hue.name] = hue
233237

234238
for name, service in automation_services.iteritems():
235-
Log(name + ' connection status is ' + str(wink.is_authenticated()))
239+
Log(name + ' connection status is ' + str(service.is_authenticated()))
236240

237241

238242
def run_websocket_watcher():
@@ -262,6 +266,17 @@ def toggle_socket_thread():
262266
threading.Thread(target=run_websocket_watcher, name=THREAD_WEBSOCKET).start()
263267

264268

269+
def is_hue_enabled():
270+
return Prefs['HUE_IP_ADDRESS'] != "HUE_IP_ADDRESS"
271+
272+
273+
def is_wink_enabled():
274+
return Prefs['WINK_USERNAME'] != "WINK_USERNAME"\
275+
and Prefs['WINK_PASSWORD'] != "WINK_PASSWORD"\
276+
and Prefs['WINK_CLIENT_ID'] != "WINK_CLIENT_ID"\
277+
and Prefs['WINK_CLIENT_SECRET'] != "WINK_CLIENT_SECRET"
278+
279+
265280
# TODO rewrite logic
266281
def is_plex_playing(plex_status, room, room_uuid):
267282
global CURRENT_STATUS
@@ -336,7 +351,7 @@ def __init__(self):
336351
global PLEX_ACCESS_TOKEN
337352

338353
HEADERS = {'X-Plex-Product': 'Automating Home Lighting',
339-
'X-Plex-Version': '3.1.0',
354+
'X-Plex-Version': '3.1.1',
340355
'X-Plex-Client-Identifier': 'PlexWink',
341356
'X-Plex-Device': 'PC',
342357
'X-Plex-Device-Name': 'PlexWink'}
@@ -372,5 +387,5 @@ def get_plex_status(self):
372387

373388
def get_plex_devices(self):
374389
Log('Requesting devices from Plex')
375-
return XML.ElementFromURL(url="https://www.plex.tv/devices.xml?X-Plex-Token=" + PLEX_ACCESS_TOKEN,
390+
return XML.ElementFromURL(url="https://plex.tv/devices.xml?X-Plex-Token=" + PLEX_ACCESS_TOKEN,
376391
headers=HEADERS, cacheTime=360)

0 commit comments

Comments
 (0)