Woohoo! This worked. I moved the bulb and set color into the execute every minute and now it’s working great. I’ll mess around to find a way to leave the bulb off if it’s already off.
Thanks for everyone’s help.
Woohoo! This worked. I moved the bulb and set color into the execute every minute and now it’s working great. I’ll mess around to find a way to leave the bulb off if it’s already off.
Thanks for everyone’s help.
The command:
Every X minutes, do Y
Is one of the few triggers that does not run top to bottom. It only executes what is inside the block at the time of execution. The rest of the code outside is ignored.
So this worked until recently. It appears that it cannot read the response with $response. Any ideas on how to write out a json expression to pull data?
Are there any errors at account.smartthings.com > Live Logging? It looks like this API responds quickly enough to not be affected by the linked timeout issue, at least from your past logs. If there are no errors, try logging $httpStatusCode
– is it in the 300’s?
Oh nope, this is something new. webCoRE is sending a very wrong request header:
Accept: application/x-www-form-urlencoded
That doesn’t make sense, the Accept header tells the server what type of response it should send back. It should not be set to match the request. I don’t see any code in webCoRE doing this, SmartThings is defaulting that to the request type but I can override it. That’s an illogical default
If you need this quickly and want to apply a code patch, line 3301 in the webCoRE Piston smart app sets the requestContentType
and needs the following contentType
line added (this code is not specific to you, JSON is the only response that webCoRE understands and “prefers” but anything is acceptable)
requestContentType: requestContentType,
contentType: 'application/json, */*;q=0.9', // add this line
My god, you’re a genius. This now works and my lights finally turn color and my outdoor lights finally turn off when it’s light outside. I couldn’t be certain, but I recently updated webcore and this is what must have messed up everything. Thanks so much.
Should I post this as a bug, though I don’t understand the issue beyond what you typed.
I’ll write up a bug and link this task. It was convenient that your API URL was still in the thread!
I have since confirmed that the edit sometimes works and sometimes doesn’t. There must be something else also happening that is affecting the reliability of the get request.
When it works
3/4/2021, 7:10:43 AM +298ms
+1ms ╔Received event [Home].wc_async_reply = httpRequest with a delay of 0ms
+76ms ║RunTime Analysis CS > 14ms > PS > 5ms > PE > 56ms > CE
+78ms ║Runtime (46581 bytes) successfully initialized in 5ms (v0.3.113.20210203) (77ms)
+79ms ║╔Execution stage started
+94ms ║║Calculating (decimal) 26.0 , (decimal) 0.0 >> (decimal) 26.0
+97ms ║║Executed virtual command setVariable (2ms)
+145ms ║║Calculating (dynamic) 26.0 <= (integer) 110 >> (boolean) true
+150ms ║║Calculating (dynamic) 26.0 <= (integer) 100 >> (boolean) true
+155ms ║║Calculating (dynamic) 26.0 <= (integer) 95 >> (boolean) true
+160ms ║║Calculating (dynamic) 26.0 <= (integer) 90 >> (boolean) true
+165ms ║║Calculating (dynamic) 26.0 <= (integer) 85 >> (boolean) true
+171ms ║║Calculating (dynamic) 26.0 <= (integer) 80 >> (boolean) true
+180ms ║║Calculating (dynamic) 26.0 <= (integer) 75 >> (boolean) true
+185ms ║║Calculating (dynamic) 26.0 <= (integer) 70 >> (boolean) true
+191ms ║║Calculating (dynamic) 26.0 <= (integer) 65 >> (boolean) true
+196ms ║║Calculating (dynamic) 26.0 < (integer) 60 >> (boolean) true
+200ms ║║Calculating (dynamic) 26.0 <= (integer) 55 >> (boolean) true
+206ms ║║Calculating (dynamic) 26.0 <= (integer) 50 >> (boolean) true
+210ms ║║Calculating (dynamic) 26.0 <= (integer) 45 >> (boolean) true
+215ms ║║Calculating (dynamic) 26.0 <= (integer) 40 >> (boolean) true
+219ms ║║Calculating (dynamic) 26.0 < (integer) 32 >> (boolean) true
+224ms ║║Calculating (dynamic) 26.0 <= (integer) 15 >> (boolean) false
+228ms ║║Calculating (dynamic) 26.0 <= (integer) 0 >> (boolean) false
+232ms ║║Calculating (decimal) 0.0 - (decimal) 5.0 >> (decimal) -5.0
+235ms ║║Calculating (dynamic) 26.0 <= (decimal) -5.0 >> (boolean) false
+239ms ║║Calculating (decimal) 0.0 - (decimal) 10.0 >> (decimal) -10.0
+242ms ║║Calculating (dynamic) 26.0 <= (decimal) -10.0 >> (boolean) false
+246ms ║║Executed virtual command setVariable (2ms)
+249ms ║║Cancelling statement #23’s schedules…
+289ms ║║Executed physical command [Weather Lamp].setColor([[hex: #4242ff, hue:67, saturation:100, level:63]]) (32ms)
+290ms ║║Executed [Weather Lamp].setColor (37ms)
+292ms ║╚Execution stage complete. (213ms)
+294ms ║Setting up scheduled job for Thu, Mar 4 2021 @ 7:15:44 AM CST (in 300s)
+304ms ╚Event processed successfully (304ms)
When it doesn’t
3/4/2021, 7:06:08 AM +56ms
+0ms ╔Received event [Home].time = 1614863168599 with a delay of -543ms
+75ms ║RunTime Analysis CS > 13ms > PS > 6ms > PE > 56ms > CE
+78ms ║Runtime (46576 bytes) successfully initialized in 6ms (v0.3.113.20210203) (77ms)
+80ms ║╔Execution stage started
+147ms ║║Calculating (decimal) 32.0 , (decimal) 0.0 >> (decimal) 32.0
+154ms ║║Executed virtual command setVariable (3ms)
+214ms ║║Calculating (dynamic) 32.0 <= (integer) 110 >> (boolean) true
+220ms ║║Calculating (dynamic) 32.0 <= (integer) 100 >> (boolean) true
+226ms ║║Calculating (dynamic) 32.0 <= (integer) 95 >> (boolean) true
+233ms ║║Calculating (dynamic) 32.0 <= (integer) 90 >> (boolean) true
+239ms ║║Calculating (dynamic) 32.0 <= (integer) 85 >> (boolean) true
+245ms ║║Calculating (dynamic) 32.0 <= (integer) 80 >> (boolean) true
+251ms ║║Calculating (dynamic) 32.0 <= (integer) 75 >> (boolean) true
+257ms ║║Calculating (dynamic) 32.0 <= (integer) 70 >> (boolean) true
+263ms ║║Calculating (dynamic) 32.0 <= (integer) 65 >> (boolean) true
+269ms ║║Calculating (dynamic) 32.0 < (integer) 60 >> (boolean) true
+275ms ║║Calculating (dynamic) 32.0 <= (integer) 55 >> (boolean) true
+281ms ║║Calculating (dynamic) 32.0 <= (integer) 50 >> (boolean) true
+288ms ║║Calculating (dynamic) 32.0 <= (integer) 45 >> (boolean) true
+293ms ║║Calculating (dynamic) 32.0 <= (integer) 40 >> (boolean) true
+298ms ║║Calculating (dynamic) 32.0 < (integer) 32 >> (boolean) false
+304ms ║║Calculating (dynamic) 32.0 <= (integer) 15 >> (boolean) false
+309ms ║║Calculating (dynamic) 32.0 <= (integer) 0 >> (boolean) false
+312ms ║║Calculating (decimal) 0.0 - (decimal) 5.0 >> (decimal) -5.0
+316ms ║║Calculating (dynamic) 32.0 <= (decimal) -5.0 >> (boolean) false
+320ms ║║Calculating (decimal) 0.0 - (decimal) 10.0 >> (decimal) -10.0
+323ms ║║Calculating (dynamic) 32.0 <= (decimal) -10.0 >> (boolean) false
+329ms ║║Executed virtual command setVariable (3ms)
+332ms ║║Cancelling statement #23’s schedules…
+347ms ║║Executed physical command [Weather Lamp].setColor([[hex: #428dff, hue:60, saturation:100, level:63]]) (7ms)
+348ms ║║Executed [Weather Lamp].setColor (10ms)
+386ms ║╚Execution stage complete. (306ms)
+388ms ║Setting up scheduled job for Thu, Mar 4 2021 @ 7:10:44 AM CST (in 275s)
+396ms ╚Event processed successfully (396ms)