Blake its pretty simple.
Store a value for later to act on. these are usually interpolated or calculated values that had little or nothing to do with the state of an existing device.
For instance. Lets go through this use case…
Washing Machine Notification:
(Dumb Washing machine connected to system with Zooz heavy duty Zwave outlet.)
Requirements:
When washing machine completes load, notify user until either acted upon (cancel is a valid action) or 5 notification cycles complete unanswered.
Assumption:
Washing machine is not ‘smart’ itself but is connected to the system using a metering plug. The plug accurately measures the load from the Washing machine and we have observed recurring values where we can be reasonably assured we can trap ‘running’ ‘spin’ and ‘idle’ DONE is to be considered IDLE after a period where the machine was ‘running’ for 5 or more minutes and is now idle.
So for this we would need to capture a value for current state. (remember the plug doesn’t do this so we’re reading values and calculating a flag based on that value - lets create a string (local) variable and store RUNNING, SPIN, IDLE, OFF, and UNKNOWN (This could also be an integer, but I like self documenting code)
I need to capture the ‘DONE’ condition, so I need a temp variable to store ‘last’ state and compare to current. (another local same type as above) and if it meets the criteria I want, I need to set ANOTHER flag in this case, lets do bIsDone as a local Boolean
So now we can trap the is Done flag. We announce. To what? under what conditions? When Echo Speaks was a thing, I had a second piston constantly capturing the ‘last used’ echo in my system and Stuffing a global variable of type DEVICE with the device object of the last spoken to Echo. BTW - Echo Speaks shouldn’t be the barometer if this IS necessary - it just is - we need a way to store a device or group of devices for later processing, this could be speakers, presence objects, lamps, switches, etc. Doesn’t matter. It facilitates creating a program that behaves conditionally depending on what devices are fed to it.
Also do we even Announce? For this I had global variables tQuietHoursStart, and tQuietHoursEnd, with the start and stop times for all general announcements. These were both type DateTime that stored a 24 hr time. Any announcement went through a piston that accepted the announcement text as input - String, a type of announcement (general or urgent, as string were the most common) as well as an optional Device as the speaker target. Depending on the combination of these inputs it would route the announcement to the right speaker and if it were quiet hours and not urgent it wouldn’t notify at all and instead route the message to the system’s history.
I need a loop that does the notify, check response thing- another boolean possibly two depending on how complex the check is, local context. I also need a counter for this loop to limit after 4 retries… Integer, local.
So in just this ONE example I need, Boolean, Integer, String, Device and DateTime in BOTH local and global contexts. I also need advanced comparison and branching.
BTW - THIS is why you guys are seeing so many v-switches popping up and why the v-switch creator is so important right now. Without a way to store state flags, guess what becomes state flag storage? (Unfortunately most people don’t realize they’re also bumping themselves against various system limits by doing this)
Without it you can’t do anything beyond a basic motion light. Even those are iffy without the ability to run locally - big improvement when you finally get the ability to do a delayed check in local processing…
Ady knows all this - just go ask him. 