Invalid ternary operator?


#1

1) Give a description of the problem
Not sure if this is an issue. piston ran, leaving me to think that its ok but I did notice this in the medium set logs. Is this an issue and/or what does this mean?

2) What is the expected behaviour?
for there to be no errors :slight_smile:

3) What is happening/not happening?
getting an error, not sure if its bad since the piston ran anyway

**4) Post a Green Snapshot of the piston!

5) Attach logs after turning logging level to Full
It was set to medium but still lists the error

10/17/2019, 8:07:22 AM +9ms
+0ms ╔Received event [Home Master].routineExecuted = cc531390-996b-4bb1-8091-cae429fbe804 with a delay of 102ms
+105ms ║Runtime (43686 bytes) successfully initialized in 56ms (v0.3.110.20191009) (104ms)
+106ms ║╔Execution stage started
+148ms ║║Invalid ternary operator. Ternary operator’s syntax is ( condition ? trueValue : falseValue ). Please check your syntax and try again.
+156ms ║║Executed virtual command wait (1ms)
+158ms ║║Waiting for 4000ms
+4187ms ║║Executed virtual command setAlarmSystemStatus (26ms)
+4248ms ║║Executed virtual command setLocationMode (58ms)
+4251ms ║║Executed virtual command wait (1ms)
+4252ms ║║Waiting for 600ms
+6240ms ║║Executed virtual command resumePiston (1385ms)
+6254ms ║║Invalid ternary operator. Ternary operator’s syntax is ( condition ? trueValue : falseValue ). Please check your syntax and try again.
+6260ms ║╚Execution stage complete. (6154ms)
+6262ms ╚Event processed successfully (6261ms)


#2

This is in reference to your line 18.
(where the condition is everything up to and including the “1”)


Side Note:
I would also leave the variable up top to say (no value set), and set that variable somewhere after line 27. Otherwise, the “true/false count” will always reference old data…


#3

For the variable to say no value set I am assuming you are talking about line 17? If so that is currently the case as shown below, or is that wrong?

Then line 18 is correct as is or will this need adjustment? I have another piston that is very similar but didnt fire this morning which made me look into this.


#4

Line 18 in the piston above starts with “boolean OpenDevices…”
That is the line I would change to (no value set)

Then somewhere between line 28 & 30, I would add a “Set variable {OpenDevices}” command, and use an expression something like this:

(gt((count(DevicesToCheckThatFailedForStay)), 0) ? true : false)


#5

ok, line 18 changed.

Need some help with how to plant that expression code. All of my variables I have written through “if’s” but haven’t written a expression like you mentioned.


#6

Right below the 600ms wait, click add a statement… Then the drop down choose Set variable. The rest is easy copy paste (after changing the ‘Value’ to an Expression)

temp


#7

Gotya, I was confused since I wasn’t getting to that window right away since i was adding it as a new statement and not one already under the location, but I seem to have figured it out.

this is what I ended up with


#8

The first 31 lines look good!
(I haven’t looked at the rest, LOL)


By the way, the “gt” stands for “greater than”, so the code actually says:
greater than 0 = true, else false


#9

LOL well that seems to be the meat and potatoes of if really!

You also answered my next clarifying question! Its as if you can read my screen!

I need to buy you a beer for all the help you have given me!


#10

Updated with your explanation of 0 = true, else false.

So if there are no devices reported = 0, it would be true and house will arm

Alternatively if any devices = 1+, then it will be false and house will not arm

Also made some of my own labeling more logical.

Seriously, where can I donate some $ for all the help you have given me on here?


#11

It looks good! :+1:


#12

Follow up question here that might have nothing to do with the piston. Tested this last night and even though one of the contact sensors was closed, and showing as such in the ST app, it took a bit to reflect that update in the piston to then give me a true value. At first glance this would seem to be an issue on the ST end or even device end, but is there anyway in the piston to refresh the data or similar action that would give me a more immediate real life reading for evaluation?


#13

If you are referring to your piston (0w4xi) above…

That piston only fires when “Routine executes Puppers Home Alone”

It does not fire when contact sensors change. You can see the lightning bolt on line 23 which denotes which action executes the piston.


#14

Right, and it fires correctly off that routine. The issue seems that that initial “if” which looks at the contact sensors, sometimes reads outdated data. In other words when the piston fires and it looks at those sensors it might read them as open when they are in fact just closed. Not sure where WC gets its data from in that sense. Does it read off of the device in the ST app or does it look directly at the device itself? And the refresh/update rate from device/ST to WC might be the issue here I suspect?

edit: the very simple example to this is that I was testing this and was physically looking at the contact sensors that were closed, and showing as closed in ST but yet sometimes coming up as open in WC.


#15

What is your indication that they are coming up open in WC? Just to be sure this is what you intended, your system will only show good to go if one or more contact sensors are open. (you have if # devices that are open>0 then GoodToGo=true). If everything is closed, then you are setting to false and giving the error message.


#16

There may be a very short delay from the time the status is sent before it is “stored” and available to be referenced.

In your case, if webCoRE properly detects the status a moment late, I would try adding a 500ms WAIT between line 24 & 25. (right before the indented IF)


Also keep in mind that many door sensors may quickly go close/open/close in a split second while closing, as the vibrations/distance changes etc. You can increase that WAIT a couple of seconds for better reliability…


Edit

If webCoRE is still seeing the status incorrectly after 5 seconds of the event, then ignore this post, LOL

A quick way to see exactly what webCoRE sees is to use an Expression:
[Exact Name of Device : contact]

such as:
temp


#17

The intent is to notify if there are any contact sensors open prior to changing the mode and arming the house. I have found that as is the piston is working correctly in that aspect but I might need to test it again because what you are saying does make sense. Its gone back and forth and been redone a few times now so I could have screwed it up somewhere.

This is exactly what I ended up doing over the weekend and seems to have fixed it. Also I walk a little slower out the door to add another few ms :slight_smile:


#18

Excellent! Thanks for reporting back!


#19

I am going to mark your initial reply as the solution since that was it to the origin of this thread. That being said you have provided a lot of solutions here! :slight_smile:


#20

LOL, sometimes it’s hard to pick just one…