Skip to content

Commit 805fb55

Browse files
devicelist.cgi extended by device_id (#79)
Co-authored-by: Jens Maus <[email protected]>
1 parent c65945b commit 805fb55

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

xmlapi/devicelist.cgi

+15-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ if {[info exists sid] && [check_session $sid]} {
99

1010
set show_internal 0
1111
set show_remote 0
12+
set device_id 0
1213
catch {
1314
set input $env(QUERY_STRING)
1415
set pairs [split $input &]
@@ -21,23 +22,36 @@ if {[info exists sid] && [check_session $sid]} {
2122
set show_remote $val
2223
continue
2324
}
25+
if {0 != [regexp "^device_id=(.*)$" $pair dummy val]} {
26+
set device_id $val
27+
continue
28+
}
2429
}
2530
}
2631

2732
array set res [rega_script {
2833

2934
integer show_internal = "} $show_internal {";
3035
integer show_remote = "} $show_remote {";
36+
string device_id = "} $device_id {";
3137

3238
integer DIR_SENDER = 1;
3339
integer DIR_RECEIVER = 2;
3440
! string TYPE_VIRTUAL = "29";
3541
string PARTNER_INVALID = "65535";
3642

43+
string sDevIdList;
3744
string sDevId;
3845
string sChnId;
3946
string sDPId;
40-
foreach (sDevId, root.Devices().EnumUsedIDs())
47+
48+
if( (device_id == 0) ) {
49+
sDevIdList = root.Devices().EnumUsedIDs();
50+
} else {
51+
sDevIdList = device_id.Split(",");
52+
}
53+
54+
foreach (sDevId, sDevIdList)
4155
{
4256
object oDevice = dom.GetObject(sDevId);
4357
integer iDevInterfaceId = oDevice.Interface();

xmlapi/index.cgi

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ if {[info exists sid] && [check_session $sid]} {
3232
<tr><td><a href=./checkuptodate.cgi?sid=$sid>checkuptodate.cgi</a></td><td>????</td></tr>
3333
<tr><td><a href=./devicelist.cgi?sid=$sid>devicelist.cgi</a></td><td><b>Lists all devices with channels. Contain names, serial number, device type and ids.</b><br/>
3434
<i>sid=string</i> - security access token id<br/>
35+
<i>device_id=list</i> - returns values of specified devices (e.g. "1234,5678") (optional)<br/>
3536
<i>show_internal=0/1</i> - adds internal channels also (default=0)<br/>
3637
<i>show_remote=0/1</i> - adds output of virtual remote channels (default=0)
3738
</td></tr>

0 commit comments

Comments
 (0)