Skip to content

Commit 30eab4f

Browse files
authored
Merge pull request #3799 from rwaaren/development
Update dzVents to V2.5.3 (add triggerHTTPResponse and long runtime warnings)
2 parents af55de6 + e39d750 commit 30eab4f

File tree

13 files changed

+743
-658
lines changed

13 files changed

+743
-658
lines changed

History.txt

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
Version 4.xxxxx (xxx 2019)
1+
Version 4.1xxxx (xxx 20xx) see https://www.domoticz.com/wiki/Domoticz_versions_-_Commits for details
22
- Implemented: DarkSky CloudCover sensor
33
- Implemented: EventSystem, option in Settings to enable/disable URL call logging containing full URL path
44
- Implemented: Floorplan, add support for SVG
55
- Implemented: GUI, OpenZWave added Refresh Node Information button, styling
6+
- Implemented: Hue, Add Support for Geo fence sensor, dimmer switches and Hue LCG002 GU10 spot
67
- Implemented: RTL433, added Power (Watt) type
78
- Implemented: RTL433, added rainfall_mm type
89
- Implemented: OZW, JSON call to retrieve current battery levels for all nodes
@@ -12,7 +13,9 @@ Version 4.xxxxx (xxx 2019)
1213
- Implemented: OZW, Support for Volatile_Organic_Compound (CO2, ppm)
1314
- Implemented: BuienRadar
1415
- Implemented: Sun/Rain icons
15-
- Fixed: Gui, Choosing Icon for ARC type switches
16+
- Implemented: Add support for Belgian and Luxembourgian P1 meters
17+
- Fixed: API, allow variabletype to be entered as text or integer in adduservariable and updateuservariable (#3320)
18+
- Fixed: GUI, Choosing Icon for ARC type switches
1619
- Fixed: GUI, Dashboard icon incremental counter (energy generated) not correct (#3231)
1720
- Fixed: GUI, device table initial order column
1821
- Fixed: GUI, Switch Log, date parsing in device log (#3206)
@@ -22,11 +25,16 @@ Version 4.xxxxx (xxx 2019)
2225
- Fixed: GUI, Weight Log now displays correct Unit (#3211)
2326
- Fixed: GUI, OpenZWave Abort Include/Exclude button
2427
- Fixed: Blockly, handling incorrect time field
25-
- Fixed: YouLess, possible buffer overflow (#3261)
26-
- Fixed: notification, Telegram error when odd number of underscores in text
27-
- Fixed: API, allow variabletype to be entered as text or integer in adduservariable and updateuservariable (#3320)
28+
- Fixed: Youless, possible buffer overflow (#3261)
29+
- Fixed: Evohome Web for updated library
30+
- Fixed: Telegram notification when odd number of underscores in text
31+
- Fixed: PhilipsHue
32+
- Updated: Translations
33+
- Updated: Update domoticz script now running directly in background
34+
- Updated: Mosquitto to 1.68
2835
- Updated: OpenZWave version 1.6
29-
- Updated: dzVents (version 2.5.2 for Lua 5.3) See dzVents/documentation/history.md)
36+
- Updated: Lua version 5.3
37+
- Updated: dzVents version 2.5.3 ( https://www.domoticz.com/wiki/DzVents:_next_generation_LUA_scripting )
3038

3139
Version 4.10717 (May 9th 2019)
3240
- Fixed: dzVents, Allowing no error message for HTTP calls (#3191)

dzVents/documentation/README.md

Lines changed: 246 additions & 222 deletions
Large diffs are not rendered by default.

dzVents/documentation/README.wiki

Lines changed: 425 additions & 402 deletions
Large diffs are not rendered by default.

dzVents/documentation/history.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
[2.5.3]
2+
- Add timealert / errors for long running scripts
3+
- Add triggerHTTPResponse()
4+
15
[2.5.2]
26
- Add actualWatt to replace WhActual (left in WhActual for compatibility reasons)
37
- Add toBase64 and fromBase64 function in utils

dzVents/runtime/Domoticz.lua

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,6 +321,20 @@ local function Domoticz(settings)
321321
end
322322
end
323323

324+
function self.triggerHTTPResponse(httpResponse, delay, message)
325+
local httpResponse = httpResponse or _G.moduleLabel
326+
local delay = delay or 0
327+
local message = 'triggerHTTPResponse: ' .. (message or httpResponse)
328+
local url = self.settings['Domoticz url'] .. '/json.htm?type=command&param=addlogmessage&message=' .. self.utils.urlEncode(message)
329+
self.openURL
330+
(
331+
{
332+
url = url,
333+
callback = httpResponse,
334+
}
335+
).afterSec(delay)
336+
end
337+
324338
-- have domoticz send snapshot
325339
function self.snapshot(cameraID, subject)
326340
if tostring(cameraID):match("%a") then

dzVents/runtime/EventHelpers.lua

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ local function EventHelpers(domoticz, mainMethod)
2929
local _url = 'http://127.0.0.1:' .. (tostring(globalvariables['domoticz_listening_port']) or "8080")
3030

3131
local settings = {
32-
['Log level'] = tonumber(globalvariables['dzVents_log_level']) or 1,
32+
['Log level'] = tonumber(globalvariables['dzVents_log_level']) or 1,
3333
['Domoticz url'] = _url,
3434
url = url,
3535
webRoot = tostring(webRoot),
@@ -392,10 +392,19 @@ local function EventHelpers(domoticz, mainMethod)
392392
end
393393

394394
triggerInfo = eventHandler.trigger and ', trigger: ' .. eventHandler.trigger or ''
395-
396-
utils.log('------ Start ' .. scriptType .. moduleLabel ..':' .. moduleLabelInfo .. triggerInfo, utils.LOG_MODULE_EXEC_INFO)
395+
local clockTimeStampAtStart = os.clock()
396+
local timeStampAtStart = os.time()
397+
utils.log('------ Start ' .. scriptType .. moduleLabel ..':' .. moduleLabelInfo .. triggerInfo, utils.LOG_MODULE_EXEC_INFO)
397398
self.callEventHandler(eventHandler, device, variable, security, scenegroup, httpResponse)
398-
utils.log('------ Finished ' .. moduleLabel, utils.LOG_MODULE_EXEC_INFO)
399+
local clockTimeSpend = os.clock() - clockTimeStampAtStart
400+
local realTimeSpend = os.time() - timeStampAtStart
401+
if realTimeSpend > 9 or clockTimeSpend > 7 then
402+
utils.log('------ Finished ' .. moduleLabel .. ' after >' .. realTimeSpend .. ' seconds. (using '.. tostring(clockTimeSpend):sub(1,5) .. ' seconds CPU time !)' , utils.LOG_ERROR)
403+
elseif realTimeSpend > 6 or clockTimeSpend > 5 then
404+
utils.log('------ Finished ' .. moduleLabel .. ' after >' .. realTimeSpend .. ' seconds. (using '.. tostring(clockTimeSpend):sub(1,5) .. ' seconds CPU time !)' , utils.LOG_FORCE)
405+
else
406+
utils.log('------ Finished ' .. moduleLabel , utils.LOG_MODULE_EXEC_INFO)
407+
end
399408

400409
restoreLogging()
401410
end

dzVents/runtime/Utils.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ local self = {
88
LOG_MODULE_EXEC_INFO = 2,
99
LOG_INFO = 3,
1010
LOG_DEBUG = 4,
11-
DZVERSION = '2.5.2',
11+
DZVERSION = '2.5.3',
1212
}
1313

1414
function math.pow(x, y)

dzVents/runtime/integration-tests/httpResponseScript.lua

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ end
2525
return {
2626
on = {
2727
devices = { 'vdHTTPSwitch' },
28-
httpResponses = {'trigger1', 'trigger2','trigger3'}
28+
httpResponses = {'trigger1', 'trigger2','trigger3', 'vdHTTPSwitch'}
2929
},
3030
execute = function(domoticz, item)
3131

@@ -61,9 +61,15 @@ return {
6161
res = res and expectEql(item.statusCode, 6, 'statusCode')
6262
if (res) then domoticz.globalData.httpTrigger = domoticz.globalData.httpTrigger .. "OK" end
6363

64+
elseif (item.callback == 'vdHTTPSwitch') then
65+
res = res and expectEql(item.statusCode, 200, 'statusCode')
66+
if (res) then domoticz.globalData.httpTrigger = domoticz.globalData.httpTrigger .. "OK" end
67+
6468
end
6569

6670
elseif item.isDevice then
71+
domoticz.triggerHTTPResponse(item.name, 4, item.state )
72+
6773
domoticz.openURL({
6874
url = 'http://localhost:4000/testget?p=1',
6975
method = 'GET',

dzVents/runtime/integration-tests/stage2.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -780,7 +780,7 @@ end
780780
local testHTTPSwitch = function(name)
781781
local res = true
782782
local trigger = dz.globalData.httpTrigger
783-
res = res and expectEql('OKOKOK', trigger)
783+
res = res and expectEql('OKOKOKOK', trigger)
784784
handleResult('Test http trigger switch device', res)
785785
return res
786786
end

dzVents/runtime/misc/testdzVents.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ function fillTimes
133133
function fillNumberOfTests
134134
{
135135
Device_ExpectedTests=113
136-
Domoticz_ExpectedTests=70
136+
Domoticz_ExpectedTests=71
137137
EventHelpers_ExpectedTests=32
138138
EventHelpersStorage_ExpectedTests=50
139139
HTTPResponse_ExpectedTests=6

0 commit comments

Comments
 (0)