Repeating piston checks and actions


#1

Hi, there are a couple of issues I’ve got with the below piston. Firstly, it seems to only run once. So will notify me the first time a light is turned on during the time conditions but won’t notify me if any further lights turn on during the same time period. Do I need to use a while loop to achieve that?

Secondly, when the piston did run first time, I got duplicate notifications. I had this issue with an outdoor light condition which was also based on sunset timings so I think I know what would fix it but this time it’s not one device being manipulated, it could be more than one and they will be in the “LightsOn” variable so not sure how I resolve that.

Any help would be much appreciated!


#2

@freddyq Here you go,
Sorry its taken so long for anyone to help, ive just spotted your post and decided to recreate your piston for you,
I have tested it and it works flawlessly as long as you still have the variable {@allLights} and all the lights in your house are in that variable…


#3

Thanks! And no problem about the delayed reply.

I can update my piston like this but what are the symbols next to lines 26 and 28?


#4

That is me forcing the piston not to subscribe to those events.

If you can’t find the setting then the easiest thing would be to import my piston using the import code.

Just select create a new piston. Then click the orange button. And type in that code. :grinning:


#5

Ah ok gotcha! I actually managed to get the piston to work with a slightly different structure (see below). I added a notification for when the light turned off as I noticed I was wanting to know that as well. Would yours be more efficient or will my version also work just as well?


#6

Have you tested your piston yet?
Just wondering because looking at it, it seems as though you will only be notified about one light at a time instead of more than one light being on?

I may be wrong but I think you need to change it slightly.

Try turning on 2 lights and see if you get individual notifications about them both or one about the first and then a second about both of them?

I’m guessing you will get one about the first and then a second about the second not about both being on together?


#7

Oh yes you’re right, I’m pretty sure I only get singular notifications when a light turns on - that’ll be the difference between my piston and yours. Much prefer your one so I will import and check it out. Many thanks! :slight_smile:


#8

So I finally got round to testing your piston and if I turn on two lights, I get separate on and off notifications for each. I think you were suggesting in your last response that with your version of the piston when the second light turns on I would get a notification saying the two lights which were on…?


#9

That’s correct. You will get notifications containing multiple light names if more than 1 are on.

Are you not getting that then?

Did you import my piston using the import code?


#10

hmm no I get individual notifications, not combined ones like those in your screenshot. And yes, I imported the piston using the backup code in the screenshot.


#11

Hang on, I haven’t got the same piston logic as yours actually. I’ll try again, if I also want a notification when one or more of the lights subsequently turn off, where can I add that?


#12

This will do what you’re after.
Just make sure all your lights are in a Global DEVICE Variable. Called @allLights
Then import this piston and don’t change anything in it apart from the notification. :grinning:


#13

Perfect - thanks! Will test this out soon hopefully. But the logic all makes sense to me.


#14

Yep that works a treat. Thanks a lot!