Very verbose Piston code


#1

1) Give a description of the problem
My piston working, but it has some redundant blocks which I don’t see in other examples, and I am not sure how to get rid of them. Namely, two:

  • the when true and when false inside an if. They just appear when I add a condition, and I am not sure how to get rid of them.
  • with block for setting variables. I can’t find a way to just set conditions in a then. Action requires with and adds it in the code.

2) What is the expected behavior?
An if without when true and when false, an action without with


#2

When editing a piston, in the top right, setting your options to this:

temp

will give you access to 98% of commands, without cluttering up your code.
(the other 5 checkmarks will likely confuse more than help at this point)


#3

Thanks!

Unchecking The “Show when true/false actions” indeed hid the "when true/state actions :grinning:

But I still struggle with having set the environment variables without the with blocks.
What I want to get is:

What I do have is:
webCoRE%20Dashboard%202019-01-08%2009-12-30


#4

Not sure I’m understanding this part but in the with, use Location (default) as the device so you can set variables.


#5

Sorry, I added some pictures to my reply.


#6

Ah, ok, so my reply still applies, instead of using $device, use Location and you’ll get the same result as your target example above.


#7

Just to embellish a tad… Add a new statement > Add an action > Devices > Location

temp

is the default, meaning that any commands that will work across all devices, will be available.
(I do all my variables in this block)



#8

Yay, it worked :slight_smile:
Thanks!!!


#9

I have your second issue, and can’t seem to get rid of the With Location, do block around the variable setting. How did you get rid of that?

Tas.


#10

Every command needs some kind of “container” to hold it. The “With Location” is the generic container that allows for all built-in code to be accessed.


#11

There are lots of example pistons I see with set statements inside ifs that don’t have the with location do construct around them. That’s the result I am after, but can’t find a way to achieve. The with/do ms superfluous in that context at least?


#12

When you’re in Edit mode, you see this…
image

When you Save the piston, you see this…
image


#13

Thanks. This doesn’t seem to happen immediately for me but it does after some time. Wondering if the code optimisation setting has any part in this? Any way all good, and now code is much easier to read.