Sending JSON for reolink Camera


#1

1) Give a description of the problem
I am trying to send a Post to my Reolink NVR to disable Push notifications

2) What is the expected behaviour?
It should shutdown push notifications on the NVR

3) What is happening/not happening?
I am getting error when the piston runs

4) Post a Green Snapshot of the pistonimage

5) Attach logs after turning logging level to Full
9/17/2024, 12:02:54 AM +299ms
+4ms ╔Received event [Home].wc_async_reply = httpRequest with a delay of 1ms, canQueue: true, calledMyself: false
+36ms ║Invalid ternary operator. Ternary operator’s syntax is (condition ? trueValue:falseValue ). Please check your syntax.
+40ms ║Calculating (string)enable : (integer)0 >> (string)
+42ms ║Invalid ternary operator. Ternary operator’s syntax is (condition ? trueValue:falseValue ). Please check your syntax.
+45ms ║Calculating (string)Push : (string) >> (string)
+47ms ║Invalid ternary operator. Ternary operator’s syntax is (condition ? trueValue:falseValue ). Please check your syntax.
+51ms ║Calculating (string)cmd : (string)SetPushV20 >> (string)
+52ms ║Calculating (string) , (string)param >> (string)param
+54ms ║Invalid ternary operator. Ternary operator’s syntax is (condition ? trueValue:falseValue ). Please check your syntax.
+57ms ║Calculating (string)param : (string) >> (string)
+62ms ║Runtime (7443 bytes) initialized 59 LockT > 1ms > r9T > 30ms > pistonT > 27ms (first state access 24 m:4 5 54) (v0.3.114.20240115_HE)
+85ms ║╔Execution stage started
+94ms ║╚Execution stage complete. (9ms)
+102ms ╚Event processed successfully (98ms)
9/17/2024, 12:02:34 AM +82ms
+17ms ╔Received event [Home].test = 1726545754082 with a delay of 1ms, canQueue: true, calledMyself: false
+37ms ║Invalid ternary operator. Ternary operator’s syntax is (condition ? trueValue:falseValue ). Please check your syntax.
+41ms ║Calculating (string)enable : (integer)0 >> (string)
+43ms ║Invalid ternary operator. Ternary operator’s syntax is (condition ? trueValue:falseValue ). Please check your syntax.
+46ms ║Calculating (string)Push : (string) >> (string)
+48ms ║Invalid ternary operator. Ternary operator’s syntax is (condition ? trueValue:falseValue ). Please check your syntax.
+51ms ║Calculating (string)cmd : (string)SetPushV20 >> (string)
+53ms ║Calculating (string) , (string)param >> (string)param
+54ms ║Invalid ternary operator. Ternary operator’s syntax is (condition ? trueValue:falseValue ). Please check your syntax.
+58ms ║Calculating (string)param : (string) >> (string)
+68ms ║Runtime (7355 bytes) initialized 65 LockT > 1ms > r9T > 45ms > pistonT > 43ms (first state access 11 m:8 18 47) (v0.3.114.20240115_HE)
+70ms ║╔Execution stage started
+78ms ║║Invalid ternary operator. Ternary operator’s syntax is (condition ? trueValue:falseValue ). Please check your syntax.
+81ms ║║Calculating (string)enable : (integer)0 >> (string)
+83ms ║║Invalid ternary operator. Ternary operator’s syntax is (condition ? trueValue:falseValue ). Please check your syntax.
+87ms ║║Calculating (string)Push : (string) >> (string)
+89ms ║║Invalid ternary operator. Ternary operator’s syntax is (condition ? trueValue:falseValue ). Please check your syntax.
+92ms ║║Calculating (string)cmd : (string)SetPushV20 >> (string)
+93ms ║║Calculating (string) , (string)param >> (string)param
+95ms ║║Invalid ternary operator. Ternary operator’s syntax is (condition ? trueValue:falseValue ). Please check your syntax.
+98ms ║║Calculating (string)param : (string) >> (string)
+108ms ║║Invalid ternary operator. Ternary operator’s syntax is (condition ? trueValue:falseValue ). Please check your syntax.
+112ms ║║Calculating (string)enable : (integer)0 >> (string)
+114ms ║║Invalid ternary operator. Ternary operator’s syntax is (condition ? trueValue:falseValue ). Please check your syntax.
+117ms ║║Calculating (string)Push : (string) >> (string)
+119ms ║║Invalid ternary operator. Ternary operator’s syntax is (condition ? trueValue:falseValue ). Please check your syntax.
+123ms ║║Calculating (string)cmd : (string)SetPushV20 >> (string)
+124ms ║║Calculating (string) , (string)param >> (string)param
+125ms ║║Invalid ternary operator. Ternary operator’s syntax is (condition ? trueValue:falseValue ). Please check your syntax.
+129ms ║║Calculating (string)param : (string) >> (string)
+131ms ║║Calculating (string)" + (string) >> (string)"
+133ms ║║Calculating (string)" + (string)" >> (string)""
+137ms ║║Sending asynchttpPost web request to: ns.ruotolos.com/api.cgi?cmd=SetPushV20&user=admin&password=password
+140ms ║║Executed virtual command httpRequest (4ms)
+143ms ║║Requesting wake up at Tue, Sep 17 2024 @ 12:02:58 AM EDT (in 23999ms) for 1 (st:2)
+149ms ║╚Execution stage complete. (80ms)
+199ms ║Setting up scheduled job for Tue, Sep 17 2024 @ 12:02:58 AM EDT (in 23984ms)
+202ms ╚Event processed successfully (185ms)


