Hi there,
I use zwave TRV valves for my heating and sometimes they fail and need excluding and re-adding. When I write to them I use their IDX, which I store in a variable. If a valve is removed then I put 999 in the variable which stops the code from executing for that valve.
So, i re-add the valve and put the new IDX in the variable.
But, when I look at the current setting of the valve at the moment I use the name. What I'd like to do is look at the IDX for this, then I don't have to add/name the device into the GUI.
At the moment I use valve=tonumber(otherdevices_svalues["Set_"..zoneName])
I'd like to use valve=tonumber(otherdevices_svalues[idx])
The IDX comes from idx=tostring(uservariables["valve_idx_"..zoneName])
I can't work out how to do this.
IDX in LUA (read)
Moderator: leecollings
- jvdz
- Posts: 2269
- Joined: Tuesday 30 December 2014 19:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 4.107
- Location: Netherlands
- Contact:
Re: IDX in LUA (read)
There is an otherdevices_idx[] table available to return the IDX for a DeviceName.
The other way around be accomplished by something like this:
Jos
The other way around be accomplished by something like this:
Code: Select all
function getdevname4idx(deviceIDX)
for i, v in pairs(otherdevices_idx) do
if v == deviceIDX then
return i
end
end
return 0
end
commandArray[getdevname4idx(123)] = 'Off'
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Who is online
Users browsing this forum: No registered users and 1 guest