I’ve found a few articles scattered about that may cover this but wanted to get a few thoughts on this idea.
Having to refer to devices by their id number is the usual way to do things and can sometimes lead to errors when there are many devices. More so if you have to replace a faulty device and go through all of your coding to search and replace that device number with the modified value.
Could we delcare a variable in the startup code that references a value and therefore any future modfications can be quick and easy besides giving a more meaningful name to a device.
example:
replace this code within a scene or wherever…
--get virtual switch state
local VirtualSwitchState = luup.variable_get("urn:upnp-org:serviceId:VSwitch1", "Status", 30)
with the following
--get virtual switch state
local VirtualSwitchState = luup.variable_get("urn:upnp-org:serviceId:VSwitch1", "Status", Dev_PorchLight)
and insert into the startup code:
Dev_PorchLight=30 --textual representation of device number
dont think i need to declare it as “global Dev_PorchLight=30” as it will be global by default because its in the startup code?
Could anyone advance on this suggestion or comment if this is not advisable in anyway, please?
thanks