Complete list of device #s and node IDs

This code does just that… the altid is called ID in the luup.devices structure. Just another inconsistency in the Vera Luup saga…

How about an HTML version of the file:

[code]local file = io.open(“/www/devlist.html”, “w”)
file:write(“”)
file:write(“”)
file:write(“”)
file:write(“body {background-color: linen;} table,td,th {border: 1px solid black;} table {width:100%;}”)
file:write(“”)

file:write(“”)
file:write(“”)

file:write(“” … os.date() … “”)
file:write(“”)
file:write(“”)
file:write(“”)

local id = “%03d


local sid = “urn:micasaverde-com:serviceId:EnergyMetering1”
for deviceNo,d in pairs(luup.devices) do
if d.id ~= “” then
local W = luup.variable_get (sid, “Watts”, deviceNo)
local kWh = luup.variable_get (sid, “KWH”, deviceNo)
local ids = id: format (deviceNo, d.id)
file:write(“”)
file:write (info: format(ids, d.description, W or ‘’, kWh or ‘’))
file:write(“”)
end
end

file:write(“

”)
file:write(“
Device Watts kWh
No ID Name
%s”
local info = “
%-20s %-32s %8s %8s
”)
file:write(“”)
file:write(“”)

file:close()
[/code]

then just go to http://Your.Vera.IP.Address/devlist.html

Your solution to the device list issue is much appreciated. However, one issue I still have is that some devices create a host of “phantom” child devices when installed, and they often remain even when the parent is unpaired. Would it be possible to modify the code to show the parent ID of any child devices as well?

any way to sort the device list by device name?

local file = io.open("/etc/cmh-ludl/MyS_Devices2", "w")
--file:write("[DeviceNo / id] device names on " .. os.de() .. "\n")
function noSpace(str)
  local normalisedString = string.gsub(str, "%s+", "")
  return normalisedString
end

function all_trim(s)
	return s:match( "^%s*(.-)%s*$" )
end

for deviceNo,d in pairs(luup.devices) do
    if d.id ~= "" then  
		--dev = all_trim(d.description)
		devnospace = noSpace(all_trim(d.description))
		cleanedstr = devnospace:gsub('%W','')
        file:write(string.format('%s= %01d\n', cleanedstr, deviceNo))
		--file:write(string.format('[%03d / %s] %s \n', deviceNo, d.id, d.description))
    end
end
file:close()

PatioMotion= 513
HomeTheater= 517
HueDiningArea2= 518
HueDiningArea1= 519
HallwayLights= 269
KitchenLights= 20
LivingRoomFanLap= 21

My preferred approach is to pull the user data via curl and pump it through jq to dump the information of interest. I just open a terminal/shell on my PC and run something like the following. It works equally well for scene information.

