Local Web Request to Vizio SmartCast API is getting 408


#1

1) Give a description of the problem
I can successfully make API calls to my Vizio TV (SmartCast) via Postman. But when I try to make the same call via SmartThings/WebCore, I’m getting a 408

2) What is the expected behaviour?
I expect to get a 200 back from the POST call, and the TV should turn on

3) What is happening/not happening?
I’m getting a 408 back from the WebCore Web Request/Post

4) Post a Green Snapshot of the pistonimage
(UPLOAD YOUR IMAGE HERE)

5) Attach logs after turning logging level to Full
9/19/2020, 8:45:31 PM +462ms
+1ms ╔Starting piston… (v0.3.110.20191009)
+525ms ║╔Subscribing to devices…
+562ms ║║Subscribing to Test Button 01.button…
+628ms ║╚Finished subscribing (113ms)
+655ms ║Cancelling condition #2’s schedules…
+656ms ║Cancelling condition #1’s schedules…
+681ms ╚Piston successfully started (681ms)
9/19/2020, 8:42:02 PM +42ms
+0ms ╔Received event [The Field House].time = 1600562523853 with a delay of -1812ms
+94ms ║RunTime Analysis CS > 19ms > PS > 49ms > PE > 27ms > CE
+97ms ║Runtime (40948 bytes) successfully initialized in 49ms (v0.3.110.20191009) (95ms)
+98ms ║╔Execution stage started
+111ms ║║[:]
+112ms ║║Executed virtual command log (2ms)
+117ms ║║408
+118ms ║║Executed virtual command log (2ms)
+120ms ║╚Execution stage complete. (23ms)
+121ms ╚Event processed successfully (121ms)
9/19/2020, 8:41:43 PM +698ms
+2ms ╔Received event [Test Button 01].button = pushed with a delay of 429ms
+96ms ║RunTime Analysis CS > 20ms > PS > 49ms > PE > 26ms > CE
+98ms ║Runtime (40942 bytes) successfully initialized in 49ms (v0.3.110.20191009) (96ms)
+99ms ║╔Execution stage started
+109ms ║║Comparison (enum) pushed gets (string) pushed = true (3ms)
+110ms ║║Cancelling condition #2’s schedules…
+111ms ║║Condition #2 evaluated true (8ms)
+112ms ║║Cancelling condition #1’s schedules…
+113ms ║║Condition group #1 evaluated true (state changed) (10ms)
+116ms ║║Cancelling statement #3’s schedules…
+138ms ║║Executed virtual command sendPushNotification (18ms)
+140ms ║║Cancelling statement #9’s schedules…
+149ms ║║Sending internal web request to: 192.168.1.62:7345/key_command
+153ms ║║Executed virtual command httpRequest (5ms)
+154ms ║║Requesting a wake up for Sat, Sep 19 2020 @ 8:42:03 PM EDT (in 20.0s)
+159ms ║╚Execution stage complete. (59ms)
+160ms ║Setting up scheduled job for Sat, Sep 19 2020 @ 8:42:03 PM EDT (in 19.996s)
+168ms ╚Event processed successfully (167ms)
9/19/2020, 8:41:37 PM +144ms
+0ms ╔Starting piston… (v0.3.110.20191009)
+528ms ║╔Subscribing to devices…
+563ms ║║Subscribing to Test Button 01.button…
+657ms ║╚Finished subscribing (140ms)
+684ms ║Cancelling condition #2’s schedules…
+685ms ║Cancelling condition #1’s schedules…
+710ms ╚Piston successfully started (710ms)
9/19/2020, 8:40:51 PM +68ms
+0ms ╔Received event [The Field House].time = 1600562452445 with a delay of -1378ms
+92ms ║RunTime Analysis CS > 20ms > PS > 50ms > PE > 23ms > CE
+95ms ║Runtime (40951 bytes) successfully initialized in 50ms (v0.3.110.20191009) (94ms)
+96ms ║╔Execution stage started
+109ms ║║[:]
+110ms ║║Executed virtual command log (2ms)
+115ms ║║408
+116ms ║║Executed virtual command log (1ms)
+118ms ║╚Execution stage complete. (23ms)
+119ms ╚Event processed successfully (119ms)
9/19/2020, 8:40:32 PM +270ms
+1ms ╔Received event [Test Button 01].button = pushed with a delay of 234ms
+87ms ║RunTime Analysis CS > 18ms > PS > 45ms > PE > 24ms > CE
+89ms ║Runtime (40945 bytes) successfully initialized in 45ms (v0.3.110.20191009) (87ms)
+90ms ║╔Execution stage started
+99ms ║║Comparison (enum) pushed gets (string) pushed = true (3ms)
+101ms ║║Cancelling condition #2’s schedules…
+101ms ║║Condition #2 evaluated true (7ms)
+102ms ║║Cancelling condition #1’s schedules…
+103ms ║║Condition group #1 evaluated true (state changed) (9ms)
+105ms ║║Cancelling statement #3’s schedules…
+159ms ║║Executed virtual command sendPushNotification (50ms)
+161ms ║║Cancelling statement #9’s schedules…
+169ms ║║Sending internal web request to: 192.168.1.62:7345/key_command/
+173ms ║║Executed virtual command httpRequest (4ms)
+175ms ║║Requesting a wake up for Sat, Sep 19 2020 @ 8:40:52 PM EDT (in 20.0s)
+178ms ║╚Execution stage complete. (88ms)
+180ms ║Setting up scheduled job for Sat, Sep 19 2020 @ 8:40:52 PM EDT (in 19.996s)
+186ms ╚Event processed successfully (186ms)
9/19/2020, 8:40:24 PM +519ms
+0ms ╔Starting piston… (v0.3.110.20191009)
+591ms ║╔Subscribing to devices…
+640ms ║║Subscribing to Test Button 01.button…
+722ms ║╚Finished subscribing (142ms)
+758ms ║Cancelling condition #2’s schedules…
+759ms ║Cancelling condition #1’s schedules…
+795ms ╚Piston successfully started (795ms)v


