Post
by pvklink » Sunday 07 July 2019 16:31
Yesss, thank you waaren , it works !! finally!
i struggled with:
- if logcode = 1 or logcode = 3 then
- if logcode <> 2 they did not work...
if logcode ~= 2 then WORKED! i thought that ~ can only be used with strings not numeric
Code: Select all
addMessage =
function(dz, item, info, message, messages,logcode)
local trigger
if item.isDevice then
trigger = ", Device: " .. item.name
elseif item.isTimer then
trigger = ", Timer: " .. item.trigger
elseif item.isVariable then
trigger = ", Variable: " .. item.name
else
trigger = ", Unknown trigger"
end
messages[#messages + 1] = {}
if logcode ~= 2 then
messages[#messages].log = 'scriptname: ' .. info.scriptName .. trigger .. ' ' .. message
end
if logcode ~= 1 then
messages[#messages].text = dz.time.rawDate .. ' ' .. dz.time.rawTime .. ' : ' .. message
--messages[#messages].text = dz.time.rawDate .. ' ' .. dz.time.rawTime .. ' : ' .. message .. '<br>'
end
return messages
end,
dumpMessages =
function(dz, messages)
local textDevice = dz.devices('timerlog')
local currentText = dz.globalData.mylogging
local newText = currentText
local lf = '<br>' --local lf = "\n" --local lf = "\r\n" --PVK \n of \r\n UITGEZET ANDERS werkt dashticz niet
local maxLines = 8
for i, record in ipairs(messages) do
if record.log then dz.log(record.log, dz.LOG_INFO) end
if record.text then newText = record.text .. lf .. newText end
end
dz.log(newText, dz.LOG_INFO)
if newText ~= currentText then
--lines = dz.utils.stringSplit(newText, lf) -- create lines table from newText string --PVK UITGEZET ANDERS werkt dashticz niet
--newText = table.concat(lines, lf, 1, (math.min(maxLines,#lines))) -- recreate newText string from first maxLines --PVK UITGEZET ANDERS werkt dashticz niet
textDevice.updateText(newText)
dz.globalData.mylogging = newText -- ADDED
end
end,
Raspberry (raspbian on rpi 3) , Domoticz Beta, dzVents , RFXtrx433e, P1, Hue, Yeelight, Zwave+, X10, ESP(easy), MQTT,Weather Underground, System Alive Checker, Domoticz Remote Server to RPI with Google Assistant,
Jablotron connection, Ikea