I’m trying to get back a response from a hubAction call. The docs imply this should come in the parameter to parse that is called after hubAction is returned from the device hander’s event.
But I’m getting just a bit of call data…
‘index:0F, mac:0073E023A13A, ip:C0A80114, port:040B, requestId:c1f09565-94e4-4b55-9f88-a99ecab297ee’
I can see on the sniffer that the correct data is being returned, and the code is correctly waiting for it. It’s just not seeming to give me access to the headers or content.
(Ideally I’d be using the httpGet() command, but that apparently can’t send to addresses on the LAN.)
It’s a standard HTTP response, part text, part binary. Works wonderfully in any browser, or with curl (which parses the headers and can redirect the content to a file.) Just doesn’t seem to be visible, in any form, to hubAction’s parse data.
From the link I provided above, they claim it would include: When you make a request to your device using HubAction, any response will be passed to your device-handler’s parse method, just like other device messages.
def msg = parseLanMessage(description) def headersAsString = msg.header // => headers as a string def headerMap = msg.headers // => headers as a Map def body = msg.body // => request body as a string
…
But as you can see, I’m not getting any of that, just the requestId. parseLanMessage() is merely parsing the string into a map. How do I resolve the requestID to the actual response, or retrieve the correct response in parse()?
Interesting. Are you telling me that the headers won’t come across if the content-type is, for example, image/jpeg instead of application/json? How do the LAN cameras do it?
In this case, it’s a file with proper HTTP headers, but the body is all binary content.
It’s not working here. Using your device type, configured up, I get:
1cd2ae5f-7a5e-442b-a292-afd9a7827cd4 6:16:54 AM: debug Parsing 'index:0F, mac:4C11BF298685, ip:C0A8010F, port:0050, requestId:d86e0efc-e83e-4167-a6c0-9be9c16071d6’
1cd2ae5f-7a5e-442b-a292-afd9a7827cd4 6:16:53 AM: debug GET cgi-bin/snapshot.cgi HTTP/1.1
Accept: /
User-Agent: Linux UPnP/1.0 SmartThings
HOST: 192.168.1.15:80
Authorization: Basic YWRtaW46UmVtVmlldw==
1cd2ae5f-7a5e-442b-a292-afd9a7827cd4 6:16:53 AM: debug The method is GET
1cd2ae5f-7a5e-442b-a292-afd9a7827cd4 6:16:53 AM: debug The Header is [HOST:192.168.1.15:80, Authorization:Basic YWRtaW46UmVtVmlldw==]
1cd2ae5f-7a5e-442b-a292-afd9a7827cd4 6:16:53 AM: debug Uses which method: GET
1cd2ae5f-7a5e-442b-a292-afd9a7827cd4 6:16:53 AM: debug Requires Auth: true
1cd2ae5f-7a5e-442b-a292-afd9a7827cd4 6:16:53 AM: debug path is: cgi-bin/snapshot.cgi
1cd2ae5f-7a5e-442b-a292-afd9a7827cd4 6:16:53 AM: debug The device id configured is: C0A8010F:0050
1cd2ae5f-7a5e-442b-a292-afd9a7827cd4 6:16:53 AM: debug 0050
1cd2ae5f-7a5e-442b-a292-afd9a7827cd4 6:16:53 AM: debug IP address entered is 192.168.1.15 and the converted hex code is c0a8010f
As you can see, same thing. No S3 key/bucket, just the request id.
Is there some configuration on the SmartThings hub I could have wrong?
How big is the response? What type of camera? St hub may truncate larger images and responses even with s3. Also s3 is flaky for some. Corrupt images or timeouts. Open a support ticket as I can’t do anything from my side.
Thanks. The size seems to have been the problem. From experimentation, it seems like the practical limit is just under a 30KB payload (content beyond headers.)