CoRE - Get peer assistance here with setting up Pistons

I’m going nuts trying to figure out what I’m doing wrong. All I’m trying to do is when the motion sensor gets tripped it will capture the attributes of a light, then turn it up to 100%, then reload the attributes and set the light up before the motion trip after a set time. In this case for my example I set it up to only five seconds. It’s just not working. The light does turn up to 100%, but after 5 Seconds it does not go back to the state it was. Perhaps I’m reading the attributes into a variable the incorrect way? I’m new to CoRE, so it doesn’t help my situation. I’ve looked up many examples and try to figure this out. Here’s a screenshot of what I’ve done. Any help would be much appreciated, and I’m sure I’m overlooking something really stupid.

you are saving the attributes to one variable and trying to load from an empty one. Capitalize your A on the save state and you should be good

Never mind that is a different variable. Your push notification is different however.

It just messages me a text:
Variable = 40
That’s it.

Before starting piston, set CoRE for expert mode: Settings->ExpertFeatures turn ON Expert Mode

This is a basic piston that uses the expert features. This makes the piston super simple. You will do all your work within the ‘IF’ statement.

First, select your motion sensors. On that same card in the UI, scroll down and you will find ‘When True’ and ‘When False’. It is in here where you will place your actions.

‘When True’, save the level attribute into a local variable called level. Then, set the light to 100%.
‘When False’, Wait, then Set Level (variable) and use the ‘level’ variable.

Here is another example:

Well. after following your example, this seems to have worked out. Light went to 100%, then after the motion detector quieted down (about 1min). I seem to think that my SAVES and LOADS were incorrect, so when I used the proper ones, it set the light back to the previous level. Odd thing though, my light level seems to always read 40%, even though I’ve brought it down to 10% before I tripped the sensor. When it does it’s thing, instead of going back to the 10%, it just goes to the 40%. Not sure why.

Another question is, does a variable have to have it’s first letter as small and not caps?
IE… “myVariable” instead of "MyVariable"
Does it make a difference?

Thanks so much BTW. :slight_smile:

It does not make a difference. I honestly do not know the full reason, it is just something that is done that way.

I’m glad it is working better. If you wish to learn more about variables, I started the following thread that has lots of great input from many folks.

1 Like

Check this out. When I applied the SAVE and LOAD changes back into my original piston, it also worked. In the end it was my incorrect use of the SAVE/LOAD that messed me up. Your example is great but it doesn’t allow (at least I couldn’t find it) and AND time is between time A and time B.

Each action can be time delimited. Under the ‘When true’/‘When false’ you will scroll down and look for ‘Only execute if time is between’. You will place one each of these limits on BOTH the True and False statements.

In this image, you can see there is a time restriction on this ‘When true’

OK, first Piston and have it running almost how I want it but the lights always stay on. Backyard lights on 20% at 7:00pm and off at 7:30am. If any of the sliding doors open go 100%, stay at 100% for 3 minutes after they close and only when the backyard lights switches are on. I added the last part because I didn’t want the lights on during the day if someone opens the sliding door.

I set up a test piston that mimics yours and mine had similar results. The logic seems right, but for some reason it doesn’t work. You may need to use IF, THEN statements instead of When True, When False for it to work.

Technically it doesn’t make any difference. In programming there are two types of things which look like variables, variables and classes.

You start variables with a lowercase character and classes with an uppercase character so when you come back to your code, or somebody else does, you can immediately tell which is which.

Pistons don’t use classes (at least in a way you can tell), but people who are developers (me) get stuck in their ways.

This is my version of your piston, that works for me.

I then use Smart Lighting to turn the lights on at sunset and off at 11pm - but you could change this as you want.

Motion sensor is just on the other side of the door, so the lights stay on if we sit outside.

Your piston is not working because you have it has an ‘And-If’. Change the piston to a latching (But-If) and it will work. You can leave it as when true/when false. There isn’t anything wrong with doing that.

I switched it to a latching but I don’t see the option for (But-If).

Latching is the but-if piston type

Should be in there - http://thingsthataresmart.wiki/index.php?title=CoRE#Latching

Awesome, thanks guys. Will work in it this weekend and let you know how it goes.

1 Like

@ady624

Confused here

My morning lights Piston still won’t completely. The Piston fires, does change the mode to home but no lights will come on.

I have rebuilt the Piston from within CoRE, Re-created from scratch, added/removed lights…
The lights work manually, through the ST app and with a basic Piston to turn on/off

Here is my IDE log from about 5 mins ago that shows it did kick off but didn’t do anything

Here is the Piston

When I contacted ST support last week about this, they said, since the Piston fired, it’s not a ST issue but to contact the CoRE dev.

Thoughts?
Rick

What exactly are you trying to accomplish in the end with your piston?