Re: Custom http notification
Posted: Thursday 01 October 2020 13:27
i'm getting
2020-10-01 13:14:21.710 Error: dzVents: Error: (3.0.12) An error occurred when calling event handler test
2020-10-01 13:14:21.710 Error: dzVents: Error: (3.0.12) ...moticz/scripts/dzVents/generated_scripts/global_data.lua:21: attempt to concatenate a table value (local 'cmd')
Code: Select all
return
{
logging = {
level = domoticz.LOG_DEBUG,
marker = "Global"
},
-- global helper functions
helpers = {
join = function(dz, command, title)
local function logWrite(str,level)
dz.log(tostring(str),level or dz.LOG_DEBUG)
end
local function osCommand(cmd)
dz.log('Executing Command: ' .. cmd,dz.LOG_DEBUG)
local fileHandle = assert(io.popen(cmd))
local commandOutput = assert(fileHandle:read('*a'))
local returnTable = {fileHandle:close()}
dz.log('ReturnCode: ' .. returnTable[3] .. '\ncommandOutput:\n' .. commandOutput, dz.LOG_DEBUG)
return commandOutput,returnTable[3] -- rc[3] contains returnCode
end
logWrite("Command " .. command .. "Title" .. title)
icon = "&icon=https://raw.githubusercontent.com/domoticz/domoticz/master/www/images/logo.png"
JoinPassword = dz.variables('JoinPassword').value
JoinEmail = dz.variables('JoinEmail').value
JoinKey = "apikey=" .. dz.variables('JoinKey').value
JoinURL = "https://joinjoaomgcd.appspot.com/_ah/api/messaging/v1/sendPush?"
if string.match(command, "=:=") then
message = "&deviceId=group.android"
else
returnTitle, returnCode = osCommand(dz, 'perl /opt/join/joincli.pl \"' .. JoinPassword .. ';' .. JoinEmail .. ';' .. title .. '\"')
message = "&title=" .. returnTitle .. icon .. "&deviceId=group.all"
end
returnMessage, returnCode = osCommand(dz, 'perl /opt/join/joincli.pl \"' .. JoinPassword .. ';' .. JoinEmail .. ';' .. command .. '\"')
if returnCode then
logWrite(returnCode)
return
end
message = message .. "&text=" .. returnMessage
dz.openurl( JoinURL .. JoinKey .. message )
end
}
}