Skip to content

Commit 04959c0

Browse files
committed
more debug info
1 parent 78cdf12 commit 04959c0

File tree

8 files changed

+38
-23
lines changed

8 files changed

+38
-23
lines changed

scripts/dzVents/runtime/Device.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ local function Device(domoticz, data, dummyLogger)
4646
local adapters = adapterManager.getDeviceAdapters(self)
4747

4848
for i, adapter in pairs(adapters) do
49-
utils.log('Processing adapter for ' .. self.name .. ': ' .. adapter.name, utils.LOG_DEBUG)
49+
utils.log('Processing device-adapter for ' .. self.name .. ': ' .. adapter.name, utils.LOG_DEBUG)
5050
adapter.process(self, data, domoticz, utils, adapterManager)
5151
end
5252

scripts/dzVents/runtime/Domoticz.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ local function Domoticz(settings)
199199
-- have domoticz send an email
200200
function self.email(subject, message, mailTo)
201201
if (mailTo == nil) then
202-
utils.log('No mail to is provide', utils.LOG_DEBUG)
202+
utils.log('No mail-to is provided', utils.LOG_ERROR)
203203
else
204204
if (subject == nil) then subject = '' end
205205
if (message == nil) then message = '' end

scripts/dzVents/runtime/EventHelpers.lua

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -264,18 +264,8 @@ local function EventHelpers(domoticz, mainMethod)
264264

265265
function self.processTimeRuleFunction(fn)
266266

267-
-- _G.domoticz = {
268-
-- ['LOG_INFO'] = utils.LOG_INFO,
269-
-- ['LOG_MODULE_EXEC_INFO'] = utils.LOG_MODULE_EXEC_INFO,
270-
-- ['LOG_DEBUG'] = utils.LOG_DEBUG,
271-
-- ['LOG_ERROR'] = utils.LOG_ERROR,
272-
-- ['log'] = self.domoticz.log
273-
-- }
274-
275267
local ok, res = pcall(fn, self.domoticz)
276268

277-
-- _G.domoticz = nil
278-
279269
if (not ok) then
280270
utils.log('Error executing custom timer function.', utils.LOG_ERROR)
281271
utils.log(res, utils.LOG_ERROR)

scripts/dzVents/runtime/TimedCommand.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ local function TimedCommand(domoticz, name, value)
3737

3838
local sCommand = table.concat(command, " ")
3939

40-
utils.log('Constructed command: ' .. sCommand, utils.LOG_DEBUG)
40+
utils.log('Constructed timed-command: ' .. sCommand, utils.LOG_DEBUG)
4141

4242
return sCommand
4343
end

scripts/dzVents/runtime/device-adapters/Adapters.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ local function DeviceAdapters(dummyLogger)
6666
if (adapter.baseType == device.baseType) then
6767
local matches = adapter.matches(device, self)
6868
if (matches) then
69-
utils.log('Adapter found for ' .. device.name .. ': ' .. adapter.name, utils.LOG_DEBUG)
69+
utils.log('Device-adapter found for ' .. device.name .. ': ' .. adapter.name, utils.LOG_DEBUG)
7070
table.insert(adapters, adapter)
7171
end
7272
end

scripts/dzVents/runtime/dzVents.lua

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,18 @@ package.path = package.path .. ';' .. currentPath .. 'data/?.lua'
1515

1616
local EventHelpers = require('EventHelpers')
1717
local helpers = EventHelpers()
18+
local utils = require('Utils')
1819

19-
--local persistence = require('persistence')
20-
--if (_G.TESTMODE == nil) then
21-
-- persistence.store(currentPath .. '/domoticzData.lua', domoticzData)
22-
--end
20+
if (tonumber(globalvariables['dzVents_log_level']) == utils.LOG_DEBUG) then
21+
utils.log('Dumping domoticz data to ' .. currentPath .. '/domoticzData.lua', utils.LOG_DEBUG)
22+
local persistence = require('persistence')
23+
persistence.store(currentPath .. '/domoticzData.lua', domoticzData)
24+
end
2325

2426
commandArray = {}
2527

28+
utils.log('Event trigger type: ' .. triggerReason, utils.LOG_DEBUG)
29+
2630
if triggerReason == "time" then
2731
commandArray = helpers.dispatchTimerEventsToScripts()
2832
elseif triggerReason == "device" then
@@ -32,7 +36,7 @@ elseif triggerReason == "uservariable" then
3236
elseif triggerReason == 'security' then
3337
commandArray = helpers.dispatchSecurityEventsToScripts()
3438
else
35-
print ("Unknown trigger: ", triggerReason)
39+
utils.log("Unknown trigger: ", triggerReason, utils.LOG_DEBUG)
3640
end
3741

3842
return commandArray

scripts/dzVents/runtime/tests/testDevice.lua

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,31 @@ describe('device', function()
330330
assert.is_same({ { ["UpdateDevice"] = "1|44" } }, commandArray)
331331
end)
332332

333+
it('should detect a security device', function()
334+
local device = getDevice(domoticz, {
335+
['name'] = 'myDevice',
336+
['type'] = 'Security',
337+
['subType'] = 'Security Panel'
338+
})
339+
340+
device.disarm()
341+
342+
assert.is_same({ { ['myDevice'] = 'Disarm' } }, commandArray)
343+
344+
commandArray = {}
345+
346+
device.armAway()
347+
348+
assert.is_same({ { ['myDevice'] = 'Arm Away' } }, commandArray)
349+
350+
commandArray = {}
351+
352+
device.armHome()
353+
354+
assert.is_same({ { ['myDevice'] = 'Arm Home' } }, commandArray)
355+
356+
end)
357+
333358
describe('dummy methods', function()
334359

335360
it('should set dummy methods', function()

scripts/dzVents/runtime/todo.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@
44

55
*co2 device?
66

7-
* define function for all device methods with a warning
8-
* debug info in each adapater inside the matches
9-
* check all places for debug info
10-
* create domoticzdata dump when in debug mode
117

128
changes:
139
counterToday > number

0 commit comments

Comments
 (0)