Repeat Piston to react on a switch statement


#1

Hello, I already found out that my loop is wrong. :slight_smile:
Right now my only problem is that I do not know exactly how to correct it.
Line 47 - 62:
After switching the Switch13 on in line 42, it going to switch off in another Piston (Piston 2) after 20 min.

  1. My idea was with the Repeat Loop, that it waits here until the Switch 13 switched off.
  2. Then it trigger switch 14 to on.
  3. Switch 14 is also switched off by (Piston 2) after 20 min.
  4. This should leave the loop

Can someone help me with a correct loop?
I thing, the repeat loop is the wrong solution :slight_smile:


#2

You can make this piston WAY simpler once you know some of the mechanics of webCoRE. I’ll post an updated version of your piston in a bit, with some comments that I hope will help you see where you can leverage webCoRE’s features to make your life a bit simpler.


#3

Your IF statements in lines 31 and 45 can be combined. Line 31 checks the if the switch is off, so all you need to do is put your actions for off in the THEN section, and put your actions of on in the ELSE section.

Line 50 doesn’t need a loop. You selected a ‘trigger’ by saying "IF switch changes to off. That means your piston will trigger (execute) every time your switch reports a change in its switch state. However, because this statement was nested inside an “execute once at this time” event, even though the piston would run it would never reach this piece of code.

Your sequential IF statements that check the state of your variables can be combined some, too. Here’s a sample with some of those changes worked in.

One thing I noticed is you only set your variables to FALSE if they are BOTH TRUE. If this is accidental, you should be able to clean it up easily in this piston. If that’s the way you intended it to be, this piston is written with that functionality retained.

Lastly, I avoid waits whenever I can. That 2 hour wait, combined with your “execute this piston daily at 18:00” actually ensures the only thing this piston will do is push a message to you daily at 18:00. Two hours later when the piston wakes up, it will no longer be 18:00 so the rest of the piston inside that loop will not be executed.

I’ve tried to write this the way I think you want the time triggers to work for you. If I’ve missed something, just try explaining what you want this piston to do and we’ll modify it until it’s working for you.


#4

first of all many thanks for the thoughtful help :slight_smile:
you’re right, with your solution, the whole coding is much more compact and also easier to read.
but a question about the last IF in line 71.

when I start the first plant irrigation in the garden in the “every” block (line 40) but the second irrigation is outside this “every” block. ( in line 71). then it will never come in line 47 to a double true right?

could you help me here again? :slight_smile:

One more think :sunglasses:
Do you have any idea how I could make the IF of line 71 more dynamic? as an example without “time is between”.

maybe with a variable that is set after running the irrigation? or do you have a good idea?


#5

Glad to help!

The conditions and actions inside the “do every” blocks are ONLY executed at that time. That’s why I pulled line 71 outside of it and added a time condition to it. If line 71 was inside the “do every x days at 8:00pm” section, this is what would happen:

Dimmer 14 changes to off
Your piston is triggered and starts running
It reaches the “do every x at 8pm”, sees it is not 8pm, and skips every condition/action in that entire block

By putting it outside the block, that section of code is free to run at any time the switch changes position.

I’m not quite sure I follow your double-true question but my suspicion is no based on the above. If you can explain what you’re trying to accomplish with this piston, I’d be happy to offer up other suggestions! I just tried to modify your original piston without changing the functionality baked into it… whether it’s what you really wanted it to do or not. :slight_smile:


#6

OK. I explain what I have in mind.
I have 3 circles for my garden irrigation.
Piston 1:
Whenever a switch is turned on it should be switched off again after 20 minutes.

piston 2:
I would like to receive a notification that irrigation is planned during the night.
then each circle should be switched through each other.
At the end I would like a notification if all circles were executed correctly and how long each circle was.
If a circle was not executed, it should also be mentioned in the notification

I would like to have the piston as dynamic as possible. without fixed string’s.
I often have to adjust the duration and the frequency and would like to change the values only once in the variables and then the piston runs.


#7

Piston one could be pretty easy. Is it just one switch or are there multiple in the piston? For one I would just do something like this:

