Skip to content

Commit 3464467

Browse files
committed
added interface ise id check to devicelist.cgi, mastervalue.cgi,
mastervaluechange.cgi, state.cgi and statelist.cgi. This refs #68.
1 parent 8a2112a commit 3464467

File tree

5 files changed

+69
-48
lines changed

5 files changed

+69
-48
lines changed

xmlapi/devicelist.cgi

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,15 @@ if {[info exists sid] && [check_session $sid]} {
4040
foreach (sDevId, root.Devices().EnumUsedIDs())
4141
{
4242
object oDevice = dom.GetObject(sDevId);
43+
integer iDevInterfaceId = oDevice.Interface();
44+
object oDeviceInterface = dom.GetObject(iDevInterfaceId);
45+
4346
boolean bDevReady = oDevice.ReadyConfig();
4447
boolean isRemote = ( ("HMW-RCV-50" == oDevice.HssType()) || ("HM-RCV-50" == oDevice.HssType()) || ("HmIP-RCV-50" == oDevice.HssType()) );
4548

46-
if( (true == bDevReady) && ( ( isRemote == false ) || ( show_remote == 1 ) ) )
49+
if( (oDeviceInterface) && (true == bDevReady) && ( ( isRemote == false ) || ( show_remote == 1 ) ) )
4750
{
48-
string sDevInterfaceId = oDevice.Interface();
49-
string sDevInterface = dom.GetObject(sDevInterfaceId).Name();
51+
string sDevInterface = oDeviceInterface.Name();
5052
string sDevType = oDevice.HssType();
5153

5254
Write("<device");

xmlapi/mastervalue.cgi

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,17 +41,22 @@ if {[info exists sid] && [check_session $sid]} {
4141
integer iseId = "} $devid {";
4242
var oDevice = dom.GetObject(iseId);
4343
var address = oDevice.Address();
44-
string deviceInterface = (dom.GetObject(oDevice.Interface())).Name();
45-
var deviceType = oDevice.HssType();
46-
Write("<device");
47-
Write(" name='");
48-
WriteXML(oDevice.Name());
49-
Write("'");
50-
Write(" ise_id='" # iseId # "'");
51-
Write(" device_type='");
52-
WriteXML(deviceType);
53-
Write("'");
54-
Write(" >");
44+
integer ifId = oDevice.Interface();
45+
object oDeviceInterface = dom.GetObject(ifId);
46+
if(oDeviceInterface)
47+
{
48+
string deviceInterface = oDeviceInterface.Name();
49+
var deviceType = oDevice.HssType();
50+
Write("<device");
51+
Write(" name='");
52+
WriteXML(oDevice.Name());
53+
Write("'");
54+
Write(" ise_id='" # iseId # "'");
55+
Write(" device_type='");
56+
WriteXML(deviceType);
57+
Write("'");
58+
Write(" >");
59+
}
5560
}]
5661
set deviceAddress $values(address)
5762
set deviceType $values(deviceType)

xmlapi/mastervaluechange.cgi

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,42 +48,54 @@ if {[info exists sid] && [check_session $sid]} {
4848
integer iseId = "} $devid {";
4949
var oDevice = dom.GetObject(iseId);
5050
var address = oDevice.Address();
51-
string deviceInterface = (dom.GetObject(oDevice.Interface())).Name();
52-
var deviceType = oDevice.HssType();
53-
Write("<device");
54-
Write(" name='");
55-
WriteXML(oDevice.Name());
56-
Write("'");
57-
Write(" ise_id='" # iseId # "'");
58-
Write(" device_type='");
59-
WriteXML(deviceType);
60-
Write("'");
61-
Write(" >");
51+
integer ifId = oDevice.Interface();
52+
object oDeviceInterface = dom.GetObject(ifId);
53+
if(oDeviceInterface)
54+
{
55+
string deviceInterface = oDeviceInterface.Name();
56+
var deviceType = oDevice.HssType();
57+
Write("<device");
58+
Write(" name='");
59+
WriteXML(oDevice.Name());
60+
Write("'");
61+
Write(" ise_id='" # iseId # "'");
62+
Write(" device_type='");
63+
WriteXML(deviceType);
64+
Write("'");
65+
Write(" >");
66+
}
6267
}]
6368
set deviceAddress $values(address)
6469
set deviceType $values(deviceType)
6570
set deviceInterface $values(deviceInterface)
6671

6772
puts -nonewline $values(STDOUT)
6873

69-
# initialize variable, could fail in catch block below
70-
set channel ""
71-
if {[string compare -nocase -length 4 "HmIP" "$deviceInterface"] == 0 ||
72-
[string compare -nocase -length 4 "HmIP" "$deviceType"] == 0 } {
73-
# HmIP requires to add :0 to deviceAddress
74-
set channel ":0"
75-
}
74+
# simple check against unknown device id
75+
if { $deviceType == "null" } {
76+
puts -nonewline {<device ise_id="}
77+
puts -nonewline $devid
78+
puts -nonewline {" error="true">DEVICE NOT FOUND</device>}
79+
} else {
80+
# initialize variable, could fail in catch block below
81+
set channel ""
82+
if {[string compare -nocase -length 4 "HmIP" "$deviceInterface"] == 0 ||
83+
[string compare -nocase -length 4 "HmIP" "$deviceType"] == 0 } {
84+
# HmIP requires to add :0 to deviceAddress
85+
set channel ":0"
86+
}
7687

77-
# call xmlrpc to set the MASTER paramset
78-
set ausgabe ""
79-
catch {set ausgabe [xmlrpc $interfaces($deviceInterface) putParamset [list string "$deviceAddress$channel"] [list string "MASTER"] [list struct $cmd] ] }
88+
# call xmlrpc to set the MASTER paramset
89+
set ausgabe ""
90+
catch {set ausgabe [xmlrpc $interfaces($deviceInterface) putParamset [list string "$deviceAddress$channel"] [list string "MASTER"] [list struct $cmd] ] }
8091

81-
puts -nonewline {<mastervalue name='}
82-
puts -nonewline $item
83-
puts -nonewline {' value='}
84-
puts -nonewline $val
85-
puts -nonewline {'/>}
86-
puts -nonewline {</device>}
92+
puts -nonewline {<mastervalue name='}
93+
puts -nonewline $item
94+
puts -nonewline {' value='}
95+
puts -nonewline $val
96+
puts -nonewline {'/>}
97+
puts -nonewline {</device>}
98+
}
8799
}
88100
} else {
89101
puts -nonewline {<not_authenticated/>}

xmlapi/state.cgi

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,15 @@ if {[info exists sid] && [check_session $sid]} {
7272
foreach(sDevId, sDevIds.Split(",")) {
7373

7474
object oDevice = dom.GetObject(sDevId);
75+
integer iDevInterfaceId = oDevice.Interface();
76+
object oDeviceInterface = dom.GetObject(iDevInterfaceId);
7577

76-
if(oDevice.ReadyConfig() && (oDevice.Name() != "Zentrale") && (oDevice.Name() != "HMW-RCV-50 BidCoS-Wir") && oDevice.IsTypeOf(OT_DEVICE)) {
78+
if( (oDeviceInterface) && (oDevice.ReadyConfig()) && (oDevice.Name() != "Zentrale") && (oDevice.Name() != "HMW-RCV-50 BidCoS-Wir") && (oDevice.IsTypeOf(OT_DEVICE)) ) {
7779
Write("<device");
7880
Write(" name='" # oDevice.Name() # "'");
7981
Write(" ise_id='" # sDevId # "'");
8082

81-
string interfaceid = oDevice.Interface();
82-
string servicechan = "" # dom.GetObject(interfaceid).Name() #"."#oDevice.Address()#":0";
83+
string servicechan = "" # oDeviceInterface.Name() #"."#oDevice.Address()#":0";
8384
object schan = dom.GetObject(servicechan#".UNREACH");
8485
if(schan) { Write(" unreach='" # schan.Value() #"'"); }
8586
object schan = dom.GetObject(servicechan#".STICKY_UNREACH");
@@ -137,4 +138,4 @@ if {[info exists sid] && [check_session $sid]} {
137138
} else {
138139
puts -nonewline {<not_authenticated/>}
139140
}
140-
puts "</state>"
141+
puts "</state>"

xmlapi/statelist.cgi

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,17 +69,18 @@ if {[info exists sid] && [check_session $sid]} {
6969
foreach (sDevId, root.Devices().EnumUsedIDs())
7070
{
7171
object oDevice = dom.GetObject(sDevId);
72+
integer iDevInterfaceId = oDevice.Interface();
73+
object oDeviceInterface = dom.GetObject(iDevInterfaceId)
7274

7375
boolean isRemote = ( ("HMW-RCV-50" == oDevice.HssType()) || ("HM-RCV-50" == oDevice.HssType()) || ("HmIP-RCV-50" == oDevice.HssType()) );
7476

75-
if( oDevice.ReadyConfig() && ( ( isRemote == false ) || ( show_remote == 1 ) ) )
77+
if( ( oDeviceInterface ) && ( oDevice.ReadyConfig() ) && ( ( isRemote == false ) || ( show_remote == 1 ) ) )
7678
{
7779
Write("<device");
7880
Write(" name='" # oDevice.Name() # "'");
7981
Write(" ise_id='" # sDevId # "'");
8082

81-
string interfaceid = oDevice.Interface();
82-
string servicechan = "" # dom.GetObject(interfaceid).Name() #"."#oDevice.Address()#":0";
83+
string servicechan = "" # oDeviceInterface.Name() #"."#oDevice.Address()#":0";
8384
object schan = dom.GetObject(servicechan#".UNREACH");
8485
if(schan) { Write(" unreach='" # schan.Value() #"'"); }
8586
object schan = dom.GetObject(servicechan#".STICKY_UNREACH");

0 commit comments

Comments
 (0)