MQTT Discovery: get Hardware ID
Posted: Saturday 02 April 2022 9:35
Is there any direct way to get the Hardware ID for MQTT Discovery devices with DzVents in order to get the idx (I didn't find the field in DzVents)
I'm currently do it by SQL but maybe not the best way...
The use case is to get the Idx from the MQTT topic (zwavejs2mqtt -> mqtt -> NodeRED -> MQTT -> Dz)
I'm doing this
(p_id = 'zwavejs2mqtt_0xe236465e_11-37-0-currentValue' for instance)
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