Help Optimizing this Piston - Presence


#1

This piston is working really well, but there is a few things that bug me and would love your suggestions.

  1. It is very wordy and repetitive. is there a way to streamline this with variables? I am thinking of the different times of days, number of presence sensors and the different devices.
  2. when the wife and I leave at the same time (same car basically), we both get flooded with notifications. Is there a way to streamline this so that we only get one notification stating no one is home?


#2

thats quite a piston you have there. :slight_smile: how many chunks is the piston?

some of those notifications could be logically combined. like when someone arrives, the garage is opened and garage door is unlocked could just be one notification. same on the way out as well. is that an option?

the piston is set to execute when switch 20 is off. then inside the piston various conditions also have a restriction of switch 20 is off. one of those could be removed depending on the required logic.


#3

it is 21 chunks. I can definitely clean on the switch repetitiveness. as far as combining notifications, can you give me a recommendation? I understand what you are saying but wondering exactly how to do it. Thanks!


#4

consider splitting it up in to 2 pistons of 10 chunks? the number of chunks has an effect on the effective execution time for each event and this would also reduce the risk of running out of timeouts when trying to save it if gets too large.

simple things i would do is the last part which allows some automation when in-laws arrive i would make that its own piston called In-laws are here AGAIN, sweet! piston and remove that part from this piston.

if you post an updated version with the restrictions removed, i will import it and look some more.

EDIT: couple more things:

before turning off the lights there is an only when to check if any of the lights are on. why not remove that only when and remove the notification that goes along with it. just turn off the lights.

if there is a mode management piston, is there a need to repeat the mode settings in this piston as well?

also, the contact sensor 7 and lock 1 unlock group of actions is repeated a few times. may be consolidate that under 1 if?

EDIT2: sorry, i realize this were not your original question. just trying to look at some things that may be helpful regardless. if they are not, just ignore. :slight_smile:


#5

You might be able to reduce the repetition by enabling when true/false statements and then structuring this more like

if
    Time is between 6 and 8
        when true
            Set location mode to Morning - Weekday
    OR
    Time is between 8 and 30 minutes to sunset
        when true
            Set location mode to Afternoon - Weekday
then
    Set Smart Home Monitor status to off
    Set arrivalMessage ... etc

where you use OR to group together multiple actions when any condition is true and only put the parts that differ into the when true.