Help with First Piston


#1

1) Give a description of the problem
Trying to get my first piston to work. Picked something I thought would be pretty simple. I have a device that displays as three separate switches, ‘Switch 8’, ‘Switch 9’, and ‘Switch 10’. They all display fine in AT.

2) What is the expected behaviour?
Basically, this is a home alarm system. The switches represent two armed states and a disarmed state. I created a virtual switch that I want to show on or off based on the states of the existing devices. One device to show armed or disarmed.
Right now, if the system is armed and disarm is run, the switch associated with disarm will turn on and the switch associated with either armed state will turn off. This currently works. The reverse is true. If the system is in a disarmed state, and one of the two armed states is enabled, their associated switches will change correctly.

3) What is happening/not happening?
Although the existing switches work correctly, the piston monitoring their states and changing the state of the virtual switch doesn’t work. It will generally report no state change found.

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

5) Attach logs after turning logging level to Full
Here are the trace logs from my latest test. In this test, Switch 8 was initially in an off state and Switch 10 was in an on state. Switch 8 was turned on, which caused switch 10 to turn off. The trace log shows that condition #6 evaluated false even though the switch state should have changed from on to off.

I think it has to do with the “Comparison (enum) off changes_to(string) off = false” line, but I’m not sure what that means.

8/20/2019, 6:13:55 PM +585ms
+1ms ╔Received event [Switch 10].switch = off with a delay of 37ms
+10105ms ║RunTime Analysis CS > 14ms > PS > 10081ms > PE > 10ms > CE
+10106ms ║Piston waited at a semaphore for 10017ms
+10108ms ║Runtime (38540 bytes) successfully initialized in 10081ms (v0.3.10c.20190522) (10106ms)
+10109ms ║╔Execution stage started
+10120ms ║║Condition #2 evaluated false (6ms)
+10121ms ║║Condition group #1 evaluated false (state did not change) (8ms)
+10130ms ║║Condition #10 evaluated false (5ms)
+10131ms ║║Condition group #9 evaluated false (state did not change) (6ms)
+10136ms ║║Comparison (enum) off changes_to (string) off = false (1ms)
+10137ms ║║Condition #6 evaluated false (4ms)
+10139ms ║║Condition group #5 evaluated false (state did not change) (6ms)
+10141ms ║╚Execution stage complete. (32ms)
+10142ms ╚Event processed successfully (10142ms)
8/20/2019, 6:13:55 PM +578ms
+0ms ╔Received event [Switch 8].switch = on with a delay of 46ms
+98ms ║RunTime Analysis CS > 16ms > PS > 72ms > PE > 11ms > CE
+101ms ║Runtime (38460 bytes) successfully initialized in 72ms (v0.3.10c.20190522) (100ms)
+102ms ║╔Execution stage started
+114ms ║║Condition #2 evaluated false (5ms)
+115ms ║║Condition group #1 evaluated false (state did not change) (7ms)
+119ms ║║Comparison (enum) on changes_to (string) off = false (0ms)
+122ms ║║Condition #10 evaluated false (4ms)
+124ms ║║Condition group #9 evaluated false (state did not change) (6ms)
+132ms ║║Condition #6 evaluated false (6ms)
+133ms ║║Condition group #5 evaluated false (state did not change) (7ms)
+135ms ║╚Execution stage complete. (34ms)
+136ms ╚Event processed successfully (137ms)


#2

hi there…
Just a quick note:
The piston you shared can’t do that.
Pls share any other related piston to this one.


#3

Agree with @ike2018, I do not see any code for when switch 8 turns on.


#4

Maybe I’m not understanding, but should it matter what process is turning the other switches on or off (Switches 8, 9, and 10)? All this piston is doing is watching the state of those three switches and manipulating the virtual switch, Switch 30, based on the changes to those switches. This piston does not turn on or off any of those switches (8, 9, and 10).

To answer though, those three switches are part of the SmartApp for the alarm system I have. That SmartApp creates three devices rather than one to display the status of the system which is why I’m trying to monitor what they show and manipulate the virtual switch (Switch 30) to display the state I wish to see. I’m not sure how the SmartApp is manipulating those switches.


#5

Yes and no…
YES

  • It’s highly recommended - by me :slight_smile: - that webcore takes over everything. (or almost everything)
    Before truly understanding how webcore and STapps work, it’s important to keep it simple and clean.
    At the beginning I was using multiple sources for automation and what a caos that was:)

  • A single device controlled by multiple pistons and/or apps MIGHT cause tons of problems. (simulated switches are also devices)

once again, if 8 is turned on and 10 is turned off, and this piston can’t do that, your problem is for sure in someplace else…


#6

Okay, thanks for the feedback. I hadn’t expected the ‘how’ of the switch getting turned off mattered. The WebApp seems to be written in node (I think) and I’m not thinking I’ll be rewriting the app just for this.

Edit: Just for my knowledge, does the “Comparison (enum) off changes_to(string) off = false” line mean anything or is that just benign?


#7

Reading the logs is something I’m not good at, next in my list though.
Maybe @Pantheon can take a look at that?


#8

For giggles, create 3 separate pistons for each of those switches then give it a test.


#9

Ike is correct. The only problem you mentioned is:

Just to clarify a bit:
Piston “n8ran” sends no commands to switch 10. There must be some other programming that turned off switch 10, because it was not this piston.


#10

Still not sure I understand how having no commands changing the 8,9,10 switches is affecting anything. All I’m trying to do is watch these three switches and update switch 30 when they change. Does it have something to do with conditions vs triggers? I’m not sure I’m following that completely when I read about pistons, so was thinking that might be part of the problem.

@elbyer, I created three virtual switches, one for each of switch 8 9 and 10 and update their virtuals when they change. That seems to work just fine. This is one of the pistons:

I also wonder if it might be an ordering thing. If I turn on Switch 8, then Switch 10 gets turned off automatically by the SmartApp code. I was thinking that maybe 10 is already set to ‘off’ by the time the piston checks it. Wonder if I should use a condition check rather than the ‘changes to’ trigger.


#11

If Switch 8 turns off Switch 10, then the above code will run and turn on Switch 30.

What is the “SmartApp code”? Is there something setup in SmartThings? If so, you should convert that to webCoRE as well.