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 Like
tgauchat
(ActionTiles.com co-founder Terry @ActionTiles; GitHub: @cosmicpuppy)
2
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.
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…
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.
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.
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!
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 had a script doing this too but currently it’s receiving a “422 unprocessable entity” response when trying to perform the update. Has anybody else had this issue?