#2

Try making the call with webcore to a mock server like beeceptor to see if it’s actually passing the data you expect.


#3

A top-notch suggestion, and one that I learned myself just a few hours ago. Used “request catcher”, which helped a TON in getting the outbound JSON string formatted correctly, and helped me solve all my webcore ternary operator errors, which are all gone now. So in short, the reflected call now looks perfect, will include screenshot… But still no joy when making the same call locally to the Vizio SmartCast API. Plus, I’m thinking that if my request was ill-formed, I’d likely be getting some sort of 400 or 500, rather than a 408 which appears to be a version of a completely timeout ?


#4

I got no more ideas lol, you’re right though that it shouldn’t be timing out if the data is improperly formatted. I can’t mock that call on any of my devices around here :slight_smile:


#5

Looks good to me too. But my brain and eyes are tired. I’ll take another look in the morning.


#6

Have you tried a get rather than a post request?


#7

Are you using an https endpoint? I don’t think that works locally.


#8

Wah-wah. (that’s a sad trombone). Yes, it’s an https endpoint. The Vizio SmartCast API only answers to https, not http. So curious, what does WebCore try to do with an https endpoint ?


#9

Yup, just confirmed:


#10

I guess that leaves me with two (time-consuming) options:

  1. Build a local API gateway that receives http (not https) requests, then essentially relays to the actual Vizio SmartCast API endpoint
  2. Build a local API gateway that does same using the python CLI library

Only other option: I’ve got this same Vizio SmartCast API enabled as an Alexa skill, and via voice commands, she does a fine job doing what I need (e.g. toggling power, changing input). Is there a way I can trigger an Alexa skill via a call from WebCore ?


#11

Just off the top of my head, you could use @wcmore’s method here.. I am pretty sure you could get it done with Echo Speaks. But, as we know, ES is KIA.

EDIT : Could you use the Alexa Skill API?


#12

Those are very creative suggestions ! I love the first one, it almost made me laugh out loud. Actually creating a speaker to literally give voice commands to the Alexa, I think ? No doubt, it gets the job done !

On the second suggestion (Alexa Skill API), it appears that “You can use this API to invoke those skills for which you are the developer.”. I don’t think that would be true in this case, since I’d want to use the Vizio SmartCast integration.


#13

I’ve used something similar to you option 1 using a node.js app on a raspberry pi.

Another option would be a Logitech harmony hub. You can setup activities in the logitech app which are visible to webcore. This isn’t as elegant as it uses IR rather than the api and is a bit laggy


#14

Interesting idea !! Would that be similar to using Broadcom RM Pro ? If so, I’ve heard that the harmony hub can be fussy… and boy, Paul Hibbert sure does LOVE the Broadcom RM Pro :slight_smile:


#15

Just looked at the vid. He doesn’t cover how you’d control it from webcore, that would need looking into. But think it seems quite similar.


#16

The question is whether or not Broadcom can accept outside (external) commands.


#17

At the moment, I think I’m going to go the route of building an API gateway to accept POST API commands for the TV (via unauthenticated HTTP), and consequently call the https endpoint for Vizio SmartCast API. It’s more work, but likely will be handy for me, and I’m comfortable with the nodejs/express framework.