mirror of
https://github.com/mtan93/SmartThingsPublic.git
synced 2026-03-21 21:03:47 +00:00
DVCSMP-2131 Philips Hue: Handle case if bridge username becomes invalid
This commit is contained in:
@@ -37,7 +37,10 @@ preferences {
|
|||||||
|
|
||||||
def mainPage() {
|
def mainPage() {
|
||||||
def bridges = bridgesDiscovered()
|
def bridges = bridgesDiscovered()
|
||||||
if (state.username && bridges) {
|
|
||||||
|
if (state.refreshUsernameNeeded) {
|
||||||
|
return bridgeLinking()
|
||||||
|
} else if (state.username && bridges) {
|
||||||
return bulbDiscovery()
|
return bulbDiscovery()
|
||||||
} else {
|
} else {
|
||||||
return bridgeDiscovery()
|
return bridgeDiscovery()
|
||||||
@@ -102,13 +105,22 @@ def bridgeLinking() {
|
|||||||
|
|
||||||
def nextPage = ""
|
def nextPage = ""
|
||||||
def title = "Linking with your Hue"
|
def title = "Linking with your Hue"
|
||||||
def paragraphText
|
def paragraphText
|
||||||
if (selectedHue) {
|
if (selectedHue) {
|
||||||
|
if (state.refreshUsernameNeeded) {
|
||||||
|
paragraphText = "The current Hue username is invalid.\n\nPlease press the button on your Hue Bridge to re-link. "
|
||||||
|
} else {
|
||||||
paragraphText = "Press the button on your Hue Bridge to setup a link. "
|
paragraphText = "Press the button on your Hue Bridge to setup a link. "
|
||||||
} else {
|
}
|
||||||
paragraphText = "You haven't selected a Hue Bridge, please Press \"Done\" and select one before clicking next."
|
} else {
|
||||||
}
|
paragraphText = "You haven't selected a Hue Bridge, please Press \"Done\" and select one before clicking next."
|
||||||
|
}
|
||||||
if (state.username) { //if discovery worked
|
if (state.username) { //if discovery worked
|
||||||
|
if (state.refreshUsernameNeeded) {
|
||||||
|
state.refreshUsernameNeeded = false
|
||||||
|
// Issue one poll with new username to cancel local polling with old username
|
||||||
|
poll()
|
||||||
|
}
|
||||||
nextPage = "bulbDiscovery"
|
nextPage = "bulbDiscovery"
|
||||||
title = "Success!"
|
title = "Success!"
|
||||||
paragraphText = "Linking to your hub was a success! Please click 'Next'!"
|
paragraphText = "Linking to your hub was a success! Please click 'Next'!"
|
||||||
@@ -915,8 +927,15 @@ private handleCommandResponse(body) {
|
|||||||
updates[childDeviceNetworkId]."$eventType" = v
|
updates[childDeviceNetworkId]."$eventType" = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (payload.error) {
|
} else if (payload?.error) {
|
||||||
log.warn "Error returned from Hue bridge error = ${body?.error}"
|
log.warn "Error returned from Hue bridge, error = ${payload?.error}"
|
||||||
|
// Check for unauthorized user
|
||||||
|
if (payload?.error?.type?.value == 1) {
|
||||||
|
log.error "Hue username is not valid"
|
||||||
|
state.refreshUsernameNeeded = true
|
||||||
|
state.username = null
|
||||||
|
}
|
||||||
|
return []
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user