Skip to content

Commit

Permalink
fix username not being saved
Browse files Browse the repository at this point in the history
  • Loading branch information
Snapcase committed Jul 16, 2019
1 parent 47d63ed commit 1610a6a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 4 additions & 1 deletion script.service.hue/addon.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,13 @@
<disclaimer lang="en_GB">Automate Hue lights with Kodi playback</disclaimer>
<news>v0.6.5:
- Change some ambilight default settings to better values
- Change Hue NuPNP Discovery URL until SSL chain is fixed by Pphillips
- Change Hue NuPNP Discovery URL until SSL chain is fixed by Philips
- Fix Hue username not saving properly

v0.6.0:
- Choice of fallback colour to replace blacks and whites
- Support multiple colours

v0.5.0:
- Experimental Ambilight support. See Forum for more information
v0.4.2:
Expand Down
10 changes: 7 additions & 3 deletions script.service.hue/resources/lib/kodiHue.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,22 @@ def bridgeDiscover(monitor):
monitor.waitForAbort(1)

bridgeUser = createUser(monitor, bridgeIP, progressBar)

if bridgeUser:
logger.debug("User created: {}".format(bridgeUser))
progressBar.update(90,_("User Found!"),_("Saving settings"))

kodiutils.set_setting("bridgeIP",bridgeIP)
kodiutils.set_setting("bridgeIP",bridgeIP)
kodiutils.set_setting("bridgeUser",bridgeUser)
complete = True
globals.connected = True
progressBar.update(100, _("Complete!"))
monitor.waitForAbort(5)
progressBar.close()
globals.ADDON.openSettings()
return True

else:
logger.debug("User not created, received: {}".format(bridgeUser))
progressBar.update(100, _("User not found"),_("Check your bridge and network"))
monitor.waitForAbort(5)
complete = True
Expand Down Expand Up @@ -238,6 +240,7 @@ def discoverBridgeIP(monitor):


def createUser(monitor, bridgeIP, progressBar=False):
logger.debug("In createUser")
#device = 'kodi#'+getfqdn()
data = '{{"devicetype": "kodi#{}"}}'.format(getfqdn()) #Create a devicetype named kodi#localhostname. Eg: kodi#LibreELEC

Expand All @@ -263,11 +266,12 @@ def createUser(monitor, bridgeIP, progressBar=False):
progress = progress + 1

res = req.json()
logger.debug("json response: {}, content: {}".format(res,req.content))

try:
username = res[0]['success']['username']
return username
except (requests.exceptions.ConnectionError, qhue.QhueException):
except Exception:
return False


Expand Down

0 comments on commit 1610a6a

Please sign in to comment.