How to specify hub to use with sendHubCommand()?


(codersaur) #1

When using sendHubCommand() from a smartapp installed in a location with multiple hubs, how can I specify which hub is used to send the command?

If this is not currently possible, how does sendHubCommand() currently decide which hub to use?

@Staff_Members @slagle @Jim


( I hate Mondays) #2

I would assume the “selected” hub is the one connected to the location under which the SmartApp that calls the sendHubCommand() is running. As far as I know, a location can currently only hold one hub, so that seems like the common sense way of choosing which hub. To run the command on another hub, the command needs to be executed by a SmartApp that runs within its location, I am assuming again?


(codersaur) #3

Ah, according to http://docs.smartthings.com/en/latest/ref-docs/location-ref.html?highlight=location.hubs#gethubs

getHubs()
The list of Hubs for this Location. Currently only Hub can be installed into a Location, thought this API returns a List to allow for future expandability.

…poor wording in the documentation.

So if we’re ever allowed multiple hubs in a location, then sendHubCommand() would need updating to support the specification of a particular hub.


( I hate Mondays) #4

That is correct. :smiley: