I like your logic. I have structured many of my pistons in a similar fashion…
One thing I do different is I make sure there are no triggers in the “I’m Back!” piston. This lets any other piston call it, but prevents the piston from running itself, so to speak.
When the piston is saved, you want to see this up top:
For example, in your pic above, the entire logic will run thru (top to bottom) each time Contact Sensor 1 is closed. (line 29) The way it is currently worded, closing that contact after sunset will turn on Switch 1, and also turn 3 other bulbs to 50%.
Heck, it might even unlock your doors. **shivers at the thought**
I always recommend EXTREME caution if you absolutely must program Auto-Unlocks.
If it were me, I would not leave the house until I resolved this, or at the very least, disabled that section of code.
Anyways, back on topic…
If you do not wish to remove the subscribed triggers, then you have many other options revolving around variables and/or arguments in some way. Probably the easiest is having your other piston send the current piston’s External URL in a GET web request to pass the data. (instead of the Execute piston
command you are using now) Then, in your “I’m Back!” piston, you can set it to only do commands if a specific argument has been passed.
A example would be.
Piston 1
Set variable {triggered} = {"true"};
Make a GET request to https://api.smartthings.com/api/token/abc123/smartapps/installations/def456/execute/:ghi789:?triggered={triggered};
This link points to the External URL of “I’m Back!”, but I added to the end of the URL:
?triggered={triggered}
Which actually sends:
?triggered=true
Then we can add one line to
Piston 2 - "I’m Back!"
IF
Date & Time is after sunset
and
{$args.triggered} = true <-- new line
THEN
Set Bulbs to whatever
END IF
Any block of code with that extra line in it, will only follow thru if the right parameters were sent from another piston.