Complete list of device #s and node IDs

Why not just make a scene that generate the list + open it to the browser. You can run the scene manually as needed.[/quote]

I got the scene created ok, but how to get it to open in a browser tab??

Vera can’t start a process on a remote(Windows) machine by itself. The remote machine’s security should prevent that possibility.

In order to enable such a capability(a BAD idea) you would have to create a listening (web) service on the remote machine that Vera could send a request to. Then the service could start your browser when it sees the request. Again, this is a bad idea!

You’re much better off creating a shortcut on your desktop or a favorite/bookmark in your browser.

Would there be any way to convert this test code into a scene code so that I can trigger to update the devlist from a scene ?

Thanks for your help !

Just add the code from:
http://forum.micasaverde.com/index.php/topic,15010.msg291964.html#msg291964
As the LUA code for a manually triggered scene (available from the Scene Editor: “Also, execute the following Luup code:”)

Then run the scene … you should be able to access the files from the browser:
http://Your.Vera.IP.Address/devlist.txt

Is there a way to revise the following code such that the device list is sorted on device number?

local file = io.open(“/www/devlist.txt”, “w”)
file:write("[DeviceNo / id] device names on " … os.date() … “\n”)
for deviceNo,d in pairs(luup.devices) do
file:write(string.format(‘[%03d / %s] %s \n’, deviceNo, d.id, d.description))
end
file:close()

Yes, of course.

local file = io.open("/www/devlist.txt", "w")
file:write("[DeviceNo / id] device names on " .. os.date() .. "\n")
local idx = {}
for deviceNo in pairs(luup.devices) do
    idx[#idx+1] = deviceNo
end
table.sort (idx)
for _,deviceNo in ipairs(idx) do
    d = luup.devices[deviceNo]
    file:write(string.format('[%03d / %s] %s \n', deviceNo, d.id, d.description))
end
file:close()

Top, thanks a lot!

Does anyone have a version that lists the Z-wave node ID? I think it’s altid when you look in the advanced properties.

I’m trying to find the source of some nonce encryption related errors in my luaupnp log, but it’s referring to the Z-wave ID.

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]