Great!!
But is there a way we can get it from the SmartApp coding level like maybe getID()?
Instead of calling https://graph.api.smartthings.com/api/hubs and i need to do some parsing to get the ID.
I do not know of a way to get the hub id easily in a SmartApp but as far as I know you can only have one hub per location so you can use the Location object which is available to tell where something triggers. http://docs.smartthings.com/en/latest/ref-docs/location-ref.html Will that work for what you want to do?
If I’m using location as an ID, it might keep changing if i place my hub to different location right?
Let say I do my development at my office this morning and I bring my hub back home to continue my development at evening time.
If really there’s no get hub ID function available, I might just use https://graph.api.smartthings.com/api/hubs and do some parsing on SmartApp code there.
Thanks Andy…
Yeah, I would guess that they assumed the location object would cover anything needed since most people won’t be moving hubs from location to location on a regular basis. Also, an instance of a SmartApp runs inside the context of a location and can’t really interact with other locations I am pretty sure.
It’s not doc’d yet. You can get the hubs for a location via location.hubs which returns a list of hubs for that location. You could then get the id from each hub in the location that way: def hubIds = location.hubs*.id. Note that location.hubs will return a list of hubs for that location, even if there is only one hub.
You can also get the hub for an event via evt.hub, and get the id from there if you want the hub associated with the event. There is only one hub for an event.
We’ll get it clarified and in the docs.
2 Likes
tgauchat
(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy)
13
Yah… 3 years on and the documentation remains very incomplete. Guess I should be thankful for the tremendous ongoing improvements. I just find it incomprehensible that the API for an “open” platform aren’t documented at the same time that the Objects and Methods are coded!!!.
hubID is documented under the Event Object, but no others, as far as I can tell.
It used to be possible to connect multiple hubs on a location from the IDE. This is no longer the case, but some customers have more than one hub on a location. A very small subset.
1 Like
tgauchat
(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy)
16
So is this a permanent feature deprecation?
Is the data model going to change so that there is a 1:1 constraint between LocationHub?
No - that was removed over a year ago. Multi-hub locations are in our future.
1 Like
tgauchat
(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy)
18
This is “sorta” important to know for some folks that may be writing SmartApps or Device Handlers, etc., that are using location.id vs. hub.id.
It’s one thing for the Platform to currently not allow the installation of more than one Hub in a Location, but it is another for the data model to never allow it, or for the data model to actually explicitly imply that it “will be in our future”.
Not sure I’m making sense… I’m trying to ask if the relationship: Location:Hub is still, officially, 1:Many (as in one location object can be related to many hub objects, but a hub belongs to exactly one and only one location.
Or … will the data / object model in regards to Location and Hubs completely change when multi-hub locations are re-introduced??