Getting Status of Garage door into a variable


#1

1) Give a description of the problem
I’m trying to access a simplecommands Webhook to get the status of my Garage door.

2) What is the expected behaviour?
when I access the URL I get this information
{“sessionId”:“89f00699-9bfa-4b10-bd2f-b72cf5aa0fdf”,“requestId”:“1ac5077f-974b-42b3-907b-e896261a0435”,“responseText”:“Your Garage Door is closed.”,“responseCode”:“SESSION_SUCCESS”,“followUpExpected”:false,“sessionComplete”:true,“json”:null,“applicationType”:“SIMPLECOMMANDS”}

I want to be able to access the value of responseText to determine if my Garage door is open or closed

3) What is happening/not happening?
(PUT YOUR INFO HERE)
It seems like the only value I get in $response after the get is a :

**4) Post a Green Snapshot of the piston![image|45x37]![image|690x372]

5) Attach logs after turning logging level to Full
4/24/2021, 11:09:16 AM +32ms
+0ms ╔Received event [Home].time = 1619276957405 with a delay of -1374ms
+26ms ║RunTime Analysis CS > 13ms > PS > 4ms > PE > 10ms > CE
+29ms ║Runtime (38032 bytes) successfully initialized in 4ms (v0.3.113.20210203) (28ms)
+31ms ║╔Execution stage started
+44ms ║║Calculating (string) This is the Response: + (string) [:] >> (string) This is the Response: [:]
+47ms ║║This is the Response: [:]
+48ms ║║Executed virtual command log (1ms)
+52ms ║║Error parsing JSON data [:]
+53ms ║║Executed virtual command parseJson (2ms)
+58ms ║║Calculating (string) Status2: + (string) [:] >> (string) Status2: [:]
+61ms ║║Status2: [:]
+62ms ║║Executed virtual command log (1ms)
+68ms ║║Calculating (string) ResponseText: + (string) null >> (string) ResponseText: null
+71ms ║║ResponseText: null
+71ms ║║Executed virtual command log (1ms)
+73ms ║╚Execution stage complete. (42ms)
+74ms ╚Event processed successfully (74ms)
4/24/2021, 11:08:53 AM +486ms
+0ms ╔Received event [Home].wc_async_reply = httpRequest with a delay of 0ms
+41ms ║RunTime Analysis CS > 25ms > PS > 6ms > PE > 11ms > CE
+44ms ║Runtime (38036 bytes) successfully initialized in 6ms (v0.3.113.20210203) (42ms)
+44ms ║╔Execution stage started
+55ms ║║Calculating (string) This is the Response: + (string) [:] >> (string) This is the Response: [:]
+58ms ║║This is the Response: [:]
+59ms ║║Executed virtual command log (1ms)
+62ms ║║Error parsing JSON data [:]
+62ms ║║Executed virtual command parseJson (1ms)
+68ms ║║Calculating (string) Status2: + (string) [:] >> (string) Status2: [:]
+71ms ║║Status2: [:]
+71ms ║║Executed virtual command log (1ms)
+77ms ║║Calculating (string) ResponseText: + (string) null >> (string) ResponseText: null
+80ms ║║ResponseText: null
+81ms ║║Executed virtual command log (1ms)
+82ms ║╚Execution stage complete. (38ms)
+83ms ╚Event processed successfully (83ms)
4/24/2021, 11:08:53 AM +306ms
+1ms ╔Received event [Home].test = 1619276933306 with a delay of 0ms
+33ms ║RunTime Analysis CS > 17ms > PS > 5ms > PE > 10ms > CE
+36ms ║Runtime (38028 bytes) successfully initialized in 5ms (v0.3.113.20210203) (34ms)
+37ms ║╔Execution stage started
+42ms ║║Cancelling statement #1’s schedules…
+49ms ║║Sending external web request to: api.kloee.com/api/webhooks/8f527a40-f7fc-45f4-9f7c-8e40ceb5f0bc
+88ms ║║Executed virtual command httpRequest (40ms)
+98ms ║║Requesting a wake up for Sat, Apr 24 2021 @ 11:09:17 AM EDT (in 24.0s)
+130ms ║╚Execution stage complete. (93ms)
+140ms ║Setting up scheduled job for Sat, Apr 24 2021 @ 11:09:17 AM EDT (in 23s)
+148ms ╚Event processed successfully (148msPreformatted text)


#2

This one worked for me. Also in the future, remove your API data.

4/24/2021, 9:09:59 AM +830ms
+17ms ║Resp: [sessionId:7a8c8e53-2fbf-4643-a8fe-767a1ea7306e, requestId:6b51fbeb-fee2-4847-bb42-973ee92cf2c3, responseText:Your Garage Door is closed., responseCode:SESSION_SUCCESS, followUpExpected:false, sessionComplete:true, json:null, applicationType:SIMPLECOMMANDS]
+25ms ║Status: Your Garage Door is closed.


#3

That is really strange I just imported your example and it still does the same thing for me

/24/2021, 12:46:28 PM +326ms
+44ms	║Resp: [:]
+53ms	║Status: null

#4

I think that response “[:]” indicates no response has been returned from the URL call. I use that on my internal servers as a check to see if they are running or not.

Is your hub online/internet connection ok?


#5

Yes and I can access the url fine from a browser.


#6

I’m on Hubitat so not sure if there’s a difference.


#7

Interesting that the web response event and the timeout both ran the piston. Could the server be sending a redirect? That’s been causing issues with asynchronous HTTP in SmartThings (but not Hubitat).


#8

Could it be the format of the response. I’m trying to remember the details, but I wrote a node.js app which I called from webcore. I think I had something wrong with the way I returned the response (possible not calling a final method or something) however, when I called the app from a browser it worked fine but webcore timed out as you are seeing. A change to the app sorted the issue.

It may be worth asking the garage door vender