Set Hub Location Programmatically

Is there any way to set the Hub location programmatically? I haven’t found a way to change the location in the API docs.

I currently have a v2 Hub installed in my RV. Since the RV moves pretty regularly I’m looking for a way to update the Hub location to my current coordinates whenever I stop. I know how to do it manually in the app, but this is tedious when I’m in transit and I often forget.

I leave an old phone in the RV at all times and ideally I’d love to have the Hub location synced to the phone’s location automagically or via some script (IFTTT, smartapp, etc).

  1. You may want to change the Title of this Topic to say “Geographical Location” or “Coordinates”, because “Location” is a data object in SmartThings with a specific meaning. It has many other attributes besides geographical location.

  2. Most of the Properties of the Location Object (like most SmartThings configuration Object Properties … e.g., Device.Name), are likely immutable from any 3rd party developed API - at least “officially”. Various examples show up in the forum from time to time of code that can update properties using undocumented techniques. I can’t recall if geolocation coordinates has ever been mentioned in this context. But, I guess you can, hope, and search…

  3. I haven’t paid super close attention to the new API docs. As best I can tell, so far, these constraints have not been lifted.… Yes; the new API is less constrained in this regard. See posts that follow.

1 Like

I would think you should be able to do the following:

  1. Login to the IDE
  2. navigate to:
  3. click “generate new token” (it has a 50 year expiration period - generally should only be used for testing but in your case this will work)
  4. select all the “location” scopes (more on that in a minute)
  5. navigate to our new api docs: (specifically the location api)
  6. Notice the following:
    a) required oauth scopes (write locations)
    b) URL to call (top right){locationId}
    c) Request sample (this is what you will send the API)
  7. Make a PUT request to the location you want to update and in the Authorization header put “Bearer YOUR TOKEN” and include the new coordinates you want to use.

Here is an example using curl:

  -H 'authorization: Bearer <PUT TOKEN HERE>' \
  -d '{
    "name": "latlongtest",
    "latitude": 45.0,
    "longitude": 45.0,
    "regionRadius": 150,
    "temperatureScale": "F",
    "locale": "en-US"

I think that should get you what you need. Please let me know if you run into any trouble. @tgauchat fyi

EDIT: Because this will definitely be asked… Currently if you are a smartapp author and you want to hit the api from your app and distribute it, your users will have to go through the token generation process as well. Oauth in to the API has not been released yet.


You are my hero! Thank you so much, I swear I looked through the docs a while ago when I first started this, but it looks like the docs have been updated and redesigned!

I think I’m going to use Tasker on my Android device to PUT that request with my current GPS coordinates every time I connect to the wifi in my RV. This way they’re always in sync when I’m in the RV and it won’t update when I’m out!



Awesome, I haven’t heard of anyone actively changing their GPS coordinates before (this wasn’t really possible before these APIs) so I am really curious to hear how this works out for you. Please check in and let us know how it turns out!


Set it up with Tasker (+ RESTask). Working great.

FYI the docs mention all the fields in the body being optional but it would only work for me if I supplied the name in addition to lat/lon. Without specifying a name I was getting 422 errors even though I authenticated successfully.


I’ll pass this along to the team working on this API. Thanks for letting us know.

1 Like