curl -s "http://10.0.1.200:3480/data_request?id=user_data&output_format=json" | jq -r -c '.devices[] | {device: .id, name: .name, manufacturer: .manufacturer, model: .model, type: .device_type, room: .room, parent: .id_parent}'
{"device":1,"name":"ZWave","manufacturer":null,"model":null,"type":"urn:schemas-micasaverde-com:device:ZWaveNetwork:1","room":null,"parent":null}
{"device":"4","name":"_Scene Controller","manufacturer":"Mi Casa Verde","model":"","type":"urn:schemas-micasaverde-com:device:SceneController:1","room":"0","parent":1}
{"device":"5","name":"Cape Cod Lamp","manufacturer":"Linear","model":"Plug-In Lamp Module (PD300Z-2)","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":"2","parent":1}
{"device":"6","name":"Bucket Light","manufacturer":"","model":"","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":"1","parent":1}
{"device":"7","name":"Overhead Light","manufacturer":"Jasco","model":"45602W","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":"1","parent":1}
{"device":"10","name":"Sound System","manufacturer":"Jasco","model":"45602","type":"urn:schemas-upnp-org:device:BinaryLight:1","room":"1","parent":1}
{"device":"11","name":"Futon Lamp","manufacturer":"Jasco","model":"45602W","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":"2","parent":1}
{"device":"17","name":"Sink Light","manufacturer":"Leviton","model":"","type":"urn:schemas-upnp-org:device:BinaryLight:1","room":"3","parent":1}
{"device":"18","name":"Kitchen Controller","manufacturer":"Leviton","model":"VRCZC","type":"urn:schemas-micasaverde-com:device:SceneControllerLED:1","room":"3","parent":1}
{"device":"24","name":"Tea Pot Lamp","manufacturer":"Jasco","model":"45602W","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":"2","parent":1}
{"device":"25","name":"Back Porch Camera Power","manufacturer":"Jasco","model":"45602","type":"urn:schemas-upnp-org:device:BinaryLight:1","room":"4","parent":1}
{"device":"32","name":"Dining Table Light","manufacturer":"","model":"","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":"2","parent":1}
{"device":"34","name":"Serial_Portlist_2145667974","manufacturer":"","model":"","type":"urn:micasaverde-org:device:SerialPortRoot:1","room":"0","parent":0}
{"device":"35","name":"ftdi_sio","manufacturer":"","model":"","type":"urn:micasaverde-org:device:SerialPort:1","room":"0","parent":34}
{"device":"39","name":"TV","manufacturer":"Aeon","model":"SmartSwitch","type":"urn:schemas-upnp-org:device:BinaryLight:1","room":"1","parent":1}
{"device":"69","name":"Weather Station Console","manufacturer":"Jasco","model":"45602","type":"urn:schemas-upnp-org:device:BinaryLight:1","room":"1","parent":1}
{"device":77,"name":"Zigbee Network","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:ZigbeeNetwork:1","room":"0","parent":0}
{"device":78,"name":"Bluetooth Network","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:BluetoothNetwork:1","room":"0","parent":0}
{"device":79,"name":"Front Door Sensor","manufacturer":"Ecolink","model":"ECO-DW","type":"urn:schemas-micasaverde-com:device:DoorSensor:1","room":"1","parent":1}
{"device":86,"name":"Roadside Cam Power","manufacturer":"Linear","model":"FS20Z-1","type":"urn:schemas-micasaverde-com:device:Relay:1","room":"4","parent":1}
{"device":87,"name":"Lakeside Cam Power","manufacturer":"Linear","model":"FS20Z-1","type":"urn:schemas-micasaverde-com:device:Relay:1","room":"4","parent":1}
{"device":88,"name":"_Scene Controller 1","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:SceneController:1","room":"0","parent":1}
{"device":89,"name":"House Modes Plugin","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:HouseModes:1","room":"4","parent":0}
{"device":90,"name":"Basement Motion","manufacturer":"Aeon","model":"DSB05","type":"urn:schemas-micasaverde-com:device:MotionSensor:1","room":"5","parent":1}
{"device":95,"name":"Door Opener PWR","manufacturer":"","model":"","type":"urn:schemas-upnp-org:device:BinaryLight:1","room":"4","parent":1}
{"device":96,"name":"Overhead Door","manufacturer":"Linear","model":"GD00Z-5","type":"urn:schemas-upnp-org:device:BinaryLight:1","room":"5","parent":1}
{"device":101,"name":"Box Fan","manufacturer":"GE/Jasco","model":"","type":"urn:schemas-upnp-org:device:BinaryLight:1","room":"5","parent":1}
{"device":102,"name":"Pump Room Cam PWR","manufacturer":"","model":"","type":"urn:schemas-upnp-org:device:BinaryLight:1","room":"4","parent":1}
{"device":103,"name":"IT Power Strip [ITS]","manufacturer":"Aeon","model":"AL-DSC11","type":"urn:schemas-upnp-org:device:BinaryLight:1","room":"4","parent":1}
{"device":104,"name":"RPI 3 [ITS 1]","manufacturer":"","model":"","type":"urn:schemas-upnp-org:device:BinaryLight:1","room":4,"parent":103}
{"device":105,"name":"Ambient Weat [ITS 2]","manufacturer":"","model":"","type":"urn:schemas-upnp-org:device:BinaryLight:1","room":4,"parent":103}
{"device":106,"name":"AP Extreme [ITS 3]","manufacturer":"","model":"","type":"urn:schemas-upnp-org:device:BinaryLight:1","room":4,"parent":103}
{"device":107,"name":"ADSL Modem [ITS 4]","manufacturer":"","model":"","type":"urn:schemas-upnp-org:device:BinaryLight:1","room":4,"parent":103}
{"device":109,"name":"Lvng Room Motion","manufacturer":"Ecolink","model":"ECO-PIR","type":"urn:schemas-micasaverde-com:device:MotionSensor:1","room":"1","parent":1}
{"device":110,"name":"Porch Motion","manufacturer":"Ecolink","model":"ECO-PIR","type":"urn:schemas-micasaverde-com:device:MotionSensor:1","room":"2","parent":1}
{"device":112,"name":"Cabinet Lights","manufacturer":"Fibaro","model":"FGRGBWM-441","type":"urn:schemas-upnp-org:device:DimmableRGBLight:2","room":"3","parent":1}
{"device":113,"name":"RGBW Brightness","manufacturer":"","model":"","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":3,"parent":112}
{"device":114,"name":"Under Cabinet Lights","manufacturer":"","model":"","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":3,"parent":112}
{"device":115,"name":"Over Cabinet Lights","manufacturer":"","model":"","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":3,"parent":112}
{"device":116,"name":"RGBW Blue - n/a","manufacturer":"","model":"","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":3,"parent":112}
{"device":117,"name":"RGBW White - n/a","manufacturer":"","model":"","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":3,"parent":112}
{"device":121,"name":"Virtual Outdoor Temperature Sensor","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:VOTS:1","room":"0","parent":0}
{"device":122,"name":"Kitchen Motion","manufacturer":"Ecolink","model":"ECO-PIR","type":"urn:schemas-micasaverde-com:device:MotionSensor:1","room":"3","parent":1}
{"device":134,"name":"Pump Room Motion","manufacturer":"Aeon","model":"DSB05","type":"urn:schemas-micasaverde-com:device:MotionSensor:1","room":"5","parent":1}
{"device":138,"name":"Highland Lake","manufacturer":"","model":"","type":"urn:demo-micasaverde-com:device:weather:1","room":"4","parent":0}
{"device":139,"name":"Outside Temperature","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:TemperatureSensor:1","room":4,"parent":138}
{"device":140,"name":"Low Temperature","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:TemperatureSensor:1","room":4,"parent":138}
{"device":141,"name":"High Temperature","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:TemperatureSensor:1","room":4,"parent":138}
{"device":142,"name":"Outside Humidity","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:HumiditySensor:1","room":4,"parent":138}
{"device":143,"name":"MQTT Client","manufacturer":"","model":"","type":"urn:schemas-sensor-mqtt-se:device:SensorMqtt:1","room":"4","parent":0}
{"device":146,"name":"Luminara Candles","manufacturer":"","model":"","type":"urn:schemas-upnp-org:device:BinaryLight:1","room":"2","parent":0}
{"device":147,"name":"Ambient Weather 1200","manufacturer":"","model":"","type":"urn:schemas-blacey-com:device:AW:1","room":"0","parent":0}
{"device":148,"name":"Inside Temperature","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:TemperatureSensor:1","room":"0","parent":147}
{"device":149,"name":"Outside Humidity 1","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:HumiditySensor:1","room":"0","parent":147}
{"device":150,"name":"Outside Temperature ","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:TemperatureSensor:1","room":"0","parent":147}
{"device":151,"name":"Inside Humidity","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:HumiditySensor:1","room":"0","parent":147}
{"device":152,"name":"Avg Outside Humidity","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:HumiditySensor:1","room":"0","parent":0}
{"device":154,"name":"Dehumidifier","manufacturer":"Aeon","model":"SmartSwitch","type":"urn:schemas-upnp-org:device:BinaryLight:1","room":"5","parent":1}
{"device":156,"name":"AntiqueCabinetUnder","manufacturer":"Fibaro","model":"FGRGBWM-441","type":"urn:schemas-upnp-org:device:DimmableRGBLight:2","room":"3","parent":1}
{"device":157,"name":"Brightness","manufacturer":"","model":"","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":3,"parent":156}
{"device":158,"name":"Antique Under Lights","manufacturer":"","model":"","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":3,"parent":156}
{"device":159,"name":"AUC - Green n/a","manufacturer":"","model":"","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":3,"parent":156}
{"device":160,"name":"AUC - Blue n/a","manufacturer":"","model":"","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":3,"parent":156}
{"device":161,"name":"AUC - White n/a","manufacturer":"","model":"","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":3,"parent":156}
{"device":162,"name":"MySensors Plugin","manufacturer":"","model":"","type":"urn:schemas-arduino-cc:device:arduino:1","room":"4","parent":0}
{"device":163,"name":"SenseBenderMicro 1","manufacturer":"","model":"","type":"urn:schemas-arduino-cc:device:arduinonode:1","room":"5","parent":162}
{"device":164,"name":"SB1 Temp","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:TemperatureSensor:1","room":"5","parent":162}
{"device":165,"name":"SB1 Humid","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:HumiditySensor:1","room":"5","parent":162}
{"device":166,"name":"LR MiniMote","manufacturer":"Aeon","model":"Minimote","type":"urn:schemas-micasaverde-com:device:SceneController:1","room":"1","parent":1}
{"device":167,"name":"BR MiniMote","manufacturer":"Aeon","model":"Minimote","type":"urn:schemas-micasaverde-com:device:SceneController:1","room":"3","parent":1}
{"device":173,"name":"Accent Lamp","manufacturer":"Linear","model":"LB60Z-1","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":"3","parent":1}
{"device":174,"name":"Sofa Lamp","manufacturer":"Linear","model":"LB60Z-1","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":"1","parent":1}
{"device":176,"name":"Shelves Overhead LED","manufacturer":"Linear","model":"LB60Z-1","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":"5","parent":1}
{"device":177,"name":"Breaker Box LED","manufacturer":"Linear","model":"LB60Z-1","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":"5","parent":1}
{"device":178,"name":"Pump Room LED","manufacturer":"Linear","model":"LB60Z-1","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":"5","parent":1}
{"device":179,"name":"Kayaks Overhead LED","manufacturer":"Linear","model":"LB60Z-1","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":"5","parent":1}
{"device":180,"name":"Canoe Overhead LED","manufacturer":"Linear","model":"LB60Z-1","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":"5","parent":1}
{"device":181,"name":"Entry Overhead LED","manufacturer":"Linear","model":"LB60Z-1","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":"5","parent":1}
{"device":182,"name":"Right Rear LED","manufacturer":"Linear","model":"LB60Z-1","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":"5","parent":1}
{"device":183,"name":"Reading Lamp","manufacturer":"Linear","model":"LB60Z-1","type":"urn:schemas-upnp-org:device:DimmableLight:1","room":"1","parent":1}
{"device":188,"name":"Reactor","manufacturer":"","model":"","type":"urn:schemas-toggledbits-com:device:Reactor:1","room":"0","parent":0}
{"device":189,"name":"Climate & Lighting","manufacturer":"","model":"","type":"urn:schemas-toggledbits-com:device:ReactorSensor:1","room":"5","parent":188}
{"device":192,"name":"Basement Audio","manufacturer":"GE/Jasco","model":"","type":"urn:schemas-upnp-org:device:BinaryLight:1","room":"5","parent":1}
{"device":193,"name":"Reactor Internal HMT","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:DoorSensor:1","room":"0","parent":188}
{"device":200,"name":"Basement Temp","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:TemperatureSensor:1","room":5,"parent":90}
{"device":201,"name":"Basement LUX","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:LightSensor:1","room":5,"parent":90}
{"device":202,"name":"Basement Humidity","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:HumiditySensor:1","room":5,"parent":90}
{"device":203,"name":"Pump Room Temp","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:TemperatureSensor:1","room":5,"parent":134}
{"device":204,"name":"Pump Room LUX","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:LightSensor:1","room":5,"parent":134}
{"device":205,"name":"Pump Room Humidity","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:HumiditySensor:1","room":5,"parent":134}
{"device":206,"name":"Night Lights","manufacturer":"","model":"","type":"urn:schemas-toggledbits-com:device:ReactorSensor:1","room":"0","parent":188}
{"device":208,"name":"BroadLink Mk2","manufacturer":"","model":"","type":"urn:schemas-a-lurker-com:device:BroadLink_Mk2:1","room":"0","parent":0}
{"device":209,"name":"RM3 Pro Plus - temperature 1","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:TemperatureSensor:1","room":"0","parent":208}
{"device":210,"name":"RM3 Pro Plus - IR 1","manufacturer":"","model":"","type":"urn:schemas-micasaverde-com:device:IrTransmitter:1","room":"0","parent":208}

