use IDX with devicechanged and/or otherdevices

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.
Post Reply
tillo
Posts: 7
Joined: Monday 01 May 2017 20:15
Target OS: -
Domoticz version:
Contact:

use IDX with devicechanged and/or otherdevices

Post by tillo » Tuesday 12 September 2017 8:40

Is it possible to get the device status (On, Off, Open, Closed and so on) from just the IDX value? Insted of using the name of the device?

I have searched the forum and google, and have not found any answer. I know how to to update a device status using 'IDX|X|State' eg. '52|0|Off'
But not how to get te current device status using only the IDX number.

User avatar
lonebaggie
Posts: 79
Joined: Tuesday 31 January 2017 14:21
Target OS: Raspberry Pi
Domoticz version: beta
Location: England
Contact:

Re: use IDX with devicechanged and/or otherdevices

Post by lonebaggie » Tuesday 12 September 2017 18:40

I cannot claim any credit for this function, I found it somewhere on this site, but it returns the switch name from IDX number

function idxname(deviceIDX)
local idx = tonumber(deviceIDX)
for i, v in pairs(otherdevices_idx) do
if v == idx then
return i
end
end
return 0
end

tillo
Posts: 7
Joined: Monday 01 May 2017 20:15
Target OS: -
Domoticz version:
Contact:

Re: use IDX with devicechanged and/or otherdevices

Post by tillo » Wednesday 13 September 2017 9:12

i did stumble on this approach aswell in the forum, it would be nice to see a more efficient way of doing it.

Dose dzVents offer some better solution to this?

Code: Select all

function idxname(deviceIDX)
local idx = tonumber(deviceIDX)
for i, v in pairs(otherdevices_idx) do
	if v == idx then
		return i
	end
end
return 0
end

dannybloe
Posts: 884
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi
Domoticz version:
Location: Ermelo
Contact:

Re: use IDX with devicechanged and/or otherdevices

Post by dannybloe » Wednesday 13 September 2017 19:55

Of course it does! It's trivial with dzVents!
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.

Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests