Does a piston multithread or run sequentially


#1

1) Give a description of the problem
want to understand if I can combine all my door sensor pistons into a single one. I’ve attached one that I have of 4…

2) What is the expected behaviour?
I want to put all my door sensor pistons together and have a foreach loop of all door contacts
My piston has a 5 min wait after notifying that a door is open …and I’m trying to understand if that 5 min wait would hold off the foreach loop from going to the next sensor

3) What is happening/not happening?
not there yet

**4) Post a Green Snapshot of the piston

5) Attach logs after turning logging level to Full
not there yet

REMOVE BELOW AFTER READING
If a solution is found for your question then please mark the post as the solution.


#2

Why do you have a 5-min wait?


#3

I suspect that you don’t want to hear the “Close the front door” message more than once per 5 minutes. Is that the case?

With the current settings you have, the piston will be restarted each time that condition (the lightning bolt line #24) is met. There are some settings that control how that works, but I’m not an expert with that yet. Instead, I might try setting senttext to a datetime expression of addMinutes($now, 5), then check if $now is greater than senttext in line 39.

For the other part of your question (while loop), I do something similar with my “alarm” piston, but I think @WCmore says that you shouldn’t subscribe to so many devices in a single piston. It did seem to work, aside from the app sometimes not noticing that I was at home.


#4

If the temperature is your biggest concern, I would make that a starting condition. Otherwise, it’s going to give the warning whenever the door is open regardless.

If so, you might want to designate a range (+/- 5 or 10 degrees). Otherwise, you’ll hear a warning even if there’s only a 1-degree difference.


#5

Thanks for the responses !

Mebejedi and ian_boje
The goal was to notify you when the door was left open…then wait 5 mins before notifying again
My question revolves around the fact that I have 4 separate pistons doing the same thing and was wondering if a for each device would act the same as 4 separate pistons or would get hung up on the 5 min wait
The temp was not a concern …I just thought it was cool that I could tell them the temp inside and out when a door was open : )


#6

While I believe, for all practical purposes, this is true… your 7ps4 piston might actually be a valid exception.

pic

My logic is, the entire code base is a single line (line 40). This means it completes the piston a few milliseconds after it begins… 99.9% of the time, there will only be one “version” of the piston in action at any given moment. (this is good)

One of the reasons why I traditionally discourage multiple triggers is because most pistons grow in complexity, and it takes longer to process the extra lines of code. This means walking normally thru your house, Sensor 2 may trigger, and while it is still processing (or waiting etc), then Sensor 4 triggers. (this can really complexify your troubleshooting and coding)


If I am remembering correctly from another thread, it is also worth mentioning that @ian_boje’s piston is normally Paused, so not competing with other resources.

Edit:
I just noticed line 38… “IF Location is Away”.

If this piston is left running 24/7, then it will trigger at each event, all day, every day… even while you are home. (thankfully the code to execute is super quick)


#7

While this is true, wouldn’t it save some cycles if line 38 was before all the checks? If Location is home, it won’t bother with the rest. Not a huge deal, but…


#8

It won’t make any difference… A condition is not checked until after a trigger fires.