Skip to content

Commit

Permalink
Prep for 2.10 release
Browse files Browse the repository at this point in the history
  • Loading branch information
toggledbits committed Sep 28, 2019
1 parent 1e4ced5 commit 42550ee
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 23 deletions.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
# DeusExMachinaII Change Log #

## Version 2.10 (development)
## Version 2.10 (released)

* Support DeusActivity.log file, enabled by setting `MaxLogSize` to a non-zero value (units are kilobytes; logs larger than this size are "rotated" through a single LZO archive).
* Clear device state cache at the start of cycling, to ensure up-to-date state; no bug associated with this, it's just a noticed omission.
* Enhancement: implement PreactionScene (state variable) and DEMIIAction.lua hook. The latter (file), if it exists, is loaded and run; the code is expected to return a function that accepts two arguments: target and state. Before DEMII turns a target on or off, it will call this function. This is the result of a request by @rafale77 for a "hook" to allow him to mute his camera motion sensors before lights change.
* Handle any unknown device as binary light rather than erroring-out for that device; this is more flexible, and creates the opportunity for immediate manual configuration of unrecognized devices, without the need to wait for code changes.
* Clean up device list in configuration, and improve device type detection.
Expand Down
2 changes: 1 addition & 1 deletion D_DeusExMachinaII1_UI7.json
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@
"left": 0,
"Label": {
"lang_tag": "dem_about",
"text": "DeusExMachinaII ver 2.10develop-19245 &#169; 2016,2019 Patrick H. Rigney, All Rights Reserved. For documentation, license, or to report bugs, please go to the <a target='_blank' href='https://github.com/toggledbits/DeusExMachina'>DeusExMachinaII Github repository</a>. Use of this plugin constitutes acceptance of and agreement to the license terms without limitation or exclusion."
"text": "DeusExMachinaII ver 2.10 &#169; 2016,2019 Patrick H. Rigney, All Rights Reserved. For documentation, license, or to report bugs, please go to the <a target='_blank' href='https://github.com/toggledbits/DeusExMachina'>DeusExMachinaII Github repository</a>. Use of this plugin constitutes acceptance of and agreement to the license terms without limitation or exclusion."
},
"Display": {
"Top": 90,
Expand Down
2 changes: 1 addition & 1 deletion J_DeusExMachinaII1_UI7.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

var DeusExMachinaII = (function(api, $) {

var pluginVersion = '2.10develop-19267';
var pluginVersion = '2.10';

// unique identifier for this plugin...
var uuid = '11816AA9-0C7C-4E8F-B490-AAB429FA140F';
Expand Down
46 changes: 26 additions & 20 deletions L_DeusExMachinaII1.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ local string = require("string")

local _PLUGIN_ID = 8702 -- luacheck: ignore 211
local _PLUGIN_NAME = "DeusExMachinaII"
local _PLUGIN_VERSION = "2.10develop-19267"
local _PLUGIN_VERSION = "2.10"
local _PLUGIN_URL = "https://www.toggledbits.com/demii"
local _CONFIGVERSION = 20904 -- increment only, do not change 20 prefix

Expand Down Expand Up @@ -922,7 +922,7 @@ local function runOnce()
initVar( MYSID, "MinTargetsOn", 1, pluginDevice )
initVar( MYSID, "MaxTargetsOn", 0, pluginDevice )
initVar( MYSID, "LeaveLightsOn", 0, pluginDevice )
initVar( MYSID, "MaxLogSize", 64, pluginDevice )
initVar( MYSID, "MaxLogSize", 0, pluginDevice )
initVar( MYSID, "Active", "0", pluginDevice )
initVar( MYSID, "LastHouseMode", "1", pluginDevice )
initVar( MYSID, "NextStep", "0", pluginDevice )
Expand Down Expand Up @@ -984,7 +984,7 @@ local function runOnce()
initVar( MYSID, "MaxOffDelay", "", pluginDevice )
end
if s < 20904 then
initVar( MYSID, "MaxLogSize", "64", pluginDevice )
initVar( MYSID, "MaxLogSize", "0", pluginDevice )
end

-- Update version state last.
Expand Down Expand Up @@ -1101,20 +1101,25 @@ end
local function runMasterTask( task, dev )
D("runMasterTask(%1,%2)",task,dev)
if isEnabled() then
local currState = getVarNumeric("State", STATE_STANDBY, dev)
-- By default, master task will run every 60 seconds. But a lot can change that...
task:delay( 60 )

-- Get going...
local currState = getVarNumeric("State", STATE_STANDBY, dev)
local nextStep = getVarNumeric("NextStep", 0, dev)
local isAutoTiming = getVarNumeric( "AutoTiming", 1, dev ) ~= 0
if not isAutoTiming then
-- Manual/external activation mode. We just wait.
-- Set message for idle state. Other states handled in runCyclerTask.
D("runMasterTask() auto-timing off; current state is %1", currState)
if currState == STATE_IDLE then
setMessage("Waiting for activation")
task:suspend() -- we just wait
else
local nextStep = getVarNumeric( "NextStep", 0, dev )
setMessage("Cycling; next at " .. os.date("%X", nextStep))
-- Still shutting down
setMessage((currState==STATE_CYCLE and "Cycling" or "Lights-out") .. "; next at " .. os.date("%X", nextStep))
end
return -- don't reschedule master task
return
end

-- Auto-timing check.
Expand All @@ -1133,9 +1138,9 @@ local function runMasterTask( task, dev )
local inActiveHouseMode = isActiveHouseMode( mode )
-- We're auto-timing. We may need to do something...
if inActiveTimePeriod then
D("runMasterTask(): in active time period")
D("runMasterTask(): in active time period, currstate=%1", currState)
if inActiveHouseMode then
D("runMasterTask(): in active house mode, currState=%1", currState)
D("runMasterTask(): in active house mode")
-- Right time, right house mode.
if currState == STATE_IDLE then
-- Get rolling!
Expand All @@ -1150,10 +1155,10 @@ local function runMasterTask( task, dev )
t:delay( 0 )
end
end
return task:delay( 60 )
return
else
-- Right time, wrong house mode.
D("runMasterTask(): not active house mode, currState=%1", currState)
D("runMasterTask(): active period, but not active house mode")
if currState == STATE_CYCLE or currState == STATE_SHUTDOWN then
L("Stopping; inactive house mode")
setMessage("Stopping; inactive house mode")
Expand All @@ -1164,33 +1169,34 @@ local function runMasterTask( task, dev )
return task:schedule( nextStart ) -- default timing
end
else
D("runMasterTask(): not active time period")
D("runMasterTask(): not active time period, currState=%1", currState)
if inActiveHouseMode then
D("runMasterTask(): in active house mode for inactive period, currState=%1", currState)
D("runMasterTask(): in active house mode for inactive period")
-- Wrong time, right house mode.
if currState == STATE_CYCLE then
L("Lights-out (auto timing), transitioning to shut-off cycles...")
setMessage("Starting lights-out...")
setVar(MYSID, "State", STATE_SHUTDOWN, dev)
return task:delay( 60 )
return
elseif currState == STATE_SHUTDOWN then
-- Keep working.
return task:delay( 60 )
setMessage("Lights-out; next at " .. os.date("%X", nextStep))
return
end
else
-- Wrong time, wrong house mode.
D("runMasterTask(): inactive house mode, inactive time period, currState=%1", currState)
D("runMasterTask(): inactive house mode, inactive time period")
if currState == STATE_CYCLE or currState == STATE_SHUTDOWN then
L("Stopping; inactive house mode")
setMessage("Stopping; inactive house mode")
stopCycling( dev )
end
end
L("Waiting for " .. startWord)
setMessage("Waiting for " .. startWord)
if nextStart <= os.time() then nextStart = nextStart + 86400 end
return task:schedule( nextStart ) -- default timing
end
L("Waiting for " .. startWord)
setMessage("Waiting for " .. startWord)
if nextStart <= os.time() then nextStart = nextStart + 86400 end
return task:schedule( nextStart ) -- default timing
else
D("runMasterTask() disabled")
setMessage("Disabled")
Expand Down

0 comments on commit 42550ee

Please sign in to comment.