I think there is an other option
I've have a script in Dzventz which reads the log file for errors.
This script can detect a Somfy error so i can update the Hardware by Disable and then Enable ?
Code: Select all
local scriptVersion = 'Versie 1.01'
scriptVar = "-=# Domoticz ErrorLog #=-"
return
{
on = {
httpResponses = { scriptVar,},
timer = {"every 10 minutes"},
devices = {502},
},
logging = {
level = domoticz.LOG_INFO,
marker = scriptVar,
},
data = {
lastlogtime =
{
initial = 0
}
},
execute = function(dz, item)
local searchStr = 'Error: Somfy Tahoma' -- Change to reflect the messages you want to catch
local ignoreStrings = -- Enter all strings to be ignored in this table
{
'CheckAuthToken',
}
local function trueError(str)
for _, ignore in ipairs(ignoreStrings) do
if str:find(ignore) then return false end
end
return true
end
local function askDomoticzForLogLines()
local lastLogTime = dz.data.lastlogtime -- get time last logrequest
local logLevel = 4 -- loglevel (1=normal,2=Status,4=error,268435455=all
local jsonString = "/json.htm?type=command" .. "¶m=getlog" .. "&lastlogtime=" .. tostring(lastLogTime) .. "&loglevel=" .. tostring(logLevel)
dz.openURL(
{
url = dz.settings["Domoticz url"] .. jsonString,
callback = scriptVar
})
dz.data.lastlogtime = os.time() -- store current Time as seconds from epoch
end
local function findString()
if item.json.result then -- Only when there are errormessages in the log
local rt = item.json.result
for i = #rt, 1, -1 do -- traverse backwards to get latest violation first
local msg = rt[i].message
if msg:find('%s%s' .. searchStr) and trueError(msg) then return msg end
end
end
end
if item.isDevice or item.isTimer then
askDomoticzForLogLines() -- get the relevant loglines
elseif item.json then
--dz.log("Show ALL: \n" .. item.data,dz.LOG_INFO)
local line = findString()
if line then
dz.log("Log " .. searchStr .. " found! ",dz.LOG_INFO)
dz.openURL({url = 'http://192.168.1.234:9200/json.htm?type=command¶m=updatehardware&htype=94&name=Somfy%20Tahoma&enabled=false&idx=8&port=0&loglevel=7&Mode6=Normal&datatimeout=0&extra=tahomaIO&loglevel=268435455&username=xxxxxxxxx&password=xxxxxxxx3',
method = 'POST',}
)
dz.openURL({url = 'http://192.168.1.234:9200/json.htm?type=command¶m=updatehardware&htype=94&name=Somfy%20Tahoma&enabled=true&idx=8&port=0&loglevel=7&Mode6=Normal&datatimeout=0&extra=tahomaIO&loglevel=268435455&username=xxxxxxxxx&password=xxxxxxxx',
method = 'POST',}
)
dz.notify("Log " .. line .. " found! ",dz.PRIORITY_HIGH)
else
dz.log("No (new) occurrences of string " .. searchStr .. " in the domoticz log ",dz.LOG_INFO)
end
else
dz.log("Access problem to log. Data found: " .. item.data,dz.LOG_ERROR)
end
end
}
The problem now is that the to OpenURL commands are to quick after each other.
IS it possible to get a delay between them ?
-= HP server GEN11 =- OZW -=- Toon2 (rooted) -=- Domoticz v2025.1 -=- Dashticz v3.14b on Tab8" =-