Newbie questions on running pistons


#1

Hi everybody, I am experiencing some trouble figuring out if my pistons are unstable or if I am programming them all wrong.

I’ve. got some basic questions:

Using IF / Else:

Setup:

The piston turned on the pump, but I still got a “Oops! Pump already on!”

In my understanding if the first “If” condition is not “met/true” then the “ELSE” statement is run.
If the “IF” statement is “met/True” the “ELSE” statement is NOT run.
How come the pump was turned on and the Sms notification was sent?

Running order:

If a piston contains more than one “IF” statement in what order do they run?

Do the run at the same time or top to bottom or left to right?
Will a wait statement hold all other If statements? If not how do you go about running if’s in a dedicated order?

Example:

At 9:00AM every day

 DO:

         IF Outlet 1 power is less than 100W
                 Then:
                     Wait 1 hours
                     Turn on Outlet 2

          IF sensor 1 temperature is more than 25
                    Then:
                         Turn on Fan

My question is at what time does the system check the temperature? At 9:00AM or at 10:00AM

Will a wait statement hold all other If statements? If not how do you go about running if’s in a dedicated order?
For instance I would like to turn on a Pump then control if the power output of the outlet rises and notify if the power does not rise (Pump Broken).

Thanks i advance… I’m all new to the Webcore interface so bare with me :wink:

Also any link to Documentation / Tutorials beyond the Webcore WIKI would be greatly appreciated.

Nicolai


#2

I have not looked at your entire piston, but the first thing that concerns me is the duplicate IF statements:
Outlet%20power%20HERE%20and%20HERE

And when you throw in the WAIT, things can get really crazy because piston execution generally occurs top to bottom.


#3

Take a look at TCP (Task Cancellation Policy). It may provide some help.


#4

Aha… that made a lot of sense :wink:

And some questions as well…

From testing I have made the following conclusion:

If an “IF” is fired with a “trigger” (temp rises above 10) it will run until it is finished or the “Trigger” is no longer true. (If temp falls below 10 and the “if” is still running it will cancel)

If an “IF” is fired with a “condition” (Temp is above 10) It will run til finished no matter what.

Is this correct?

How would you create the following scenario?

A pump i connected to outlet 1:

If power at output 1 rises above 200w
Then
Turnoff output 1
Wait 30 min.
Turn on Output 1

When the output is turned off the trigger becomes false and the Piston cancels.

Would you set a variable for power usage on Output 1, and have a subroutine turnoff the pump for 30 min.? Would you do this subroutine in the same piston or in a seperate piston using global variables?

Also where do a set the Task Cancellation Policy? Is it global for one piston or can it be set for a specific statement i a piston.


#5

Found the Task cancellation policy under the Show/Hide advanced settings in the IF creation window :wink:

Thanks


#6

Yes.

Sort of…If the “trigger” changes state, then the piston stops where it is and runs again from top to bottom. A condition will execute based on the result of the condition, with this caveat… This is were WAIT statements can get iffy. If the “trigger” changes state during the WAIT, then the piston restarts from top to bottom, no matter if it was in the IF of the “condition.”

You could put this all in one piston. But I would set the TCP to NEVER CANCEL. That way, when the output 1 is turned off, it will complete the 30 minute WAIT and turn Output 1 back on (if that is what your want it to do). However, if the Output 1 is off, and no other action is taken on Output1, then the power will never be above 200w. So the state of the piston will not change and the piston should complete the wait and the Turn on (even with TCP at default).

The TCP can be set for the entire piston or just parts of it.


#7

Beautifully worded, @Pantheon :+1:


#8

@WCmore, Thanks, I learned most of this from you.


#9

Thank you Pantheon, that makes a lot of sense.

I have tried to redesign the piston without waits, using timed events instead.

I still have trouble with the “Watering not detected” task.

In line 49 the Water pump is turned on, it takes about 1 min. for the water to reach the contact sensor.
In line 52 “If Contact sensor changes to Open then set variable to true”

The piston always returns “Watering not detected”, I don’t know if the sensor opening was not detected or if the Boolean Variable is reset at some time before the readout.

At what time does the piston start to detect if the sensor i open and at what time will it no longer detect?

I have set TCP to never on the “If contact sensor changed” because the sensor sometimes open/close 2 times on detection.

Again Thank you Partheon, your help it has been greatly appreciated :wink:

Oh by the way…
The setup is for a Hydroponic green house. The task is to water the plants 2 min. every hour. I need to make the system as bulletproof as possible , the plants don’t have any soil so if watering is missed for more than 6-12 hours they will sustain damage or die.