nice but my reason is that i have some advanced scripts running that use the device names so
device name= devNo
pretty much from the luup engine loads and stores it then i have a bunch of scenes running custome lua code for eg

luup.log("Starting Hallway Motion")
if (HallwayMotion ~= 472) then
    dofile("/root/SceneScripts/Devices.luup")
end


SS_SID = "urn:micasaverde-com:serviceId:SecuritySensor1" -- Security Sensor Service ID
SD_SID = "urn:upnp-org:serviceId:Dimming1" -- Switch Dimming Service ID
SP_SID = "urn:upnp-org:serviceId:SwitchPower1" -- Switch Power Service ID
PH_SID = "urn:upnp-org:serviceId:althue1"

local ProjectorState= luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", Projector) -- Get Projector State
local hallDimmlvl= luup.variable_get("urn:upnp-org:serviceId:Dimming1", "LoadLevelLast", HueHallway2)
local SwitchState= luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", HallwayLights) -- Get Get Kitchen Light State
local MotionAutomationState= luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", MotionAutomation) -- Get Motion AutomationState
local MotionDetectionState= luup.variable_get("urn:upnp-org:serviceId:SwitchPower1", "Status", MotionDetection) -- Get Motion DetectionState


local hallperiod = 130 -- Seconds
local hallDefDimmlvl = 20 -- Default Dimming Load Level
local hallDimthresh = 30 -- Dimming Threshhold

