I’m not sure where to begin with this next idea for something in my piston. I want to set a variable for what light is on in a room. There are two lights on in the room and it sure how to set the variable if no light is on but even more confused how to handle if both lights are on in the room. I think I could figure it out if I wrote out each situation in separate statement, maybe. But is there a way to do this all in one statement?
Set variable with list of devices that are on
define
Device lightsOn
IF
Any of lights x or z are on
save matching devices to {lightsOn}
You can access the ‘save matching devices to’ function by clicking on the cog symbol in the IF.
Ok my next question is how can I display the list of devices that are on in the piston state? Like this?
That looks ok… test and you will see
Also, why butcher your piston screenshot like that??? Makes it really hard to read.
If you use the green snapshot button it gives each device an anonymous name automatically.
The screenshot is because I like to use the webCoRE iOS app and there’s no way to save the green snapshot directly from the app as far as I’m aware. I know it wouldn’t be that hard to open up Safari and save it - it’s just that I really like the iOS app because it’s so much more convenient.
Anyway here’s what the piston state is giving me - nothing, it’s completely blank. This is using the piston shown here…
One thing I’ve noticed is that the variable shows as not being set though - would that be the reason?
2/3/2018, 10:32:48 AM +514ms
+5ms ╔Received event [Tall Pines].test = 1517671968510 with a delay of 4ms
+147ms ║RunTime Analysis CS > 26ms > PS > 89ms > PE > 29ms > CE
+156ms ║Runtime (40086 bytes) successfully initialized in 89ms (v0.2.102.20180116) (149ms)
+161ms ║╔Execution stage started
+182ms ║║Comparison (enum) off is (string) off = true (5ms)
+185ms ║║Comparison (enum) off is (string) off = true (1ms)
+186ms ║║Condition #1 evaluated true (21ms)
+188ms ║║Condition group #null evaluated true (state did not change) (22ms)
+199ms ║║Condition #5 evaluated false (8ms)
+200ms ║║Condition group #2 evaluated false (state did not change) (9ms)
+209ms ║║Condition #9 evaluated false (6ms)
+210ms ║║Condition group #6 evaluated false (state did not change) (8ms)
+224ms ║║Comparison (enum) off is (string) on = false (1ms)
+228ms ║║Comparison (enum) off is (string) on = false (3ms)
+240ms ║║Condition #13 evaluated false (27ms)
+241ms ║║Condition group #10 evaluated false (state did not change) (28ms)
+244ms ║╚Execution stage complete. (86ms)
+250ms ╚Event processed successfully (250ms)
2/3/2018, 10:32:46 AM +31ms
+5ms ╔Received event [Tall Pines].test = 1517671966021 with a delay of 3ms
+126ms ║RunTime Analysis CS > 37ms > PS > 61ms > PE > 33ms > CE
+139ms ║Runtime (40086 bytes) successfully initialized in 61ms (v0.2.102.20180116) (128ms)
+145ms ║╔Execution stage started
+202ms ║║Comparison (enum) off is (string) off = true (6ms)
+205ms ║║Comparison (enum) off is (string) off = true (1ms)
+210ms ║║Condition #1 evaluated true (47ms)
+211ms ║║Condition group #null evaluated true (state did not change) (52ms)
+234ms ║║Condition #5 evaluated false (6ms)
+235ms ║║Condition group #2 evaluated false (state did not change) (8ms)
+245ms ║║Condition #9 evaluated false (5ms)
+246ms ║║Condition group #6 evaluated false (state did not change) (6ms)
+259ms ║║Comparison (enum) off is (string) on = false (2ms)
+263ms ║║Comparison (enum) off is (string) on = false (2ms)
+269ms ║║Condition #13 evaluated false (20ms)
+270ms ║║Condition group #10 evaluated false (state did not change) (22ms)
+279ms ║╚Execution stage complete. (136ms)
+286ms ╚Event processed successfully (288ms)
That’s not the problem.
You are testing the piston with the test button, so the triggers in the rest of the piston (looking for contact CHANGES) will always be false… but that wouldn’t stop the last part of the piston running.
The issue is that the restriction on line 27 directly contradicts the condition in line 44.
The piston will only ever run when those two lights are off, and the condition will only ever run when one of those two bulbs are on.
Hopefully I dont sound too stupid asking this but what do you think I should be doing? The part about piston running only when both lights are off was what I’d intended because if both lights are off it’s supposed to turn the light on when door opens but if either one of the lights is already on then do nothing.
IF
all of lights x and y are off (never subscribe)
save non-matching devices to variable {lightsOn}
AND
contact changes to open
THEN
turn on light
ELSE
set piston state to {LightsOn}
Would it just be easier to do this:
If contact changes to open.
AND
Both lights are off.
Then Turn on lights
well yes… but that doesn’t update this piston state or record which devices are on in a variable, so is not what @GRClark requested.
Sorry, I was going by what he said in the last post. And why do you have to have a variable with what lights are on? If you command to turn two lights on and one is already on, ST is smart enough not to try to turn it on again. I’m from the KISS school of thought. Keep It Simple, Stupid.
The variable was for setting the piston state not part of the actual operation of the piston.
As far as the lights on variable it’s ultimately going to be used for setting the piston state. It seems as though you need to use variables in order to this or something because it’s the only way I’ve had any success in doing that. But please correct me if I’m wrong since variables can still be confusing for me.
You can put expressions into the set piston state value field… but for just listing the active devices, current method is best.
@Robin I’m hoping you’re able to help me out again with another piston, but the same topic - setting a variable with list of devices. In this situation I’m trying to populate the list with any presence sensors that are currently present and then use that information to set piston state… I’m not sir why but it’s always showing “0” devices in the piston state:
Here’s the piston: