@coreystup , @bertabcd1234 : Many thanks for the documentation links, very helpful.
@tomw : With those documentation links I think I have found a clue to my issue. In my logs I see the parse() method set the state variable at 03:23:41.963 then the sending methods checks it at 1 second intervals up to 03:23:46.312 but does not see a change and so times out. In other words the sending method has still not seen a change in the state variable 4 seconds after parse() has updated it.
I use pauseExecution(1000) to create my timeout loop and I am wondering if this maybe the cause of the problem? The Hubitat documentation says " state
writes data just before the app goes to sleep again". The ST documentation says sate is "A map of name/value pairs that a Device Handler can use to save and retrieve data across executions". Maybe the sending thread only reads the state variable when it starts up after sleep() and pause execution does allow the thread to update the state variable?