if (tonumber (hallDefDimmlvl) >= tonumber (hallDimthresh) ) then --Checks the dimming level 
	hallDimmlvl = hallDefDimmlvl
	luup.log("Dim load Level  Dimming Threshold")
end

if (SwitchState ~= "1") then -- Check Switch State
	luup.log("Turn on Lights")
	luup.call_action(SP_SID, "SetTarget", {["newTargetValue"] = 1}, HallwayLights) -- Brighten Turn On Kitchen Lights
end


	if (ProjectorState == "1") then -- Check Projector State

		luup.log("Hallway number 1 load level change")
		luup.call_action(SD_SID, "SetLoadLevelTarget", {newLoadlevelTarget="100"}, HueHallway1) -- Brighten Hallway Number 1
		luup.log("Hallway number 2 load level change")
		luup.call_action(SD_SID, "SetLoadLevelTarget", {newLoadlevelTarget="3"}, HueHallway2) -- Brighten Hallway Number 2
	else
		luup.log("Projector is off Brighten All Lights") -- Projector off
		luup.log("Kitchen number 1 load leve change")
		luup.call_action(SD_SID, "SetLoadLevelTarget", {newLoadlevelTarget="100"}, HueHallway1) -- Brighten Hallway Number 1
		luup.log("Kitchen number 2 load leve change")
		luup.call_action(SD_SID, "SetLoadLevelTarget", {newLoadlevelTarget="100"}, HueHallway2) -- Brighten Hallway Number 2 
	end

