Z-Box Use Case: Enumerated Variable

As I’m becoming familiar with my recently acquired Z-Box hub, I’ve taken a look at implementing the paradigm used by SmartThings for what they title Location Mode. By default, the SmartThings hub has Location Mode defined as: Home, Night, or Away. I’ve added Evening to mine, as there are Scenes/Routines that depend upon it being between the hours of Sunset and when we switch to Night, usually by telling our girl, “Alexa, Good Night!” (She runs routines on both of our hubs–one at our main home and the other at our winter condo–and wishes us a pleasant sleep. Each hub does its nighttime thing as long as it isn’t in Away mode.)

On Z-Box, a Profile pretty much performs the same state function, i.e., tell you whether it’s night or you are away. Additionally–and this is a pretty cool feature–changing the active profile can actually accomplish many of the things you might think a Scene/Routine would be needed to do. For example, turn off some lights when you go to bed or arm some alarm features if the Profile changes to Away. A profile change will run a Scene, a Scenerio (a whole topic in itself!), change your thermostat setting, or act directly upon a device or set of devices. Sounds pretty efficient!

The Block Scene builder on Z-Box can check before executing some set of actions if the Profile is some combination of Home/Evening/Night/Away in my paradigm–but that could mean multiple scenes that perform the same action. However, an Enumerated Variable can make the logic simpler–and probably uses less resources and executes slightly faster!

Create a (global) Variable under Settings->General->Variables. Make it an Enumerated Variable (I called mine Location_Mode) with the attributes Home, Evening, Night, and Away. Next, create four Scenes, each triggered by a change in the Profile to cause Location_Mode to “mirror” the currently selected Profile.

Now you can simply use Location_Mode as a pre-condition (in other words, un-check Use as trigger when creating the new scene). Let’s say you want to do something time-based only if you are at home, such as switch from Home to Evening at sunset. Easy!

if (Sunset)                    -- the trigger
  and (Location_Mode != Away)  -- the precondition
then
  Profile = Evening            -- the action (change to Evening Profile)

There is more here on using Enumerated Variables.

1 Like

Love it! Thank you for sharing!

1 Like