Merge pull request #1387 from larsfinander/DVCSMP-2168_Philips_Hue_LIFX_dw_registration_in_update_staging

DVCSMP-2168 Philips Hue/LIFX: Send device watch registration
This commit is contained in:
Lars Finander
2016-10-24 16:53:51 -06:00
committed by GitHub
2 changed files with 17 additions and 0 deletions

View File

@@ -299,6 +299,7 @@ def initialize() {
state.bridgeRefreshCount = 0 state.bridgeRefreshCount = 0
state.bulbRefreshCount = 0 state.bulbRefreshCount = 0
state.updating = false state.updating = false
setupDeviceWatch()
if (selectedHue) { if (selectedHue) {
addBridge() addBridge()
addBulbs() addBulbs()
@@ -321,6 +322,14 @@ def uninstalled(){
state.username = null state.username = null
} }
private setupDeviceWatch() {
def hub = location.hubs[0]
// Make sure that all child devices are enrolled in device watch
getChildDevices().each {
it.sendEvent(name: "DeviceWatch-Enroll", value: "{\"protocol\": \"LAN\", \"scheme\":\"untracked\", \"hubHardwareId\": \"${hub?.hub?.hardwareID}\"}")
}
}
private upgradeDeviceType(device, newHueType) { private upgradeDeviceType(device, newHueType) {
def deviceType = getDeviceType(newHueType) def deviceType = getDeviceType(newHueType)

View File

@@ -271,9 +271,17 @@ def initialize() {
updateDevices() updateDevices()
// Check for new devices and remove old ones every 3 hours // Check for new devices and remove old ones every 3 hours
runEvery5Minutes('updateDevices') runEvery5Minutes('updateDevices')
setupDeviceWatch()
} }
// Misc // Misc
private setupDeviceWatch() {
def hub = location.hubs[0]
// Make sure that all child devices are enrolled in device watch
getChildDevices().each {
it.sendEvent(name: "DeviceWatch-Enroll", value: "{\"protocol\": \"LAN\", \"scheme\":\"untracked\", \"hubHardwareId\": \"${hub?.hub?.hardwareID}\"}")
}
}
Map apiRequestHeaders() { Map apiRequestHeaders() {
return ["Authorization": "Bearer ${state.lifxAccessToken}", return ["Authorization": "Bearer ${state.lifxAccessToken}",