I have a Z-wave “Fibaro double switch” to turn on the pump and a z-wave Door/window sensor on a float at the far end of the system.
The system also consists of a multisensor ( Temp/LUX/Motion/Humidity) This sensor is not in use right now. (but is sending a lot of data on the z-wave every time temp or Lux changes). Don’t know if the constant stream of temp/lux readings interrupts the on/off commands for the pump relay, or if this should be no problem…

Nicolai


#10

Hmmm… after changing the TCP the Piston got unstable… It turns on the Pump never turning it off again. it alto turned on the pump at 00:30 minutes?? hmmmm. guess I still have some way to go figuring out programming Webcore :wink:

Testing on…
Nicolai


#11

First, there are a number of ways to do this and others may have suggestions, corrections or improvements. Second, a few assumptions about your green house:

  1. No other action is taken on Outlet 1 switch except with this piston.
  2. I presume that if the power of the Outlet 1 switch is anything greater than zero, then the switch (pump) is ON.
  3. I do prefer to use WAIT in this application.
  4. I have not written code using power management before so your needs may be different here.
  5. Your Contact Sensor 1 is accurate and functioning.

I do not understand what you are trying to accomplish with your first two IF statements.

What does “Watering system not ready” mean to you?

What does “Pump already running” mean for your system? If the above assumptions are correct, and your ON/OFF code works properly, then your pump should not run otherwise.
Here is my suggestion :

Every hour
   With Outlet 1 switch (TCP - NEVER CANCEL here)
      Turn on
      Wait 2 minutes
      If Contact Sensor 1's contact is closed
         Then
            Send SMS "Watering not detected"
         Else (Water was detected)
            Turn Off
            Send SMS "Watering was a success"
      END If
   END With
End Every

With this code you will get an SMS notice every hour as to whether or not there was watering. If you do not get an SMS, then you know something more problematic is occuring…power outage, switch failure, etc. You can dress up the code if you like. But this should get things running for you.


#12

Hi again, - Again thanks for helping me out :wink:

The 2 first IF statements is to check that the system is OK.

If the sensor is open either water is running in the system or the float is jammed. (Should not occur when not watering)

If the Pump is running (outlet 1 is on) then it was not shut off at last watering. (Fibaro relay never received shutoff command)

I agree that your suggestion would work fine, but i would like to build some kind of security in to the system that every thing is running as planed…

For instance if the sensor/float is jammed the simple setup would just keep running water forever. I would get a “Watering not detected error”, but running the plant roots underwater for even 6-8 hours would be damaging. (I work long hours away from the greenhouse)

My Z-wave system is not that stable, i don’t know if it is just my system setup or Z-wave in common.
My system runs this piston 24 times a day, every 2-3 days i experience either pump running for ever or not at all. I also experience incorrect/delayed readout in the App on my iphone. (says something is off when infact it is on and vice versa)
System is running with a range extender at the far end of the house and distance to the green house is about 9meters/30foot with 15cm/6inch concrete and 15cm/6inch brick wall in between. I have done rangetests on the fibaro unit and it is able to communicate directly with the Smartthings HUB. (without the range extender)

I’m all new to Z-wave/Smartthings/Webcore, but it seems that the Z-wave protocol is one way communication only. (The controller tells a device to turn on, if the device does not read/comprehend then the device will stay off until toggled the next time.)

If this is indeed true I would like to Build some safety in to my system, for instance an IF statement that checks that the pump did in fact turn off.

This is where my piston is as of now:


I am having trouble with the Outlet power readings as they are very unstable. I’ve figured out using the Full logging to troubleshoot what is failing (nice feature)

The time triggers can be up to 1min off. is this to be expected? (they are not all at the same offset - 00:00 can run at 00:01 and 00:02 can run spot spot on)


#13

First off, yes, the lag time for ST and webcore can be quite variable. They rely heavily on your internet speed/reliability and the cloud. That is one reason that I used WAIT instead of time offsets. Actually, I am not sure if either of them is any better.

That is going to be difficult given what you have told me about how unreliable your system may be already. Sure, a system can be very robust. It just depends on how many safeguards are important and the time involved in programming and maintaining the code. My piston suggestion did not include any of those features. But ultimately your pistons are dependent on the consistency of your whole system.

Z-wave is bi-directional.

Given your description of some of the unreliable attributes of your setup, I would be somewhat skeptical of using OFFSET times. Especially with times that are only a couple of minutes apart. However, I would be interested to see if they work for you as planned.