For piston two, is there a switch or something that could interrupt the irrigation? Does the switch cancel all irrigation, or just the current one and the following circle still runs? Immediately or at the originally scheduled time?

I think that should give me enough information to put something together for you, using variables you can set up easily at the time to define irrigation frequency and duration.


#8

piston1:

I currently have 3 switches to control the three circuits. to your first question, yes there are several switches for the piston.

piston 2:
Currently I have 3 switches, each irrigate a circle.
I also have a simulated switch. if this is pushed, the piston should also be executed. in addition to the automated run.
To create a good / dynamic piston, I can create more simulated switch if necessary. this is no problem.
to your questions:
No, at the moment I have nothing to interrupt the irrigation. So I have to negate the other questions, too. But I would be open to any idea/solution from you :slight_smile:

The important thing is that only one switch can be “on” because the pump does not have enough pressure to supply 2 or more switches/irrigation.
It is important that I can edit all 3 circles, as easy as possible in terms of duration and frequency. something like a variable for each point oder something like that.

Do you know how I can incorporate the weather into the logic?
“if it rained a long time yesterday (f.e. more than 5h)” than it should be skipped an automated interval. "

soooooo many thanks :slight_smile:


#9

first draft for piston 1 :slight_smile:
what do you think about it?


#10

That should work! To clean it up a little and avoid any unintended behavior, you could make them all independent.

IF
switch 15 is on for 20 minutes
THEN turn off
Send notification
End IF

IF switch 14…

I’ll take a shot at the irrigation piston in a bit!


#11

Ok, here’s a first crack at your irrigation piston. Take a look through it and let me know if you have any questions. The variables at the top should make this piston pretty configurable for you.

Rather than cancelling an irrigation cycle based on how long it rained (or will rain), this piston looks at the amount of rain that will fall today, tomorrow, and the next day. You set a threshold (in mm) in the variable section and any automated cycles will be skipped if there is more rain predicted than you’ve set in your variable. Manual irrigation cycles are not affected by rain predictions.

I don’t have simulated switches so I just used ST routines in their place - swap those out to whatever you want to use to begin or cancel an irrigation cycle:


#12

Okay thanks :slight_smile:
what is a possible / good value for the variable “rainskip”?
Why do you have always 10 seconds waits?
where would be a good place to send push notifications?
perfect would be a way to check whether the irrigation was watered/finished, if so, then a notification with which circle, how long and when the next is planned.

here my piston at the moment:


#13

just a little question to this piston.
this actually works, but sometimes the color is not set to every device.
I wanted to create a piston that checks the currently set light of every HUE lamps. if the light is different than the MASTER light (it is saved in the variable “globalHUE and globalSaturation”, then it should be changed to the values in the global variables
but something is still not quite right with the piston


#14

My irrigation doesn’t run if there is more than 1/4", so that’d be right around 6mm.

To give one zone time to turn off and depressurize before the next one turns on. Otherwise you’ll be running two zones of load on your pump briefly (at least the way my system is built it would… you can remove them if you’d prefer).

Push notifications go to every device with the ST app installed. You can do it that way, or send an SMS to a specific device - whichever is better for you.

That can be added, just let me know if push message or SMS is preferred and I’ll try to put something together later tonight.


#15

please SMS :slight_smile:


#16

This should do it. Let me know if you see anything acting out of sorts when it runs (make sure full logging is turned on to help debug) and we’ll get it sorted out.

If you had any more zones, I’d re-write this all as a loop. This way should be easier for you to follow through it, though.


#17

Thank you so much
is the rainskip value correct?
i added the piston 1 in this piston at the end.

it looks perfect. thanks for your time and support

i will try it tomorrow :slight_smile:


#18

Rainskip value looks good, you should be ready to go!

Are your times in piston 1 longer than the durations in this piston? If the other commands shut zones off early it will screw up your messages, they weren’t written to take other commands shutting them down early.


#19

i have deleted piston 1.
this one is much better :slight_smile:


#20

next/last point :):grinning:
do you know how to fix the problem with the logic from the master piston?