CoRE - Get peer assistance here with setting up Pistons

I also struggled with how to kick variables off, and had no idea about the @ for globals.

Yes the @ is required, you need to explicitly put it there.

Thanks, I had pretty much figured that was probably true, but beyond that it still has all the other problems I described.

NThere is no need to initialize any variable. Simply use Set variable in an action, prefix it with @ to make it global (all pistons can read/write it) or don’t use the @ sign to make it local (only that piston knows of its existence). Date&time is stored as a long integer, namely unix timestamps. You can Set variable x = $now + 3 months if you want…

@ady624

How would I do this with a variable?

I have a contact sensor on a door. When I close the door, I want it to trigger a piston that will send a text message every 12 hours, and stop when the door is opened. The catch is, I want the piston to send the message 60 days after the door is closed.

Would this work?

 IF
 Contact sensor changes to closed
        Set variable $60_days to today's date
 THEN IF
  Date is equal to variable $60_days + 60
        Happens at every 12 hours
        Send text message: "open the door"

I had this similar setup in RM using multiple rules. This piston turns the lights on fine but doesn’t turn them off and I’m sure it has to do with the wait location… Or maybe the cancel on state change

I want to wait until the garage door is closed and then wait 3 min and turn the lights off.

Thoughts?

I was playing around with the idea of having multiple “Good Morning” messages and somehow having CoRE randomly select one. I was trying it with the Switch and Case options, but I’m not sure how to randomly select a case. If I put in a variable, it will only select the one case each time. In this example, my variable Talking = Talk 1.

I’m not sure if this is the correct way to approach what I’m trying to accomplish.

Most problems with turning lights off seem tp be generated by faulty DTH/devices that do not update in ST. Try disabling command optimizations in the piston options and report back please.

Try setting a variable like this:

Set number variable x = $random * 3

Then use the switch for variable x, but use cases 0, 1, and 2. Zero based.

Guess what the Follow Up piston is used for ;)))

At this point, you would need two pistons:

First, a simple piston called “Chief Door Spy”

IF Door is closed
   Using location...(cancel on piston state change)
      Follow up with piston "Warn me, Warn me" in 60 days (may need to use 1440 hours)
ELSE
   Using location...
      Execute piston "Warn me, Warn me"

The ELSE is there to stop the Follow Up piston.

Secondly, a follow up piston called “Warn me, Warn me”

IF
   Door is closed
THEN
   Using location... (cancel on piston state change)
      Send notification: "change the filter already!!!"
      Follow up with piston "Warn me, Warn me" in 12 hours

The trick: follow up pistons do NOT subscribe to anything, so the first simple piston has to get it both started and stopped. Once started, it will perpetually run every 12 hours due to the follow up, as long as the door is closed. If the door opens, the simple piston runs the follow up which would then evaluate to false, cancelling the current wait but not scheduling a new one, thus breaking the chain… Get it? :wink:

Glad I invented the Follow Up piston, you’re welcome looool (too much alcohol at the moment - no power after horrible thunderstorm… lol)

3 Likes

Thanks!!! It’s been a long couple of days here and my brain just wasn’t up to that much thinking… lol

1 Like

I think I have it, but I’m not understanding how. I just did my test and case 2 was selected each minute during the test. However, my variable keeps displaying 0. With $random having a value between 0.00 and 1.00 I can see how my variable will almost always equal 0 as the probability of getting 0.00 through 0.99 are higher than getting 1.00. Thus 0 * whatever will be 0.

Ok, the problem is with casting - since the variable is number, the setVariables keeps trying to make that variable a number as it proceeds through the algebra. I’ve modified CoRE now to consider “number” as “decimal” during the math calculation, then convert it to “number” at the end. It now results in random numbers: 0, 1, and 2. Tested.

v0.2.13c.20160814 - Beta M2 - Minor fix regarding setting a number variable - allowing decimals during the calculus

Thanks @ady624 for the quick update. After updating, I ran it 3 times and case 2 then case 1 then case 2 was selected. Each time, the variable also updated.

1 Like

Hi folks, I’m trying to migrate my rules from Rule Machine but need some help!

In Rule Machine, I have rules that trigger when all presence devices have left. I don’t want the rule to trigger when just one presence device leaves but one remains; only when both are gone.

In CoRE, I configure my Trigger to be when both presence sensors --> Change To --> Not Present. The problem is, when I select both sensors in the list, the “All” option goes away, and the Trigger Overview just defaults to “Any of” the presence sensors.

Is there any way to force it to “All” instead of “Any”? Or is there another way I should be writing my trigger?

If you click Any Of it should present you with a choice of either Any Of or All?

I have similar thing written

◦ Each of A or B presence is not present

Mine is written as a condition not a trigger, maybe that’s the difference?

Triggers are events, you cannot have all doors close at the same exact time, which explains the lack of All. Try using a condition (is closed) instead.

This was a very helpful tip. I have my Intermatic PE653 pool controller (partially) run by CoRE pistons and its switches, in particular, my pool light, at the DTH level do not update reliably. This was causing CoRE to not always turn it off consistently. I disabled command optimization and haven’t seen the failure in limited testing.

As it happens, I used Smart Lighting to turn it on, from which I’ve not observed a failure. My conclusion is that SL does not attempt to optimize, i.e. skip redundant, commands but CoRE does, in default mode.

Does that make sense?

@ady624 Do you recommend turning off command optimization liberally in cases where the DTH synchronization is problematic?

1 Like

Got another Piston I trying to get working with little success. This is what I have…

If: Pool Aux Multisensor acceleration did not change in the last 360 minutes.
Then: Send Push notification ’ Pool Aux Pump did not turn on within the last six hours.’

Basically I am using a smartthings multipurpose sensor to verify my pump actually ran. It’s stuck right to the pump and the accelerometer shows up as being active when its running. I decreased the time to 5 minutes to test it out, and it worked when I first created the piston. However, it never worked again after that, no matter what I changed the minutes too.

Disable away. Only benefit of the optimizations is that it seems that ST is faster to check the state of a switch than execute a command, thus saving time. But there’s no time to save where it doesn’t need saving :slight_smile:

1 Like