#2

You may have to escape your JSON sting as I have done here with \ in front of every “{” and “}”.


#3

I tried that but less errors now

9/17/2024, 9:31:02 PM +379ms
+4ms ╔Received event [Home].wc_async_reply = httpRequest with a delay of 1ms, canQueue: true, calledMyself: false
+32ms ║Runtime (6475 bytes) initialized 29 LockT > 1ms > r9T > 4ms > pistonT > 1ms (first state access 20 m:4 5 24) (v0.3.114.20240115_HE)
+59ms ║╔Execution stage started
+68ms ║╚Execution stage complete. (9ms)
+76ms ╚Event processed successfully (73ms)
9/17/2024, 9:30:49 PM +723ms
+4ms ╔Received event [Home].test = 1726623049723 with a delay of 0ms, canQueue: true, calledMyself: false
+119ms ║Runtime (6518 bytes) initialized 116 LockT > 1ms > r9T > 98ms > pistonT > 15ms (first state access 12 m:5 6 110) (v0.3.114.20240115_HE)
+122ms ║╔Execution stage started
+133ms ║║Invalid ternary operator. Ternary operator's syntax is (condition ? trueValue:falseValue ). Please check your syntax.
+136ms ║║Calculating (string)enable : (integer)0 >> (string)
+138ms ║║Invalid ternary operator. Ternary operator's syntax is (condition ? trueValue:falseValue ). Please check your syntax.
+141ms ║║Calculating (string)Push : (string) >> (string)
+143ms ║║Invalid ternary operator. Ternary operator's syntax is (condition ? trueValue:falseValue ). Please check your syntax.
+146ms ║║Calculating (string)cmd : (string)SetPushV20 >> (string)
+148ms ║║Calculating (string) , (string)param >> (string)param
+149ms ║║Invalid ternary operator. Ternary operator's syntax is (condition ? trueValue:falseValue ). Please check your syntax.
+152ms ║║Calculating (string)param : (string) >> (string)
+154ms ║║Calculating (string)" + (string) >> (string)"
+155ms ║║Calculating (string)" + (string)" >> (string)""
+160ms ║║Sending asynchttpPost web request to: 172.16.30.16/api.cgi?cmd=SetPushV20&user=admin&password=password
+163ms ║║Executed virtual command httpRequest (5ms)
+166ms ║║Requesting wake up at Tue, Sep 17 2024 @ 9:31:13 PM EDT (in 23998ms) for 1 (st:2)
+171ms ║╚Execution stage complete. (49ms)
+215ms ║Setting up scheduled job for Tue, Sep 17 2024 @ 9:31:13 PM EDT (in 23985ms)
+218ms ╚Event processed successfully (214ms)
9/17/2024, 9:30:38 PM +575ms
+6ms ╔Starting piston... (v0.3.114.20240115_HE)
+16ms ║╔Subscribing to devices...
+21ms ║║subscriptions: no triggers, promoting conditions
+23ms ║╚Finished subscribing (12ms)
+33ms ║Subscribing to Home.pistonID...(:6a062b43fb1f6087058726f2f9731744:)
+40ms ║Subscribing to Home.oldpistonID...(:accfcd1c50e8bf11d37b18156d657e8c:)
+81ms ╚Piston started (76ms)

#4

I struggled with this initially as well. Not sure if the “[” and “]” around the string is required. Also, it might help if you show us your POST command.

UPDATE : I tried my POST without the above brackets and it did not work.


#5

This is where I find the code. Its in the first post
[How to] Manage Reolink camera recording, siren, spotlight, push notifications with Rule Machine - :triangular_ruler: Rule Machine® / Rules Examples - Hubitat

  {
    "cmd": "SetPushV20",
        "param": {
            "Push": {
                "enable": 0
            }
        }
  }

I do have hubitat and I did run the code as they have it and it works. But I do all of my automations in webcore so I want to figuure this out. :slight_smile: Thank for all the help this far.


#6

Can you show us your POST command? It should look like…


#7

I don’t have Reolink equipment, so I cannot test any of this.


#8

First of all, I just want to thank you for all the help this far. I really appreciate it. Here is a screenshot


#9

Do you need an Authorization header for the reolink camera? I do not know that answer. And the Request body type may need to be CUSTOM.


#10

Take a look at the authentication header generator