How does a SmartApp get hub properties and information?


(trac starr) #1

So this is similar to this topic but specific to SmartApps. I can’t seem to figure out how to get the local IP of the hub within a SmartApp. I just can’t find enough information about “physicalgraph” class or otherwise to determine how i can call the getDataValue function that seems to be available on devices. Sorry if I’m missing the (less-than) obvious.


(trac starr) #2

Anyone? I’m still lost with this one. I’m trying to keep my LAN connected devices talking only via LAN and not STH->LAN->WAN->STH


(trac starr) #3

Well, I can finally answer my own question. A SmartApp has a location, which contains a list of hubs. I’m a bit lost here as to why an app can have multiple hubs. Perhaps I misunderstand some basics about apps. They seem to not exist on individual hubs? Anyway, I’m not sure how multiple hubs work together either. That being said, I can access the first value of the list as my “current” hub. At this point I think it’s safe to assume there will always be one hub, and that I don’t care if there are multiple?

Thus, I can get the IP of the hub from the app as:

def localHubIp = location.hubs[0].localIP

(Geko) #4

There can be multiple hubs installed at any location. Apps are attached to a location and thus can access multiple hubs. Devices, on the other hand, are attached to specific hubs, unless they are “virtual” devices that don’t use hub services I.e. either Zibgee, or Zwave, or local HTTP protocols.