jpr105 wrote: ↑Wednesday 07 April 2021 18:31
s it possible to know HOW my electrovalve has been activated?
Not natively but below script (using sqlite3 to access the domoticz database) will show you the last actor of the device.
Code: Select all
--[[
triggerinfo.lua
requires: sqlite3
dzVents >= 3.0.13
domoticz >= V2020.2 build 12693
]]
return
{
on =
{
devices =
{
'myDevice', -- Change to device you need to monitor
'eventTrigger',
},
},
logging =
{
level = domoticz.LOG_DEBUG, -- change to domoticz.LOG_ERROR when script is tested and OK
marker = 'getActor',
},
execute = function(dz, item)
local function getLightingLogData(id)
local _,rc = dz.utils.osCommand('which sqlite3')
if rc == 0 then
local cmd = 'sudo sqlite3 -list -noheader domoticz.db "SELECT DeviceRowID ID, User, Date FROM LightingLog WHERE DeviceRowID = ' .. id .. ' ORDER BY Date DESC LIMIT 1;" '
return dz.utils.osCommand(cmd)
else
dz.log('sqlite3 not available. Please make sure it is installed (sudo apt install sqlite3) and accessible', dz.LOG_ERROR)
end
end
-- main
if item.active then
local lightingLogLine = getLightingLogData(item.id)
if lightingLogLine:find('|') then
local lightingLogLineTable = dz.utils.stringSplit( getLightingLogData(item.id) ,'|')
local user = lightingLogLineTable[2]
local modTime = lightingLogLineTable[3]
dz.log( 'user: '.. user .. ' triggered me at ' .. modTime,dz.LOG_FORCE)
else
dz.log( 'No data in LightingLog for device ' .. item.name,dz.LOG_DEBUG)
end
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>>
dzVents wiki