Make Web Request command and Log to Console not working as expected


#1

1) Give a description of the problem
This is a two-part question.

Part 1: I am working on a piston that should change the profile of my security camera via an HTTP command. If I copy and paste the command from WC and paste it into a browser, things work properly and the camera’s profile changes as expected. But when I execute the piston, nothing happens and the camera’s profile stays the same.

I don’t understand why the command works when issued from a browser but doesn’t work when issued via WC. No errors are displayed in the log.

Part 2: I thought I would log the HTTP response to the console and look for clues in the response but nothing is written to the console. Am I doing something wrong? Is there just no response or is my syntax for logging the response incorrect?

2) What is the expected behaviour?
The HTTP Get command should change the camera’s profile from 0 to 1 at sunset and 1 to 0 at sunrise.

3) What is happening/not happening?
If I copy the command from WebCoRE and paste it into a browser and execute it, the camera’s profile successfully changes. When I run the piston containing the same command, nothing happens.

**4) Post a Green Snapshot of the piston
Here’s the piston. I’ve changed the the User ID and password to gibberish so the entire formatted URL is visible. When I get it working, the piston will run at sunrise and sunset but right now it says everyday at a specific time so I can easily change the time and trigger it for testing purposes.

5) Attach logs after turning logging level to Full
Here are the logs. I’ve redacted the User ID and Password.

298ms ║╔Subscribing to devices…
+349ms ║╚Finished subscribing (60ms)
+407ms ║Setting up scheduled job for Tue, Jan 19 2021 @ 7:18:00 AM MST (in 40477.27s), with 1 more job pending
+420ms ╚Piston successfully started (419ms)
1/18/2021, 7:57:18 PM +42ms
+1ms ╔Received event [Home V3].time = 1611025039105 with a delay of -1063ms
+40ms ║RunTime Analysis CS > 22ms > PS > 5ms > PE > 12ms > CE
+42ms ║Runtime (40427 bytes) successfully initialized in 5ms (v0.3.110.20191009) (41ms)
+43ms ║╔Execution stage started
+55ms ║║[:]
+56ms ║║Executed virtual command log (1ms)
+61ms ║║Calculating (string) DW Starlight profile set to Night at + (string) Mon, Jan 18 2021 @ 7:57:18 PM MST >> (string) DW Starlight profile set to Night at Mon, Jan 18 2021 @ 7:57:18 PM MST
+64ms ║║Calculating (string) DW Starlight profile set to Night at Mon, Jan 18 2021 @ 7:57:18 PM MST + (string) . >> (string) DW Starlight profile set to Night at Mon, Jan 18 2021 @ 7:57:18 PM MST.
+76ms ║║Executed virtual command sendPushNotification (9ms)
+79ms ║╚Execution stage complete. (36ms)
+81ms ║Setting up scheduled job for Tue, Jan 19 2021 @ 7:18:00 AM MST (in 40841.878s), with 1 more job pending
+87ms ╚Event processed successfully (87ms)
1/18/2021, 7:56:59 PM +41ms
+0ms ╔Received event [Home V3].time = 1611025020000 with a delay of -960ms
+35ms ║RunTime Analysis CS > 15ms > PS > 6ms > PE > 15ms > CE
+38ms ║Runtime (40426 bytes) successfully initialized in 6ms (v0.3.110.20191009) (36ms)
+39ms ║╔Execution stage started
+51ms ║║Cancelling statement #2’s schedules…
+58ms ║║Sending internal web request to: userRedacted:[email protected]/cgi-bin/configManager.cgi?action=setConfig&VideoInMode[0].Config[0]=1
+62ms ║║Executed virtual command httpRequest (4ms)
+63ms ║║Requesting a wake up for Mon, Jan 18 2021 @ 7:57:19 PM MST (in 20.0s)
+70ms ║╚Execution stage complete. (31ms)
+72ms ║Setting up scheduled job for Mon, Jan 18 2021 @ 7:57:19 PM MST (in 19.993s), with 2 more jobs pending
+79ms ╚Event processed successfully (79ms)

#2

I currently don’t have an opportunity to look at your piston. I’m not sure about this, but I believe Dahua cameras have the option to change the profile from within. I think it can be changed at particular times. Have you tried logging into the camera?


#3


#4

One problem with web requests through webcore is it is done from outside your network. So when you put the url in your browser, it is done from inside the network but when webcore tries to do it it is outside your network. perhaps try putting the url indoor phone and disconnect it from he network to see if it works from an outside location.


#5

Thanks for the response, @guxdude but it’s my understanding that the request is issued from the ST hub so it’s made locally on the LAN and doesn’t come from the WAN. And I’m successfully using HTTP commands to manage other devices so I don’t think that’s the problem.


#6

Thanks for the response. I am currently logging into the camera and changing profiles manually but want to automate things and take advantage of WebCoRE’s sunrise and sunset presets.


#7

Have you tried to use the urlencoded value of [] ?


#8

You should be fine making local web requests, I believe they run on the hub. I call out to local URLs from webcore.

I’m just wondering about the credentials at the start of the URL, I would expect it to start with the IP. Does the same line work in a browser? What are the credentials for, if they’re for the camera, I would expect them later in the URL?


#9

You seem to have a space in the URL in cgi -bin. Is that really there?


#10

Agree with @orangebucket : cgi -bin should be cgi-bin (without the space).