Determine location(hub) that a device is connected to?


(Kris Linquist) #1

Is there any way to determine the location (what hub) a device ID is connected to? It doesn’t seem to be part of the device class.

Thanks!


(Geko) #2
def hubIp = device.hub.getDataValue("name")

(Kris Linquist) #3

a-ha, thank you very much.


(Kris Linquist) #4

In this function, I can’t seem to get the hub info - any ideas?

private deviceItem(it) {
 def hubinfo = it.hub.getDataValue("name")
 it ? [id: it.id, label: it.displayName, hub: hubinfo] : null
}

This is the code I’m using to call that function (part of the API I am building)

def type = params.deviceType
settings[type]?.collect{deviceItem(it)} ?: []

(Kris Linquist) #5

@geko any ideas? thanks!


(Kris Linquist) #6

An update - figured it out, I was able to simply say device.hub.id / device.hub.name…

Now only if I could get the deviceTypeId…