Invalid ternary operator. HTTP PUT


#1

1) Give a description of the problem
This is my first piston, Ive looked a couple of threads but nothing I’ve tried helped. I’ve messed around with some {} and back slashes, but no dice, i keep getting the same error

2) What is the expected behaviour?
It should send the command successfully

3) What is happening/not happening?
Nothing is happening, I just receive the “Invalid ternary operator.” error. I KNOW it’ll be a simple fix, i just have no idea.

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

5) Attach logs after turning logging level to Full
|+7ms|╔Received event [Home].test = 1604662930550 with a delay of 1ms, canQueue: true, calledMyself: false|
|—|---|
|+18ms|║RunTime initialize > 18 LockT > 2ms > rtDT > 1ms > pistonT > 0ms (first state access 15 9 9)|
|+20ms|║Runtime (5007 bytes) successfully initialized in 1ms (v0.3.110.20201015_HE)|
|+21ms|║╔Execution stage started|
|+24ms|║║Cancelling statement #1’s schedules…|
|+32ms|║║Invalid ternary operator. Ternary operator’s syntax is (condition ? trueValue:falseValue ). Please check your syntax.|
|+35ms|║║Calculating (string)amOn : (boolean)true >> (string)|
|+36ms|║║Calculating (string) , (string)tempTarget >> (string)tempTarget|
|+38ms|║║Invalid ternary operator. Ternary operator’s syntax is (condition ? trueValue:falseValue ). Please check your syntax.|
|+40ms|║║Calculating (string)tempTarget : (integer)22 >> (string)|
|+42ms|║║Invalid ternary operator. Ternary operator’s syntax is (condition ? trueValue:falseValue ). Please check your syntax.|
|+45ms|║║Calculating (string)DA : (string) >> (string)|
|+49ms|║║Sending asynchttpPut web request to: www.anonwebcore.com/
|+51ms|║║Executed virtual command httpRequest (3ms)|
|+53ms|║║Requesting a wake up for Fri, Nov 6 2020 @ 10:42:34 PM AEDT (in 24s)|
|+59ms|║╚Execution stage complete. (37ms)|
|+92ms|║Setting up scheduled job for Fri, Nov 6 2020 @ 10:42:34 PM AEDT (in 24s)|
|+96ms|╚Event processed successfully (95ms)|


#2

You are on the right track of trying to escape the brackets with a backslash. This actually works best if it is placed in the value field rather than an expression box.

\{ "DA" : \{"amOn" : true,"tempTarget" : 22 \} \}

should work when placed in the value field.


#4

I don’t think he’s doing ternary operation, it’s the formatting of the expression that is confusing webcore.


#5

Thanks so much guys! I didn’t realise there was a difference between choosing expression and value That with adding the backslashes sorted it out! instant success! Now that that’s solved, onto bigger and better things, and one step closer to the reliance on IFTTT.


#6

Awesome, glad it worked. (Could have used the expression box but you would have had to wrap the entire string in quotes. My brain has just always associated Value with text)