function checkLastTripHallway()
    local lastTripmotion = luup.variable_get (SS_SID, "LastTrip", HallwayMotion) --or os.time()
	local Tripstate = luup.variable_get (SS_SID, "Tripped", HallwayMotion)
	local Ostime = os.time()
	local osdifftime = os.difftime (tonumber (os.time()), tonumber (lastTripmotion)) 
	luup.log("Os Time = " .. Ostime .. ", LastTrip = " .. lastTripmotion .. ", Diff = " .. osdifftime .. ", Trip state = " .. Tripstate .. ".")
	if (Tripstate == "0")  then 

		luup.log("Re-dimm the light")
        luup.call_action(SD_SID, "SetLoadLevelTarget", {newLoadlevelTarget= tonumber (HallDimmlvl)}, HueHallway1) -- Re-dimm the light.
		luup.log("Re-dimm the light.")
        luup.call_action(SD_SID, "SetLoadLevelTarget", {newLoadlevelTarget= tonumber (HallDimmlvl)}, HueHallway2) -- Re-dimm the light.
    else
        luup.call_delay ("checkLastTripHallway", hallperiod) -- Check when the sensor was last tripped every <period> seconds.
    end
end


if  ((MotionAutomationState == "1") and (MotionDetectionState == "1")) then  
		luup.call_delay ("checkLastTripHallway", hallperiod)
