@@ -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/>}
0 commit comments