CoRE - Get peer assistance here with setting up Pistons

So I updated it and rebuilt the piston with the same response.

My question is: I have a piston turning the light on and then off after 10 minutes of no motion. Do I need to put something in there that cancels the first piston? Is it the Pause Piston? Does it need to be resumed after waiting ten minutes and the turning off action is complete?

Can a Global Variable be set to a different value from within a Piston?

Iā€™m having trouble with variable setting and a momentary switch.
Not long loaded CoRE and so still getting my head around things.
Iā€™ve a momentary switch (fibaro relay) opening/closing my curtains. I want to record the state (open/closed) so I can program them only to close in an evening, rather than just toggle from the last event.
Iā€™ve set up a simple piston - condition ā€˜switch changesā€™ then look to see if variable ā€˜openā€™, else set ā€˜closedā€™. It doesnā€™t work.
If I use the same piston but with a light switched instead of the curtains, it does work.

Iā€™m really struggling with the reason! Thankyou for any help.

Alright experts have a few questions for you:

I have setup a piston to alert me via push notification when a battery level of any of my sensors get below 25%. I did this using {$currentEventDevice} in the push notification. Questions are the followingā€¦

1.) If there is more than one sensor will there be more than one push notification?
2.) Can I alter this piston to alert me once a day as long as there are devices that are less than 25%?
3.) Is there a way to send a report of some kind lets say via text in another piston comma delimtied form that would show me the battery level of each deviceā€¦I know there are smart apps for this but honestly they arenā€™t reliable. Iā€™ve used them and canā€™t get the granularity that I need.
4.) How will this affect battery life and are there things that I can do to the above pistons to ensure better battery life?

Alright guys want to split these up as they are different scenarios and I thought I would be more likely to get a response from each scenario if I split them up.

I would like to replace notify me when smartapp with a simple piston. Is there a way to only alert me when motion is here/there or contact is here/there on a per sensor basis once every X number of minutes per sensor?

Here is another oneā€¦ I setup a nightly safety check that checks all the contact sensors and sends a push notification if one of them is open after dark. My question is since I used the {$currentEventDevice} will it send me a push notification for each device?

Also how do i set this up to alert me every hour after the first alert until the sensors are closed? Is that possible?

Thanks,
Automation Hoarder

I noticed that your usingā€¦ is blank, Iā€™ve never seen that before. If you go back into that piston can you confirm that you have chosen a device? Also have you tried again with a starting value to see if it does work? Regarding your other motion piston I think it would depend on the timing of the events. It could turn off your light prior to your other piston fading and turning it off. You can view the recent events of the device and see whatā€™s going on too. Post a pic of your motion piston and mayb we can work it all into one once I see your intentions.

Just set the variable again with a different value by providing your own or doing operations on it. Something like Set number variable @loopCount = @loopCount +1

Post a pic of that piston so we can check it out.

I donā€™t have a specific piston at this point. Trying to think about how I would use local vs global values. Under actions > Using Location > Set Variable it seems like this only deals with local variables. Is this correct?

Add a @ to your variable name and it will be treated as a global.

Many thanks! Thatā€™s the detail I was searching high and low for.

This is how I prefer to set mine up. It will send a notification telling me whatā€™s open and continue to send the msg (using followup) until I close the sensor. You can use this as a template.

That follow-up is the exact same piston pictured correct?

Well you were right about a device getting accidentally deslected, good eye.

So now what I have happening is: run the good night routine, a delay of about 120 seconds, and then the light quickly ramps down to 1% and stays that way for another 120 seconds before it turns off.

Iā€™ve attached both the on pistons and the good night piston to give a bigger picture of what Iā€™m trying to accomplish.

Greatly appreciate your help!!

Thank you for looking. I canā€™t even get it to change the variable with a lamp nowā€¦ must have messed something in trying again.

Ok, what about something like thisā€¦ You can also do this in a basic piston with expert mode enabled. This one is a latching piston.

IF
Curtain switch changes to on
AND
@curtstate is equal to "closed"
Using location...
  > Set string variable @curtstate = open

BUT IF
Curtain switch changes to on
AND
@curtstate is equal to "open"
Using location...
  > Sety string variable @curstate = false

Hello again.
Thatā€™s just fabulous, thank you kindly!
Yours works a treatā€¦never thought of using a but-if.
My original one seemed logical(!), so what did I get wrong so I can learn from it?

Now Iā€™m going to write a piston that checks the time and the variable - if 5.15 and already ā€˜closedā€™ then it doesnā€™t activate.

Thank you again.

The trigger is what I focused on. Momentary switches are normally open/off, if you use the ā€˜changesā€™ trigger then it would catch both the on and off.

Ah, so it would trigger it twice with on and off and thus return to the originalā€¦looking like it had done nothing. I didnā€™t know whether it switched so quick that nothing registered. I was thinking to go back to a single switch on, then a wait, then an off to ensure something could be ā€˜seenā€™.

All good learning experience.
Thankyou