SmartThings synchronous GET webservice call

Hi, Im trying to call a web service on my local network from within a SmartThings SmartApp. However I cannot seem to get this to work. The call needs to be a GET. I have tried using HttpGet but I get an error saying the address is blacklisted ( its a local IP and I have read that you cant do this with HttpGet ). So I have tried with physicalgraph.device.HubAction. I cannot get this to work either. Is there any ways of doing a synchronous get as I need the response as part of the method that is executing.

The HubAction code is as follow:

def result = new physicalgraph.device.HubAction(
method: ā€œGETā€,
path: ā€œhttp://192.168.1.123:3000/bcloudsmart/tadoā€,
headers: [ā€œContent-Typeā€:ā€œapplication/json;charset=UTF-8ā€,
HOST: ā€œ192.168.1.123:3000ā€,
] )

	try 
	{
		sendHubCommand(result)
	} 
	catch(e)
	{
    	logInfo( "$e" );
		sendNotificationEvent("Exception occurred: $e")
	}

The parse method is never getting called. Even if I did get this working, has anyone any ideas of how I could use it in a more synchronous way.

Thanks

Steve

Welcome to the SmartThings Community, @stevepb!
Where are you creating the SmartThings app? physicalgraph.device.HubAction is a function of the legacy platform (IDE)
I suggest you use the SmartApp Node JS SDK instead, which is part of the current Developer Tools. Hereā€™s a tutorial on how to create a simple SmartApp that can help you get started.

Also, you can provide more details about your integration so I can give you other recommendations. :smiley:

2 Likes

That wouldnā€™t work for a local device AFAIK. Is there an API for connecting with a local lan device via the hub?

Try adding the callback property to be the function call and specify your callback handler ?make itā€™s scope of globally accessible and not a private callback) and it should call the callback. Iā€™ve found it more reliable than parse.

You might take a look at the following. It uses the new edge driver platform. But I donā€™t think GETs are quite working yet. (The topic title is a clickable link.)

GETs are working, in that they execute; Iā€™m still figuring out what to do with the returned data. Right now my direction is to just plunk it into a string attribute for display in the mobile app. You can do an equals comparison in Rules against it, but it has to be against the entire string; there are no substring or ā€˜containsā€™ type of compares in Rules right now.

2 Likes