Skip to content

Commit 3ba2736

Browse files
ultrahjens-maus
andauthored
Unify behaviour regarding virtual remotes and add query parameter (#11)
Previously devicelist.cgi and statelist.cgi handled virtual remotes differently. devicelist.cgi ommited these channels based on the type of the device, statelist.cgi used the name of the device to achieve the same, which yielded inconsitent behaviour. Now the device type is used in both scripts. This breaks the possiblity to receive the workaround to receive the virtual remote in statelist.cgi by renaming the device. Therefore this also adds a query parameter show_remote to both scripts to reliably receive the virtual remote channels. Co-authored-by: Jens Maus <[email protected]>
1 parent 64efb62 commit 3ba2736

File tree

3 files changed

+26
-8
lines changed

3 files changed

+26
-8
lines changed

xmlapi/devicelist.cgi

+13-5
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,27 @@ puts -nonewline "<?xml version='1.0' encoding='ISO-8859-1' ?><deviceList>"
77

88
if {[info exists sid] && [check_session $sid]} {
99

10-
set show_internal ""
10+
set show_internal 0
11+
set show_remote 0
1112
catch {
1213
set input $env(QUERY_STRING)
1314
set pairs [split $input &]
1415
foreach pair $pairs {
1516
if {0 != [regexp "^show_internal=(.*)$" $pair dummy val]} {
1617
set show_internal $val
17-
break
18+
continue
19+
}
20+
if {0 != [regexp "^show_remote=(.*)$" $pair dummy val]} {
21+
set show_remote $val
22+
continue
1823
}
1924
}
2025
}
2126

2227
array set res [rega_script {
2328

24-
string show_internal = "} $show_internal {";
29+
integer show_internal = "} $show_internal {";
30+
integer show_remote = "} $show_remote {";
2531

2632
integer DIR_SENDER = 1;
2733
integer DIR_RECEIVER = 2;
@@ -35,7 +41,9 @@ if {[info exists sid] && [check_session $sid]} {
3541
{
3642
object oDevice = dom.GetObject(sDevId);
3743
boolean bDevReady = oDevice.ReadyConfig();
38-
if( (true == bDevReady) && ("HMW-RCV-50" != oDevice.HssType()) && ("HM-RCV-50" != oDevice.HssType()) )
44+
boolean isRemote = ( ("HMW-RCV-50" == oDevice.HssType()) || ("HM-RCV-50" == oDevice.HssType() ) );
45+
46+
if( (true == bDevReady) && ( ( isRemote == false ) || ( show_remote == 1 ) ) )
3947
{
4048
string sDevInterfaceId = oDevice.Interface();
4149
string sDevInterface = dom.GetObject(sDevInterfaceId).Name();
@@ -60,7 +68,7 @@ if {[info exists sid] && [check_session $sid]} {
6068
show = true;
6169
}
6270

63-
if ( show_internal == "1"){
71+
if ( show_internal == 1){
6472
show = true;
6573
}
6674

xmlapi/index.cgi

+4-2
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ 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>show_internal=0/1</i> - adds internal channels also (default=0)
35+
<i>show_internal=0/1</i> - adds internal channels also (default=0)<br/>
36+
<i>show_remote=0/1</i> - adds output of virtual remote channels (default=0)
3637
</td></tr>
3738
<tr><td><a href=./devicetypelist.cgi?sid=$sid>devicetypelist.cgi</a></td><td><b>Lists all possible device types with their possible meta data.</b><br/>
3839
<i>sid=string</i> - security access token id<br/>
@@ -101,7 +102,8 @@ if {[info exists sid] && [check_session $sid]} {
101102
<tr><td><a href=./statelist.cgi?sid=$sid>statelist.cgi</a></td><td><b>Outputs all devices with channels and their current values.</b><br/>
102103
<i>sid=string</i> - security access token id<br/>
103104
<i>ise_id=int</i> - output only channels and values of device with specified id (e.g. "1234")<br/>
104-
<i>show_internal=0/1</i> - adds internal channels also (default=0)
105+
<i>show_internal=0/1</i> - adds internal channels also (default=0)<br/>
106+
<i>show_remote=0/1</i> - adds output of virtual remote channels (default=0)
105107
</td></tr>
106108
<tr><td><a href=./systemNotification.cgi?sid=$sid>systemNotification.cgi</a></td><td><b>Outputs the currently existing system notifications.</b><br/>
107109
<i>sid=string</i> - security access token id<br/>

xmlapi/statelist.cgi

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

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

2732
set comm "var ise_id=$ise_id;\n"
2833
append comm "var show_internal=$show_internal;\n"
34+
append comm "var show_remote=$show_remote;\n"
2935

3036
if { $ise_id != 0 } then {
3137

@@ -64,7 +70,9 @@ if {[info exists sid] && [check_session $sid]} {
6470
{
6571
object oDevice = dom.GetObject(sDevId);
6672

67-
if( oDevice.ReadyConfig() && (oDevice.Name() != "Zentrale") && (oDevice.Name() != "HMW-RCV-50 BidCoS-Wir") )
73+
boolean isRemote = ( ("HMW-RCV-50" == oDevice.HssType()) || ("HM-RCV-50" == oDevice.HssType() ) );
74+
75+
if( oDevice.ReadyConfig() && ( ( isRemote == false ) || ( show_remote == 1 ) ) )
6876
{
6977
Write("<device");
7078
Write(" name='" # oDevice.Name() # "'");

0 commit comments

Comments
 (0)