CoRE - Get peer assistance here with setting up Pistons

Yes, $random is a decimal between 0 and 1 inclusive.

Go to the dashboard, select any piston and then scroll down to find all the available system variables, they start with $ and are read-only.

There is a changes (changes in general) and a changes to which is specific to a new required stateā€¦

Iā€™m pretty new to CoRE myself. For some answers you can look at my walk thru for setting up your first piston.

For some of the motion sensor stuff you need to also think about the hardware you have. Most (if not all) motion sensors will have a built in ā€œblind timeā€ where they donā€™t change their status (either motion or no motion) regardless of what the actual sensor shows. So you need to determine what your built in time is on that (and some devices allow you to change it).

But you can within CoRE also use delay times so coupled with the built in delay you should be able to achieve what you want.

Also do check out the wiki because it does explain the basics. You may want to (I typically like doing this because it really helps me) to write down your piston in logic terms (IF, THEN, WHEN, etc.) on paper just so you know the flow of the logic youā€™re trying to accomplish. That should help with realizing when one condition may interfere with another.

This is my kitchen lights piston. If I turn the lights on myself, they stay on until I turn them off. The time is any is just a placeholder, I was initially doing it at dusk, but am now doing it at any time of the day.

1 Like

So is your autoKitchenLights variable what you use to signal that this piston has been run and active? And thus then avoids the piston being re-run. But how do you change that variable to false to sort of restart the process (for the next day or later on that day or whatever)?

I ask because this may be what I could use in my kidā€™s room light on thing, maybe setting a variable to true when the lights go on and then set back to false at sunrise or something.

It gets reset in the but if. Works self-sufficiently, no reset required

So one of those two IFā€™s will occur at some point (the IF and the BUT IF) when run or otherwise the piston doesnā€™t run at all and thus your variable never gets to ā€œtrueā€. But once the piston gets called with the first IF, it will eventually go to the BUT IF state and thus varible goes back to false.

This is really cool, hard for me to grasp, but REALLY cool.

Running into a wall here: Help with smartthings motion sensor trigger - #3 by Ac7ss

I cannot seem to be able to get a duration qualifier on a second level logic?

ā€¦[quote=ā€œAc7ss, post:3, topic:56600ā€]

If KitchenLight is off { 
If MotionSensor is active { 
with KitchenLight {   
turn on  
}  
If MotionSensor is inactive for 2 minutes{   
with KitchenLight {
turn off
}  
} 
}
}

[/quote]

This is what I have now and itā€™s not working. I tried latching too and it at least will turn off the lights after the wait time but I still have the problem with if the lights are already on and I walk by the sensor it then turns them off after wait time. I think I am missing the variable thst you have, but I donā€™t know how to setup a variable like that.

Thatā€™s why the top level is checking the switch. I am starting to think that we need to use a virtual switch set by the wall switch:

If WallSwitch changes to ON {
with VirtualWallSwitch { turn on }
with KitchenLight {turn on}
} else if WallSwitch changes to OFF {
with Virtual WallSwitch { turn off }
with KitchenLight {turn off}
}

And then run yours:

If KitchenMotion is INACTIVE for 2 minutes and VirtualWallSwitch is OFF then {
with KitchenLight {turn off}
} else if KitchenMotion is active and KitchenLight is OFF {
with KitchenLight {turn on}
}

This is something simple but I canā€™t quite seem to manage it. I have a vibration sensor on my dryer which registers OPEN for vibration and CLOSED for no vibration. I am trying to make a piston to tell me when the clothes dryer is finished using this logic:

If sensor changes to open and then stays closed for 5 minutes -> itā€™s finished.

There are a couple of quick open/closed cycles when laundry is being loaded, door is open/shut. Then there is continuous ā€œopenā€ (vibration) until the dryer is finished. I figured that once the vibration register stays ā€˜closedā€™ for five minutes the dryer is finished.

Any help appreciated.

I have tried that route lots of times, with no luck. Please let me know If you manage to make it work, thanks.

I cant seem to find a option for how many times a trigger for a open / close sensor should fire a day.
I have 1 open/close sensor Id like to fire once between 0800 and 1200 in morning.
And one that fires twice.
Is this possible? Or isnt that option added?
I would appreciate it If you guys can give me a howto If possible.

The only way to make s contact sense report open/closed is to actually physically open and close it.
You can not program it to fire.

Someone else was having trouble with the having a timed condition like that. I think the best way to solve it is to use a wait with a cancel on piston change

If Dryer contact changes to open
Then (using whatever devices) wait 5 minutes (TCP: Cancel on Piston State Change)

Does that make sense?

That should accomplish what youā€™re wantingā€¦ I think the problem may be that the ā€œclosed for more thanā€ is a condition not a trigger, so the Piston doesnā€™t know to go back and re-evaluate it once it evaluates on the contact changeā€¦ Though, I may be wrong about that.

1 Like

You could use a variableā€¦

Set two variablesā€¦

Piston #1 fires at midnight and sets the global variable {@Trigger1} to 0
Piston #2 checks {@Trigger1} as a conditon and if itā€™s less than 1 (or two) it fires and uses location to set variable {@Trigger1} to {@Trigger1} + 1

You could use Piston #1 to reset as many variables as you like and have the individual pistons do the rest.

I think thatā€™s what youā€™re wanting, and it works, in my head at least. It may be overcomplicating things, though.

Can you try and explain a bit what you need? Use door, window, plain English words :slight_smile: You canā€™t have a sensor ā€œfireā€ unless you physically open the door/window itā€™s attached toā€¦

1 Like

Hi, can someone help me convert these rules from Rule Machine to the CoRE pistons?

This is what I had in Rule Machine:

Rule one: lights on at sunset
Condition - time between sunset and 10pm
Rule - time between sunset and 10pm
Actions for true: dim corridor lights: 10%

Rule two: capture/restore lights
Condition - private Boolean: this rule: false
Rule - private Boolean: this rule: false
Action for true - Capture: corridor lights, Set private Boolean: rule three: false
Actions for false - restore captured bulbs, set private Boolean: rule three: true, turn off the virtual override switch

Rule three: arrival lights
Conditions - private Boolean: this rule: false
Rule - private Boolean: this rule: false
Actions for true - dim corridor lights: 99%, set private Boolean: rule two: true - delay 10 minutes
Actions for false - leave blank

Rule four: trigger - someone arrives
Trigger actions - presence sensor arrives (any)
Actions - set private Boolean: rule two: false
Action - Turn on Virtual Override Switch
Restrictions - only between two times: sunset and sunrise
Switch to disable rule: Virtual Override Switch

Sorry for my bad explaining.
What I meant is:

If i open / close a door, it should trigger once that day.
So if it gets opened or closed more times during the day, nothing happens.

Reason for this is, when the door is opened a light should flash, but it should only flash once a day.
Or it will be a crazy disco feeling in here.
But I cant seem to find a option for this.

I accomplished something similar to this by setting a boolean variable that I set to true once the event has happened, after that I have a timer (you can set this however long you want) to reset that variable back to false say.

Now on your piston, add the conditions to trigger only when the variable is false.

Thereā€™s probably a more graceful way of approaching this but this one worked for me.