Inventory of devices
Posted: Wednesday 08 January 2025 22:21
Hi,
I want to make a csv file with an inventory of all devices in Domoticz. I wrote a dzVents script that finds all devices that are shown (used) on the tabs but not the ones that are hidden (unused) from the tabs:
How can I get the complete list of all devices, used or not used? A complete approach to get a csv file is also good.
Peter
I want to make a csv file with an inventory of all devices in Domoticz. I wrote a dzVents script that finds all devices that are shown (used) on the tabs but not the ones that are hidden (unused) from the tabs:
Code: Select all
return {
active = true, -- Activeer het script
on = {
timer = { 'every minute' } -- Voer het script elk uur uit (of pas dit naar wens aan)
},
execute = function(domoticz)
-- Bestandspad waar de CSV wordt opgeslagen
-- Open het bestand voor schrijven
local file = io.open("/mnt/documents/Domoticz/apparaten.csv", "a+")
if file then
-- Schrijf de header van het CSV-bestand
file:write('DeviceID;Name;Type;Hardware\n')
-- Doorloop alle apparaten in Domoticz
for i = 1, 250 do
-- Haal apparaatdetails op
if domoticz.utils.deviceExists(i) then
local device = domoticz.devices(i)
local deviceID = device.id
local name = device.name
local deviceType = device.deviceType
local hardware = device.hardwareName
-- Schrijf de gegevens naar het CSV-bestand
local s = deviceID .. ';' .. name ..';'.. deviceType ..';'.. hardware ..';'..'\n'
file:write(s)
end
end
-- Sluit het bestand
file:close()
end
end
}
Peter