From 3224f5a50360f3de62e5671c72d444dd4dea3bde Mon Sep 17 00:00:00 2001 From: Patrick Rigney Date: Thu, 14 May 2020 10:51:55 -0400 Subject: [PATCH 1/6] Hotfix 20135-01: Fix UserURL notify action type not substituting message field correctly --- CHANGELOG.md | 4 ++++ J_ReactorSensor_UI7.js | 2 +- J_Reactor_UI7.js | 2 +- L_Reactor.lua | 20 ++++++++++++-------- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c597aa9..81f51eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,10 @@ NOTE TO OPENLUUP USERS: All current versions of Reactor REQUIRE openLuup 2020.04 **DEPRECATION NOTICE:** The expression functions `arraypush()`, `arraypop()`, `arrayunshift()` and `arrayshift()` have been made first-class functions in the LuaXP module under the names `push()`, `pop()`, `unshift()` and `shift()` respectively. The `array...()` versions are now deprecated, and will be removed from a future release. Please convert to the new functions, which for all practical purposes are identical (so you just need to change the names in your expressions and it's done). +## HOTFIXES TO 3.6 RELEASE + +* Hotfix 20135-01: Fix special message parameter not correctly substituted in *UserURL* notification method. + ## Version 3.6 (released) * **BREAKING CHANGE**: The previously-permitted but inconsistently-supported ability to use variable substitution embedded within strings (e.g. `The time is {now}`) is no longer supported. Some places could handle expressions, others could handle only variable names, and the embedding within a string was also not consistently supported. In order to make the behavior consistent throughout, a new formatting rule applies. Now, variable/expression substitutions are performed only when the string/parameter/operand begins with a `{` (left curly brace) and ends with a `}` (right curly brace). The text between the curly braces may be a variable name or an expression (a variable name alone is, in fact, an expression unto itself). Concatenation operators can be used to build strings from both text and multiple values, as well as any of the functions available. So where previously one might have used `The time is {nowtime} and the weather is {weatherwords}`, it is now necessary to use `{ "The time is " .. nowtime .. " and the weather is " .. weatherwords }`. This was necessary to support consistent form and use of expression substitution in more places where possible. diff --git a/J_ReactorSensor_UI7.js b/J_ReactorSensor_UI7.js index dcc29c8..16586ed 100644 --- a/J_ReactorSensor_UI7.js +++ b/J_ReactorSensor_UI7.js @@ -17,7 +17,7 @@ var ReactorSensor = (function(api, $) { /* unique identifier for this plugin... */ var uuid = '21b5725a-6dcd-11e8-8342-74d4351650de'; - var pluginVersion = '3.6'; + var pluginVersion = '3.6hotfix-20135'; var DEVINFO_MINSERIAL = 482; diff --git a/J_Reactor_UI7.js b/J_Reactor_UI7.js index f764fa8..d992bf0 100644 --- a/J_Reactor_UI7.js +++ b/J_Reactor_UI7.js @@ -17,7 +17,7 @@ var Reactor = (function(api, $) { /* unique identifier for this plugin... */ var uuid = '72acc6ea-f24d-11e8-bd87-74d4351650de'; - var pluginVersion = '3.6'; + var pluginVersion = '3.6hotfix-20135'; var _UIVERSION = 20130; /* must coincide with Lua core */ diff --git a/L_Reactor.lua b/L_Reactor.lua index aff4943..bf2d7d1 100644 --- a/L_Reactor.lua +++ b/L_Reactor.lua @@ -11,7 +11,7 @@ local debugMode = false local _PLUGIN_ID = 9086 local _PLUGIN_NAME = "Reactor" -local _PLUGIN_VERSION = "3.6" +local _PLUGIN_VERSION = "3.6hotfix-20135" local _PLUGIN_URL = "https://www.toggledbits.com/reactor" local _DOC_URL = "https://www.toggledbits.com/static/reactor/docs/3.6/" @@ -176,9 +176,9 @@ end local function urlencode( s ) -- Could add dot per RFC3986; note space becomes %20 - return s:gsub( "([^A-Za-z0-9_-])", function( m ) + return ( s:gsub( "([^A-Za-z0-9_-])", function( m ) return string.format( "%%%02x", string.byte( m ) ) end - ) + ) ) end -- Shallow copy @@ -1824,7 +1824,7 @@ local function getExpressionContext( cdata, tdev ) end ctx.__functions.urldecode = function( args ) local str = string.lower( args[1] or "" ):gsub( "%+", " " ) - return str:gsub( "%%([a-f0-9][a-f0-9])", function( m ) return string.char( tonumber( m, 16 ) or 49 ) end ) + return ( str:gsub( "%%([a-f0-9][a-f0-9])", function( m ) return string.char( tonumber( m, 16 ) or 49 ) end ) ) end -- Append an element to an array, returns the array. ctx.__functions.arraypush = function( args ) @@ -2388,7 +2388,7 @@ local function doActionNotify( action, scid, tdev ) D("doActionNotify() AddAlert request returned %1,%2 [%3]", st, ht, baseurl) elseif action.method == "UU" then -- User URL local baseurl = action.url or "" - baseurl = baseurl:gsub( "%{message%}", urlencode( msg ):gsub("%%", "%%%%") ) -- special + baseurl = baseurl:gsub( "%{message%}", ( urlencode( msg ):gsub("%%", "%%%%") ) ) -- special baseurl = baseurl:gsub( "%{[^}]+%}", function( ref ) local vv = getValue( ref, nil, tdev ) return ( vv ~= nil ) and vv or ref @@ -6007,10 +6007,14 @@ local function getReactorScene( t, s, tdev, runscenes, cf ) if cf.notifications and cf.notifications[tostring(act.notifyid)] then local nn = cf.notifications[tostring(act.notifyid)] if nn.scene then resp = resp .. " sid " .. nn.scene end - if nn.users then resp = resp .. " users " .. tostring(nn.users) end + if ( nn.users or "") ~= "" then resp = resp .. " users " .. tostring(nn.users) end resp = resp .. " message " .. string.format("%q", tostring(nn.message)) end - local mv = { + for k,v in pairs(act) do + if not string.match(":type:method:notifyid:", k) then + resp = resp .. string.format("; %s=%q", k, tostring(v)) + end + end local mv = { SM={"SMTPServer","SMTPPort","SMTPSender","SMTPDefaultRecipient","SMTPDefaultSubject","SMTPUsername","*SMTPPassword"}, PR={"ProwlProvider","ProwlSubject","ProwlURL","*ProwlAPIKey"} } @@ -6018,7 +6022,7 @@ local function getReactorScene( t, s, tdev, runscenes, cf ) local m,n = v:match("^(%*)(.*)") n = n or v local vv = getVar( n, "", pluginDevice, MYSID ) - if m and vv ~= "" then vv = "****" end + if m and vv ~= "" then vv = "*" end resp = resp .. string.format("; %s=%q", n, tostring(vv)) end if act.method == "SM" then From 450b153e820d8eef10d1341b2e8388f1b5a0307f Mon Sep 17 00:00:00 2001 From: Patrick Rigney Date: Sun, 24 May 2020 09:11:43 -0400 Subject: [PATCH 2/6] Hotfix 20145-01: Fix field redraw/reload problem with "not between" operator on date/time conditions. --- CHANGELOG.md | 1 + J_ReactorSensor_UI7.js | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 81f51eb..8e7e0cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ NOTE TO OPENLUUP USERS: All current versions of Reactor REQUIRE openLuup 2020.04 ## HOTFIXES TO 3.6 RELEASE +* Hotfix 20145-01: Fix field redraw/reload problem with "not between" operator on date/time conditions. * Hotfix 20135-01: Fix special message parameter not correctly substituted in *UserURL* notification method. ## Version 3.6 (released) diff --git a/J_ReactorSensor_UI7.js b/J_ReactorSensor_UI7.js index 16586ed..c6beecb 100644 --- a/J_ReactorSensor_UI7.js +++ b/J_ReactorSensor_UI7.js @@ -17,7 +17,7 @@ var ReactorSensor = (function(api, $) { /* unique identifier for this plugin... */ var uuid = '21b5725a-6dcd-11e8-8342-74d4351650de'; - var pluginVersion = '3.6hotfix-20135'; + var pluginVersion = '3.6hotfix-20145'; var DEVINFO_MINSERIAL = 482; @@ -3463,7 +3463,7 @@ div#reactorstatus div.cond.reactor-timing { animation: pulse 2s infinite; } \ }); /* Restore values. */ op = menuSelectDefaultFirst( $( "select.opmenu", container ), cond.operator ); - if ( "bet" === op || "nob" === "op" ) { + if ( "bet" === op || "nob" === op ) { $("fieldset.re-endfields", container).show(); } else { $("fieldset.re-endfields", container).hide(); From 28b76764ed8fb5d36225cf89359d239aeabfd96c Mon Sep 17 00:00:00 2001 From: Patrick Rigney Date: Sun, 24 May 2020 09:12:21 -0400 Subject: [PATCH 3/6] Bump --- J_Reactor_UI7.js | 2 +- L_Reactor.lua | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/J_Reactor_UI7.js b/J_Reactor_UI7.js index d992bf0..cbc5d8b 100644 --- a/J_Reactor_UI7.js +++ b/J_Reactor_UI7.js @@ -17,7 +17,7 @@ var Reactor = (function(api, $) { /* unique identifier for this plugin... */ var uuid = '72acc6ea-f24d-11e8-bd87-74d4351650de'; - var pluginVersion = '3.6hotfix-20135'; + var pluginVersion = '3.6hotfix-20145'; var _UIVERSION = 20130; /* must coincide with Lua core */ diff --git a/L_Reactor.lua b/L_Reactor.lua index bf2d7d1..71794fa 100644 --- a/L_Reactor.lua +++ b/L_Reactor.lua @@ -11,7 +11,7 @@ local debugMode = false local _PLUGIN_ID = 9086 local _PLUGIN_NAME = "Reactor" -local _PLUGIN_VERSION = "3.6hotfix-20135" +local _PLUGIN_VERSION = "3.6hotfix-20145" local _PLUGIN_URL = "https://www.toggledbits.com/reactor" local _DOC_URL = "https://www.toggledbits.com/static/reactor/docs/3.6/" From d70b2d0d5b4433f1ca99520cad73cf1dc6bbaee9 Mon Sep 17 00:00:00 2001 From: Patrick Rigney Date: Sun, 24 May 2020 09:21:35 -0400 Subject: [PATCH 4/6] Formatting fix and bump --- J_ReactorSensor_UI7.js | 2 +- J_Reactor_UI7.js | 2 +- L_Reactor.lua | 5 +++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/J_ReactorSensor_UI7.js b/J_ReactorSensor_UI7.js index c6beecb..476f707 100644 --- a/J_ReactorSensor_UI7.js +++ b/J_ReactorSensor_UI7.js @@ -17,7 +17,7 @@ var ReactorSensor = (function(api, $) { /* unique identifier for this plugin... */ var uuid = '21b5725a-6dcd-11e8-8342-74d4351650de'; - var pluginVersion = '3.6hotfix-20145'; + var pluginVersion = '3.6hotfix-20145.0920'; var DEVINFO_MINSERIAL = 482; diff --git a/J_Reactor_UI7.js b/J_Reactor_UI7.js index cbc5d8b..6f0b964 100644 --- a/J_Reactor_UI7.js +++ b/J_Reactor_UI7.js @@ -17,7 +17,7 @@ var Reactor = (function(api, $) { /* unique identifier for this plugin... */ var uuid = '72acc6ea-f24d-11e8-bd87-74d4351650de'; - var pluginVersion = '3.6hotfix-20145'; + var pluginVersion = '3.6hotfix-20145.0920'; var _UIVERSION = 20130; /* must coincide with Lua core */ diff --git a/L_Reactor.lua b/L_Reactor.lua index 71794fa..bfd0c51 100644 --- a/L_Reactor.lua +++ b/L_Reactor.lua @@ -11,7 +11,7 @@ local debugMode = false local _PLUGIN_ID = 9086 local _PLUGIN_NAME = "Reactor" -local _PLUGIN_VERSION = "3.6hotfix-20145" +local _PLUGIN_VERSION = "3.6hotfix-20145.0920" local _PLUGIN_URL = "https://www.toggledbits.com/reactor" local _DOC_URL = "https://www.toggledbits.com/static/reactor/docs/3.6/" @@ -6014,7 +6014,8 @@ local function getReactorScene( t, s, tdev, runscenes, cf ) if not string.match(":type:method:notifyid:", k) then resp = resp .. string.format("; %s=%q", k, tostring(v)) end - end local mv = { + end + local mv = { SM={"SMTPServer","SMTPPort","SMTPSender","SMTPDefaultRecipient","SMTPDefaultSubject","SMTPUsername","*SMTPPassword"}, PR={"ProwlProvider","ProwlSubject","ProwlURL","*ProwlAPIKey"} } From 055c2d6c735eee3ff95aa0660abf536c487c197f Mon Sep 17 00:00:00 2001 From: Patrick Rigney Date: Wed, 17 Jun 2020 10:16:22 -0400 Subject: [PATCH 5/6] Hotfix 20169-01: Fix state var cleanup for openLuup causing error logged --- CHANGELOG.md | 1 + J_ReactorSensor_UI7.js | 2 +- J_Reactor_UI7.js | 2 +- L_LuaXP_Reactor.lua | 1 + L_Reactor.lua | 9 ++++----- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e7e0cf..9b45fa4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ NOTE TO OPENLUUP USERS: All current versions of Reactor REQUIRE openLuup 2020.04 ## HOTFIXES TO 3.6 RELEASE +* Hotfix 20169-01: For openLuup, fix an error in a background non-critical task that cleans unused state variables from ReactorSensors (e.g. exported expressions that have been deleted). * Hotfix 20145-01: Fix field redraw/reload problem with "not between" operator on date/time conditions. * Hotfix 20135-01: Fix special message parameter not correctly substituted in *UserURL* notification method. diff --git a/J_ReactorSensor_UI7.js b/J_ReactorSensor_UI7.js index 476f707..b54e8bc 100644 --- a/J_ReactorSensor_UI7.js +++ b/J_ReactorSensor_UI7.js @@ -17,7 +17,7 @@ var ReactorSensor = (function(api, $) { /* unique identifier for this plugin... */ var uuid = '21b5725a-6dcd-11e8-8342-74d4351650de'; - var pluginVersion = '3.6hotfix-20145.0920'; + var pluginVersion = '3.6hotfix-20169.1015'; var DEVINFO_MINSERIAL = 482; diff --git a/J_Reactor_UI7.js b/J_Reactor_UI7.js index 6f0b964..95eb518 100644 --- a/J_Reactor_UI7.js +++ b/J_Reactor_UI7.js @@ -17,7 +17,7 @@ var Reactor = (function(api, $) { /* unique identifier for this plugin... */ var uuid = '72acc6ea-f24d-11e8-bd87-74d4351650de'; - var pluginVersion = '3.6hotfix-20145.0920'; + var pluginVersion = '3.6hotfix-20169.1015'; var _UIVERSION = 20130; /* must coincide with Lua core */ diff --git a/L_LuaXP_Reactor.lua b/L_LuaXP_Reactor.lua index 5abda79..b9e3e24 100644 --- a/L_LuaXP_Reactor.lua +++ b/L_LuaXP_Reactor.lua @@ -1122,6 +1122,7 @@ function coerce(val, typ) end elseif isNull(val) then return false -- null coerces to boolean false end + return true -- all other non-null is true elseif typ == "string" then if vt == "number" then return base.tostring(val) elseif vt == "boolean" then return val and "true" or "false" diff --git a/L_Reactor.lua b/L_Reactor.lua index bfd0c51..0efb93b 100644 --- a/L_Reactor.lua +++ b/L_Reactor.lua @@ -11,7 +11,7 @@ local debugMode = false local _PLUGIN_ID = 9086 local _PLUGIN_NAME = "Reactor" -local _PLUGIN_VERSION = "3.6hotfix-20145.0920" +local _PLUGIN_VERSION = "3.6hotfix-20169.1015" local _PLUGIN_URL = "https://www.toggledbits.com/reactor" local _DOC_URL = "https://www.toggledbits.com/static/reactor/docs/3.6/" @@ -4805,16 +4805,15 @@ local function masterTick(pdev) end -- Clean up sensor variables --- TODO: GetState seems to be faster than the request; test and verify, particularly openLuup local function cleanSensorState( tdev, taskid ) D("cleanSensorState(%1,%2)", tdev, taskid) local content - if false and unsafeLua then -- ??? deprecate out if not needed for openLuup + if isOpenLuup then -- openLuup does not (yet) implement GetStatus local sc, httpStatus sc,content,httpStatus = luup.inet.wget( 'http://127.0.0.1:3480/data_request?id=status&DeviceNum='..tdev..'&output_format=json' ) if sc ~= 0 then L({level=2,msg="Failed to complete status request for #%1 (%2, %3)"}, tdev, sc, httpStatus) - content = false + content = nil end end if not content then @@ -4823,7 +4822,7 @@ local function cleanSensorState( tdev, taskid ) if rc ~= 0 or (ra or {}).Status == nil then L({level=2,msg="GetStatus action failed for #%1; rc=%2, ra=%3"}, tdev, rc, ra) end - content = (ra or {}).Status + content = (ra or {}).Status or "" end local data = json.decode( content ) if data and data['Device_Num_'..tdev] then From 1f3bc94b44e8228a47d411650c57ccfaf3626c4a Mon Sep 17 00:00:00 2001 From: Patrick Rigney Date: Fri, 3 Jul 2020 13:12:33 -0400 Subject: [PATCH 6/6] Hotfix 20185-01: Fix crash generating Logic Summary when activity delay uses variable reference. --- CHANGELOG.md | 1 + J_ReactorSensor_UI7.js | 2 +- J_Reactor_UI7.js | 2 +- L_Reactor.lua | 6 +++--- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b45fa4..bd1f539 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ NOTE TO OPENLUUP USERS: All current versions of Reactor REQUIRE openLuup 2020.04 ## HOTFIXES TO 3.6 RELEASE +* Hotfix 20185-01: Fix crash generating Logic Summary when activity delay uses variable reference. * Hotfix 20169-01: For openLuup, fix an error in a background non-critical task that cleans unused state variables from ReactorSensors (e.g. exported expressions that have been deleted). * Hotfix 20145-01: Fix field redraw/reload problem with "not between" operator on date/time conditions. * Hotfix 20135-01: Fix special message parameter not correctly substituted in *UserURL* notification method. diff --git a/J_ReactorSensor_UI7.js b/J_ReactorSensor_UI7.js index b54e8bc..14706ec 100644 --- a/J_ReactorSensor_UI7.js +++ b/J_ReactorSensor_UI7.js @@ -17,7 +17,7 @@ var ReactorSensor = (function(api, $) { /* unique identifier for this plugin... */ var uuid = '21b5725a-6dcd-11e8-8342-74d4351650de'; - var pluginVersion = '3.6hotfix-20169.1015'; + var pluginVersion = '3.6hotfix-20185.1315'; var DEVINFO_MINSERIAL = 482; diff --git a/J_Reactor_UI7.js b/J_Reactor_UI7.js index 95eb518..12723d3 100644 --- a/J_Reactor_UI7.js +++ b/J_Reactor_UI7.js @@ -17,7 +17,7 @@ var Reactor = (function(api, $) { /* unique identifier for this plugin... */ var uuid = '72acc6ea-f24d-11e8-bd87-74d4351650de'; - var pluginVersion = '3.6hotfix-20169.1015'; + var pluginVersion = '3.6hotfix-20185.1315'; var _UIVERSION = 20130; /* must coincide with Lua core */ diff --git a/L_Reactor.lua b/L_Reactor.lua index 0efb93b..05420e4 100644 --- a/L_Reactor.lua +++ b/L_Reactor.lua @@ -11,7 +11,7 @@ local debugMode = false local _PLUGIN_ID = 9086 local _PLUGIN_NAME = "Reactor" -local _PLUGIN_VERSION = "3.6hotfix-20169.1015" +local _PLUGIN_VERSION = "3.6hotfix-20185.1315" local _PLUGIN_URL = "https://www.toggledbits.com/reactor" local _DOC_URL = "https://www.toggledbits.com/static/reactor/docs/3.6/" @@ -5943,7 +5943,7 @@ local function getReactorScene( t, s, tdev, runscenes, cf ) local pfx = " " if s then for _,gr in ipairs( s.groups or {}) do - if (gr.delay or 0) > 0 then + if (gr.delay or "0") ~= "0" then resp = resp .. pfx .. "Delay " .. gr.delay .. " " .. (gr.delaytype or "inline") .. EOL end for _,act in ipairs( gr.actions or {} ) do @@ -6128,7 +6128,7 @@ local function getLuupSceneSummary( scd ) end for ix,gr in ipairs( scd.groups or {} ) do r = r .. string.format( "%sGroup %d", pfx, ix ) - if ( gr.delay or 0 ) > 0 then + if ( gr.delay or "0" ) ~= "0" then r = r .. string.format( " delay %d", gr.delay ) end r = r .. EOL