DeusExMachina
Vacation Plugin for Vera Home Automation
Install / Use
/learn @toggledbits/DeusExMachinaREADME
DeusExMachinaII: The Vacation Plugin
Introduction
DeusExMachina is a plugin for the MiOS home automation operating system used on MiCasaVerde Vera gateway/controllers. It takes over your house while you're away on vacation by creating a ghost that moves from room to room, turning on and off lights. Simply specify the lights you want to have controlled by the plugin, specify a "Lights Out" time when lights will begin to turn off, and come sundown DeusExMachina will take over.
IMPORTANT: This plugin is no longer distributed/updated in the Vera App Marketplace, which as of this writing has been down for months and is apparently not fully functional and well-supported by Ezlo these days. Updates will be offered exclusively through the plugin's Github repository.
History
DeusExMachina was originally written and published in 2012 by Andy Lintner (beowulfe), and maintained by Andy through the 1.x versions. In May 2016, Andy turned the project over to Patrick Rigney (toggledbits here on Github, rigpapa in the MCV/MiOS world) for ongoing support (version 2.0 onward). At this point, the plugin became known as Deus Ex Machina II, or just DEMII.
How It Works
When Deus Ex Machina II (DEMII) is enabled, it first waits until two conditions are satisfied: the current time is at or after sunset, and the "house mode" is one of the selected modes in which DEMII is configured by the user to be active. If both conditions are met, DEMII enters a cycle of turning a set of user-selected lights on and off at random intervals. This continues until the user-configured "lights out" time, at which point DEMII begins its shutdown cycle, in which any of the user-selected lights that are on are turned off at random intervals until all lights are off. DEMII then waits until the next day's sunset.
For more information, see Additional Documentation below.
Reporting Bugs/Enhancement Requests
Bug reports and enhancement requests are welcome! Please use the "Issues" link for the repository to open a new bug report or make an enhancement request.
License
DeusExMachina is offered under GPL (the GNU Public License).
Additional Documentation
Installation
IMPORTANT: This plugin is no longer distributed/updated in the Vera App Marketplace, which as of this writing has been down for months and is apparently not well supported within Ezlo these days. Updates will be offered exclusively through the plugin's Github repository.
- Download the latest release package in ZIP format: release packages
- Unzip the downloaded archive to a location on your local system (remember where!).
- Open the Vera UI in your browser.
- Go to Apps > Develop apps > Luup files
- Go the folder container the unzipped files; select all of the files as a group, and drag them as a group to the Upload button in the Vera UI.
- Wait for the upload to complete and your Vera to reload Luup.
- Hard refresh your browser.
If and only if you are installing this plugin for the first time, perform the following additional steps to create the DeusExMachina II master device:
- Go to Apps > Develop apps > Create device in the Vera UI.
- For Description, copy-paste:
DeusExMachina II - For Upnp Device Filename, copy-paste:
D_DeusExMachinaII1.xml - For Upnp Implementation Filename, copy-paste:
I_DeusExMachinaII1.xml - Select a room if you wish.
- Press Create device.
- Go to Apps > Develop apps > Test Luup code (Lua)
- Enter and run
luup.reload() - Wait until Luup reloads and then hard-refresh your browser again (see last step above).
Simple Configuration
Deus Ex Machina's "Configure" tab gives you a set of simple controls to control the behavior of your vacation haunt.
Active Period
By default, you may specify a start time and an end time, during which DEMII will run (cycle lights). If the start time is blank, the current day's sunset time will be used.
If the Manual Activation checkbox is checked, then no automatic schedule for DEMII is run, and it must be started
and stopped by using the Activate and Deactivate actions (e.g. from a scene, PLEG, or Lua).
House Modes
The next group of controls is the House Modes in which DEMII should be active when enabled. If no house mode is selected, DEMII will operate in any house mode.
Controlled Devices
Next is a set of checkboxes for each of the devices you'd like DEMII to control. Selecting the devices to be controlled is a simple matter of clicking the check boxes. Because the operating cycle of the plug-in is random, any controlled device may be turned on and off several times during the cycling period (between sunset and Lights Out time). Dimming devices can be set to any level by setting the slider that appears to the right of the device name. Non-dimming devices are simply turned on and off (no dimmer slider is shown for these devices).
Note: all devices are listed that implement the SwitchPower1 and Dimming1 services. This leads to some oddities, like some motion sensors and thermostats being listed. It may not be entirely obvious (or standard) what a thermostat, for example, might do when you try to turn it off and on like a light, so be careful selecting these devices.
The "Max On Time" field can be used (optionally) to control the maximum time a light should be turned on. For example, it may not appear natural for DEMII to leave a bathroom/WC or hallway light on for 30 minutes, which it could easily do with its default behavior and schedule. Setting a maximum time on will cause DEMII to manage those lights to a shorter schedule explicitly.
Scene Control
The next group of settings allows you to use scenes with DEMII. Scenes must be specified in pairs, with one being the "on" scene and the other being an "off" scene. This not only allows more patterned use of lights, but also gives the user the ability to handle device-specific capabilities that would be difficult to implement in DEMII. For example, while DEMII can turn Philips Hue lights on and off (to dimming levels, even), it cannot control their color because there's no UI for that in DEMII. But a scene could be used to control that light or a group of lights, with their color, as an alternative to direct control by DEMII.
Both scenes and individual devices (from the device list above) can be used simultaneously.
Maximum "On" Targets
This value sets the limit on the number of targets (devices or scenes) that DEMII can have "on" simultaneously. If 0, there is no limit. If you have DEMII controlling a large number of devices, it's probably not a bad idea to set this value to some reasonable limit.
Final Scene
DEMII allows a "final scene" to run when DEMII is explicitly disabled, stops due to the house mode changing to an "inactive" mode (one in which DEMII is not supposed to run), or turns off the last light after the "lights out" time. This could be used for any purpose. I personally use it to make sure a whole-house off is run, but you could use it to ensure your alarm system is armed, or your garage door is closed, etc.
The scene can differentiate between DEMII being disabled and DEMII just going to sleep by checking the Target variable in service urn:upnp-org:serviceId:SwitchPower1. If the value is "0", then DEMII is being disabled. Otherwise, DEMII is going to sleep. The following code snippet, added as scene Lua, will allow the scene to only run when DEMII is being disabled:
local val = luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Target", pluginDeviceId)
if val == "0" then
-- Disabling, so return true (scene execution continues).
return true
else
-- Not disabling, just going to sleep. Returning false stops scene execution.
return false
end
As of version 2.8, there is special handling of the final scene for when the house mode changes to an inactive mode. If a scene with the name of the final scene plus the prior house mode can be found, it will be run in preference to the specified scene. That is, if your final scene is called "DeusEnd", but there's a scene called "DeusEndAway", then it will be run when DEMII deactivates due to the house mode changing to something other than "away." Otherwise, the "DeusEnd" scene will run.
Control of DEMII by Scenes and Lua
As of version 2.8, there are two ways to control DEMII's operation with scenes, PLEG, Lua, etc.:
- Set the active period to "Manual Activation" as described above, and use the
ActivateandDeactivateactions to start and stop cycling, respectively. When deactivating with this method, lights will be progressively turned off to simulate the bedtime "lights out" behavior DEMII uses with automatic scheduling. These actions are part of theurn:toggledbits.com:serviceId:DeusExMachinaII1service, and take no parameters. - Use the
urn:upnp-org:serviceId:SwitchPower1serviceSetTargetaction to turn DEMII on and off as you would any switch. This enables and disables DEMII. Using this method to start and stop cycling, however, is deprecated in favor of the above message.
Note that for cycling to occur, DEMII must either (a) be enabled with automatic timing on and a valid configured active period, or (b) be enabled, and with manual activation configured, in which case cycling will not begin until the Activate action is run, and not stop until the Deactivate action is run.
Here's an example of how to send the Activate action to DEMII:
luup.call_action("urn:toggledbits-com:serviceId:DeusExMachinaII1", "Activate", {}, _deviceNumber_)
Triggers
DEMII signals changes to its enabled/disabled state and changes to its int