end

so if the device number updates (which it will bc im constantly adding devices ) all i do is update the device list

Rather a messy bit of code there. Sorting is trivial if you structure things better…

local x = {}
local line = "%s=%d"
for devno,d in pairs (luup.devices) do
  local name = d.description:gsub("%W","")
  x[#x+1] = line:format (name,devno)
end

table.sort (x)

local file = io.open("/etc/cmh-ludl/MyS_Devices2", "w")
if file then 
  file:write(table.concat(x,'\n'))
  file:close()
end

yeah im working on refining my code for the most part, not great at coding but it works

Hey is there a way to parse a room list using this method?

A room list is simply a table (luup.rooms) of room names indexed by room ID.

hey quick question @akbooer how would I do a list of non- Zwave devices

something like this Non - Zwave devices [ 13, 14, 16, 20, 23, 72, 73, 74, 75, 76, 77, 78, 88, 89, 99]

These generally have the ZwaveNetwork as a parent, so look for those with a parent_id attribute of 1.

So I went back to that thread I tried to add scenes and rooms…
I was able to make it work for the scenes but for the rooms I can only get the Room ID, not the name… any idea ? (I know my code is crappy…)

local file = io.open("/www/devlist.html", "w")
file:write("<html>")
file:write("<head>")
file:write("<style>")
file:write("body {background-color: linen;} table,td,th {border: 1px solid black;} table {width:100%;}")
file:write("</style>")

file:write("</head>")
file:write("<body>")

file:write("<table><caption>" .. os.date() .. "</caption>")
file:write("<thead><tr><th colspan='3'>Device</th><th rowspan='2'>Watts</th><th rowspan='2'>kWh</th></tr>")
file:write("<tr><th>No</th><th>ID</th><th>Name</th></tr></thead>")
file:write("<tbody>")

local id = "%03d</td><td>%s"
local info = "<td>%-20s</td><td>%-32s</td><td>%8s</td><td>%8s</td>"
local sid = "urn:micasaverde-com:serviceId:EnergyMetering1"
for deviceNo,d in pairs(luup.devices) do
    if d.id ~= "" then
        local W   = luup.variable_get (sid, "Watts", deviceNo)
        local kWh = luup.variable_get (sid, "KWH", deviceNo)
        local ids = id: format (deviceNo, d.id)
		file:write("<tr>")
        file:write (info: format(ids, d.description, W or '', kWh or ''))
		file:write("</tr>")
	end
end

file:write("</tbody>")
file:write("</table>")
file:write("<br>")

file:write("<table>")
file:write("<thead><tr><th colspan='2'>Scenes</th></tr>")
file:write("<tr><th>ID</th><th>Decription</th></tr></thead>")
file:write("<tbody>")

    for SceneID,d in pairs(luup.scenes) do
	
	file:write("<tr>")
    file:write("<td>", SceneID, "</td><td>", d.description)
	file:write("</tr>")
     end


file:write("</tbody>")
file:write("</table>")
file:write("<br>")


file:write("<table>")
file:write("<thead><tr><th colspan='2'>Rooms</th></tr>")
file:write("<tr><th>ID</th><th>Decription</th></tr></thead>")
file:write("<tbody>")

    for RoomID,e in pairs(luup.rooms) do
	
	file:write("<tr>")
    file:write("<td>", RoomID, "</td><td>", e.??????)
	file:write("</tr>")
     end


file:write("</tbody>")
file:write("</table>")
file:write("</body>")
file:close()

Well, you haven’t got a </td> at the end of the room name…?

The for loop syntax is correct.

I agree for the </td> but I still get an error like :
Runtime error: Line 61: bad argument #4 to ‘write’ (string expected, got nil)

I don’t know what this argument variable should be ? e.description ?
everything I tried returns : bad argument #4 to ‘write’ (string expected, got nil)

any idea ?

Just e, it’s a string, not a table.

Thanks :slight_smile: Working A1 !

I like the output of this code. How do I access the resulting file?

goto http://“your Vera IP address”/devlist.html

1 Like