Oct 22, 2017
Oct 22, 2017
Dec 14, 2018
This is a very simple virtual device that is compatible with the fine Smart Lights scene provided by stevenvd. It also borrows from the contributions of some leading lights of this community as referenced in the code. Thanks to all - .stevenvd, Robmac, Krikroff, Shad, Dalle1985, Jompa68 and many other forum members.
It is a simple VD that presents and allows the manual change of the global 'state' variables used by Smart Lights: presentState, TimeOfDay and sleepState.
I have this VD running in a section called House. I find it very helpful to see and - at times - manually adjust the state variables. Otherwise the state variables are managed by a set of scenes:
You will find more sophisticated versions within the forum as well but this is a good starting point for anyone begining to automate using some common techniques, global variables, scenes and VDs found on the forum.
TimeOfDay (Morning, Day, Evening, Night)
These are all managed via block scenes:
sleepState (Sleeping Waking up, Awake, Going to sleep)
This is managed by a set of block scenes and also be other VD. For example, in the master bedroom I have a 'Sleep Timer' virtual device that acts as a 'reverse' alarm clock dimming lights and volume on Sonos after preset or custom sleep 'delay'. In this sleepState is set to "Going to sleep" at start of the process and switched to "Sleeping" when timer expires.
Other scenes or devices could also change this state - it is simple at present - but I use as trigger for other actions.
presentState (Home, Away, Holiday)
This is currently managed by this House Status VD only but could easily be trigger in other ways.
guestMode (Family, Guests)
This is not used in SmartLights scene by stevenvd. It is currently managed manually through this House Status VD only.
The virtual device code follows a common pattern in each button that cycles through the defined domain values for each state and updates the UI. You will see a identical code snippet in each button - behaviours are controlled through parameters called managedGlobal, uiVariable and state. This makes it easy to add extra buttons for other global variables if you wish.
The main loop is a simple construct to create a summary sentence for the compact/expanded VD display form - it shows status details as best it can given available screen real-estate. For example, "It is Night and the house is Awake. (Home with Family)."