Page 1 of 1

Use IDX instead of device name in LUA ?

Posted: Sunday 06 August 2017 15:26
by sebitop
Hi all

simple question as i'm struggling to find a clear info.

i would like to check a device using it's idx instead of it's name, is it possible in LUA ?

otherwise is it possible to assign the name of a device to a variable and use this variable in the script instead of repeating the device name ?

idea is just to avoid many changes when i change the name of a device.

thnaks !

seb

Re: Use IDX instead of device name in LUA ?

Posted: Sunday 06 August 2017 15:52
by sebitop
I found part of the answer

one idea is to set a local var with your device name

local variable = "name of the device"

then you can use commandArray[variable]='On' for exmaple to whitch on your device

Re: Use IDX instead of device name in LUA ?

Posted: Sunday 06 August 2017 19:24
by sisaenkov
Try this:

Code: Select all

commandArray = {}

function getdevname4idx(deviceIDX)
   for i, v in pairs(otherdevices_idx) do
      if v == deviceIDX then
         return i
      end
   end
   return 0
end
commandArray[getdevname4idx(383)] = 'On'

return commandArray

Re: Use IDX instead of device name in LUA ?

Posted: Friday 29 December 2017 15:02
by papoo
thanks sisaenkov

Re: Use IDX instead of device name in LUA ?

Posted: Friday 29 December 2017 15:36
by McMelloW
Try to use dzVents for Lua and idx for devices as well. See this wiki page http://www.domoticz.com/wiki/DzVents:_n ... _scripting.