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
Use IDX instead of device name in LUA ?
Moderator: leecollings
-
- Posts: 69
- Joined: Sunday 08 June 2014 20:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Toulouse France
- Contact:
Use IDX instead of device name in LUA ?
domoticz on Raspberry Pi + RFXcom LAN moded + wifi
Blyss / DI.O / homemade / ESP / wemos
Blyss / DI.O / homemade / ESP / wemos
-
- Posts: 69
- Joined: Sunday 08 June 2014 20:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Toulouse France
- Contact:
Re: Use IDX instead of device name in LUA ?
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
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
domoticz on Raspberry Pi + RFXcom LAN moded + wifi
Blyss / DI.O / homemade / ESP / wemos
Blyss / DI.O / homemade / ESP / wemos
- sisaenkov
- Posts: 50
- Joined: Friday 27 May 2016 7:21
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.8
- Location: Moscow, Russia
- Contact:
Re: Use IDX instead of device name in LUA ?
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
- McMelloW
- Posts: 434
- Joined: Monday 20 November 2017 17:01
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V2024.1
- Location: Harderwijk, NL
- Contact:
Re: Use IDX instead of device name in LUA ?
Try to use dzVents for Lua and idx for devices as well. See this wiki page http://www.domoticz.com/wiki/DzVents:_n ... _scripting.
Greetings McMelloW
Who is online
Users browsing this forum: No registered users and 1 guest