How is it possible to use two hubAction commands in same function?

I have two functions, one called GetValue and one called SetValue. They both use hubAction to perform an HTTP GET and the other a hubAction HTTP SET. If called in isolation, they work perfectly. However, I have a third function which needs to call SetValue followed by GetValue. In this instance only GetValue is ever completed.

From what I can tell, its the asynchronous nature of hubAction and its seemingly absolute reliance on the ‘parse’ callback. log lines from GetValue are present, but only the SetValue hubAction actually gets invoked.

I am unable to find anyway to make two hubActions work in a single call.

Any assistance is appreciated.

Nested Hub action:

  	try {
  		hubAction = [new physicalgraph.device.HubAction(
  		method: "GET",
  		path: rooPath,
  		headers: [HOST: "${settings.ip}:${settings.port}", Accept: "application/json"]
  		), delayAction(9800), api('refresh')]

private delayAction(long time) {
new physicalgraph.device.HubAction(“delay $time”)

Full code


That worked perfectly. Thank you!! Who knew we have the ability to sleep via the smartthings hub… brilliant!

Thank you both. I use the now common HubGet method, and just chained them in my X10 command:

def doX10(...) {
   // do setup
   def hubActions = [hubGet("path", true), delayAction(200), hubGet("path2", true)]

I just have to say a big thank you for having figured this out and sharing. Kudos for your brilliance. Thanks to this I’ve figured out how to put a delay in front of commands to help with timing as well as stack a group of commands together, including delays between. Couldn’t have gotten it done without this. Again job very well done!!!