Location Modes, Time-of-Day, and Location Automations


#1

So this is going to be a little out of format, but everything works in these pistons but everything will be explained below.
Hey everyone, I’m trying to get some help with a couple of my light pistons which I’ll explain when I get to them and if I could get some thoughts and/or pointers on my main programming pistons I’m ideally trying to either (a) condense them, (b) if there is an easier way that I can preform these functions, or © speed up the performance of the piston. Ideally, I would love to be able to combine them all, but when I do the piston is so large that it doesn’t work. I know that there is a lot of “junk” in there like logging and/or piston states, but it makes it a lot easier to see what’s happening internally and the piston. As you can tell I don’t trust it and love to make extremely specific automations. Lol, that has come with a lot of trial and error also, I’m completely self-taught and like to make these for fun and to learn programming. The Pistons deal with (1) Location Modes and Types, (2) Setting the Time-of-Day, (3) Routine Automations (Deadbolt/SHM/Light Modes). But if anyone could give me some thoughts and feedback I’d greatly appreciate it.
(1) The first piston deals with Location Modes and creating a variable called a Location Type (that acts as a check for basically every piston, but they are mostly for when automations run.) It then sets these two variables to a global variable. I currently have 6 Location Modes, and 3 Location Types (Home, Night, Away). Where each Location Type has 3 Location Modes. And these are accessible to all my pistons and it gives me to ability to see what is going on. I have tried this using if statements, switches, for loops, and the combination of all of them. But I feel like there could be a way better way to do this, plus I use to have multiple presence sensors in there, but I couldn’t get the range or timing to work at all and/or accurately. I think that I should mention I’m just beginning to use built in functions so any pointers are really really appreciated.

(2) This piston sets the time of day based using the location type global variable and specific time intervals. I also have the piston refresh anytime the location mode changes or a routine is activated.

(3) This piston uses the Time-of-Day and the Location Modes and Types to set the “security” (August Deadbolt and SHM), and sets the a global variable that sets specific scenes from my Philips Hue App that are saved as global variables.

Anyways if anyone would like to give me any kind of feedback or thoughts on how I could make these pistons more efficient I would greatly appreciate it!


#2

Not sure where to start as these are all so big. What is the reason for creating a time of day global variable? The time of day is already in system variables in several ways ($now, $hour, etc).


#3

I have the time of day piston to set my devices to do different actions (but mostly to different Philips hue scenes) during specific time intervals. Where they change based on if I’m in home, sleep or away nodes