Jump to content
Automate Life

Recommended Posts

I have been asked to create a webcore tutorial. One of the most often asked questions has been what is a variable and how do I create one. You can think of a variable as a container. There are several kinds of containers as there are variables. For example there are piston variables that only work inside the piston itself and there are global variables which can be used by any of your pistons. Global variables are what I will explain first as they are the most useful. A global variable has a @ symbol in front of it so you can tell it apart from other types of variables. They can hold the names of your devices, a time, date, ect. I use them most often to hold the names of devices. While you are editing a piston look to the right of your screen and you should see a link that will allow you to create a global variable. It looks like this

1077187752_GlobalCreate.PNG.bf9d49341044561773f77717c49dca8a.PNG

Click on it and it will open a box that looks like the picture below.

818683466_GlobalType.PNG.9200db174b8b113cfd8e7898f7f095b1.PNG

Select Device in the drop down box after clicking the down arrow, then where the @ symbol is give it a name. The name should match what type of devices you are putting in it. For example i create one and put all the sensors that are on all my outside doors in my SHM piston..

536764110_GlobalDeviceSelect.thumb.PNG.36d80fad4c2583dd53e779b923310200.PNG

As you can see in the picture above i clicked on the down arrow in the value field and selected physical devices, then clicked on the down arrow in the nothing selected field and selected the 2 sensors that are on my doors leading to the outside.

644444774_GlobalDeviceMake.PNG.e57a8d4ef5caf88c0104473bf5d12490.PNG

Finally click on the blue Add button and you have just created your first global variable that can be used in any piston you import or create.

Next in this series I will explain piston variables, how to create them and how to use them in pistons.

If anyone has any questions please ask them here.

Share this post


Link to post
Share on other sites

This post will explain how to create piston variables and show you their basic use.

A piston variable can only be used in the piston it is created in. None of your other pistons can use or change it unlike a global variable explained in the previous post. To be able to create a piston variable first either import a piston or create a new one. Once you do that you will see some options that you can turn on and off by clicking on them in the upper left hand side of your screen. They look like what you see below.

1701372926_ShowVariables.PNG.ab8cafa2463866e9556ff56139043516.PNG

The ones in blue are turned on. If the first one on the left is not blue click on it and it will turn on allowing you to see the piston variables and create them. Once you have that on you can click on a link in the blank piston that says add a new variable. Its light gray so it's hard to see. Its in between the word define and end define;

8116535_CreateVariable.PNG.1fb105dbb009106b8b57669c41c2bf70.PNG

Once you click on that you should see a box pop up that looks like the picture below.

2058713130_TypesofvariablesPNG.PNG.ae1525a13342a807ada93b4f0b3c6d8d.PNG

Where you see the word Dynamic is called the variable type. As you can see there are many different type of variables you can create and use in the piston. Let's talk about one of the more useful ones. Look in the list and you should see one called Boolean (true/false) it's one i used in my washing machine piston. click on that option then look over to the right of that field and you will see a blink space that will be the name of the variable that we are creating. Give it a name, for example in my washing machine piston i called mine WashingStarted because it is used to let the piston know when the washing machine was being used.

774114579_VariableValue.PNG.7cdbd5c0f80caad07e37a81341b919e2.PNG

Once you have done that there is the Initial Value fields. I very seldom ever fill these in because when this piston runs each time the variable you are creating will always be reset to this value. There are times that this is desirable but not often so leave these blank here. Once you click on the Add field you have just created your first piston variable. As show below.

457186937_VariableCreationDone.PNG.82da282f9eb6e1c18171a8d4ecdbd8c4.PNG

Now that you have created it what can you do with it you may be asking. If you look at my washing machine piston you can see that i use it to tell when the washing machine is being used.

2136283119_WashingStartedVariable.PNG.5c0051d4dc732e9f58670da0615c0bb7.PNG

So if the Smart plug that the washer is plugged into rises above 50W and the piston variable is False then it will set the variable to true, meaning that the washer is in use.

In the other part of the piston i use the conduction of that variable to allow the piston to continue to wait for the power level to drop below 5w meaning the washer is done. If I didn't use the variable that part of the piston would try to run even when the washing machine wasn't in use as the power level would always be below 5w when not in use.

1244556558_WashingFinished.PNG.4b18baf249e23e6184eecfe57e267fa8.PNG

Then after it alerts us when it's finished i change the variable back to false so it doesn't keep trying to alert us every 5 minutes.

If anyone has any questions about this please ask here.

If anyone has suggestions about some part of webcore they would like me to explain next I'm open to suggestions. Otherwise I will talk about how to create IF, Then statements and what a trigger and conduction is and how to get them to work correctly in a piston.

 

Edited by Larry Underwood
  • Thanks 1

Share this post


Link to post
Share on other sites

Ok, let's talk about the meat and potatoes of webcore automation's. That is the If/Then statements.

1968330662_createanewstatement.PNG.de4391329096065779bd01d70b745f9e.PNG

There are 2 parts to a If/Then statement. Lets start with the if statement. if you click on the + add a new statement link in between the execute and end execute; as you can see in the picture above, you will get a box like the one in the picture below.

104024879_ifoption.PNG.e45c6edf32360ea0fe1f9c20e6ef88b8.PNG

Click on the blue Add and if button and you will see another box like the one below

conduction.PNG.8abe283249337f22ae0c306cde7690d6.PNG

Click on the blue Add a conduction button and you will see another box like the one below

1332848701_conductionsetup.PNG.a0d2b6061fc2d09ad23262692ddaf8f3.PNG

Let's say we want to turn on a light when we enter a room. First we will select the Nothing selected drop down box to the right of the Physical Devices field.

1515158145_anewtrigger.PNG.9b0abf63efe1ee29469c4bbea910b164.PNG

As you can see in the picture above I have selected the Laundry Room Motion Sensor, then select that i wanted to detect motion to the right of that then under What kind of comparison field I selected a trigger for it to look for. Each statement should have a trigger statement, otherwise it will not always run when you want it to.

371037961_triggersVSconductions.thumb.PNG.98d14c675010a70975005bc89ada27f1.PNG

As you can see in the picture above there are Conduction's and Trigger's. I selected a trigger because i want it to execute when it sees motion. If i wanted to add another requirement, let's say i only want it to turn the light on at night I would add another statement requirement but this time i would select the IS conduction. You only want 1 trigger for each statement. Look at the picture below.

1699544406_Iftriggerandconduction.PNG.465407b4bb960fa3371eb1de5df2a164.PNG

As you can see I have 2 conduction's and one trigger. You can tell which ones are triggers as they will have a orange lighting bolt icon to the left of the statement and the conduction's will not. So here It's saying if one of my family members comes home check and see if the time is between sunset and sunrise , if it is then check and see if the outside light switch is off, if it is then continue to the THEN part of the statement and preform that function, in this case turn on the outside lights. If either of the conduction's are false it will not preform the THEN part of the statement.

There are a lot of different ways this can be used. It's pretty much only limited my the devices you have to control and your imagination. Play around with creating a new piston and see what can be done the best teacher is experience. If you have any questions come back here and ask. I will be glad to help.

Unless anyone has a different suggestion, next time I will talk about restrictions, what they are and how you can use them in a piston.

Edited by Larry Underwood
  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...