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:
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
}
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.
Why would you want that csv/Excel file on a regular base?
If it is just for one time copy the contents of page Setup - Devices with old fashioned select copy/paste into an Excel file.
Or open a recent database backup with sqlite browser and copy the contents of the device tables.
Another alternative is to use an API call for all devices and paste the resulting json in an Excel.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
I used the JSON API call '/json.htm?type=command¶m=getdevices&displayhidden=1'. In the wiki it also contains '&used=true' but if you add that it will filter out all unused devices. If you add '&used=false' it filters out all used devices. If you omit it, it does not filter and gives all devices. I converted the json file with an online converter to a csv file.