The use case is to get the Idx from the MQTT topic (zwavejs2mqtt -> mqtt -> NodeRED -> MQTT -> Dz)
I'm doing this
Code: Select all
local function selectTableDeviceStatus (p_id)
local _,rc = _u.osCommand('which sqlite3')
if rc == 0 then
local f_cmd, f_result
f_cmd = 'sudo sqlite3 -list -noheader domoticz.db "SELECT ID FROM DeviceStatus WHERE HardwareID = 31 and Used = 1 and Type = 244 and DeviceID LIKE \'' .. p_id .. '%\' ;" '
f_result = _u.osCommand(f_cmd)
--logWrite(f_cmd)
--logWrite(f_result)
f_result = tonumber(f_result)
if f_result == nil then
logWrite('selectTableDeviceStatus ' .. p_id .. ' no DeviceID', dz.LOG_ERROR)
return -1
else
logWrite('selectTableDeviceStatus ' .. p_id .. ' ' .. f_result, dz.LOG_DEBUG)
return f_result
end
else
logWrite(p_table .. ' sqlite3 not available. Please make sure it is installed (sudo apt install sqlite3) and accessible', dz.LOG_ERROR)
return -1
end
end