"
21 |
22 | set filename "/www/addons/xmlapi/VERSION"
23 | set fd [open $filename r]
24 | set version ""
25 | if { $fd >=0 } {
26 | gets $fd version
27 | close $fd
28 | }
29 |
30 | puts [subst {
31 | XML-API $version |
32 | checkuptodate.cgi | ???? |
33 | devicelist.cgi | Lists all devices with channels. Contain names, serial number, device type and ids.
34 | sid=string - security access token id
35 | device_id=list - returns values of specified devices (e.g. "1234,5678") (optional)
36 | show_internal=0/1 - adds internal channels also (default=0)
37 | show_remote=0/1 - adds output of virtual remote channels (default=0)
38 | |
39 | devicetypelist.cgi | Lists all possible device types with their possible meta data.
40 | sid=string - security access token id
41 | |
42 | exec.cgi | Allows to execute arbitrary ReGaHss script commands (as POST data).
43 | sid=string - security access token id
44 | |
45 | favoritelist.cgi | Lists all favorites and users.
46 | sid=string - security access token id
47 | show_datapoint=0/1 - outputs datapoint_id and datapoint_type also (default=0)
48 | show_internal=0/1 - adds internal channels also (default=0)
49 | |
50 | functionlist.cgi | Lists all functions including channels.
51 | sid=string - security access token id
52 | |
53 | mastervalue.cgi | Outputs a single or several '1234,5678' devices with their names and master values.
54 | sid=string - security access token id
55 | device_id=list - returns master values of specified devices (e.g. "1234,5678")
56 | requested_names=list - returns only master values of selected types (e.g. "TEMPERATURE_COMFORT,TEMPERATURE_LOWERING")
57 | |
58 | mastervaluechange.cgi | Sets one or more master values for a list of devices.
59 | sid=string - security access token id
60 | device_id=list - sets master values of specified devices (e.g. "1234,5678")
61 | name=list - sets only master values of selected types (e.g. "TEMPERATURE_LOWERING,TEMPERATURE_COMFORT")
62 | value=list - sets master values to specified values (e.g. "17.0,22.5")
63 | |
64 | programactions.cgi | Allows to change active and visible program options.
65 | sid=string - security access token id
66 | program_id=int - id of program to modify (e.g. "1234")
67 | active=true/false - sets active status of program to true/false
68 | visible=true/false - sets visible status of program to true/false
69 | |
70 | programlist.cgi | Lists all programs.
71 | sid=string - security access token id
72 | |
73 | protocol.cgi | Outputs the system protocol.
74 | sid=string - security access token id
75 | start=int - start of the protocol
76 | show=int - number of entries to output
77 | clear=0/1 - allows to clear the system protocol
78 | |
79 | roomlist.cgi | Lists all configured rooms including channels.
80 | sid=string - security access token id
81 | |
82 | rssilist.cgi | Lists RSSI values of all RF devices.
83 | sid=string - security access token id
84 | |
85 | runprogram.cgi | Starts a program with the specified id.
86 | sid=string - security access token id
87 | program_id=int - id of program to modify (e.g. "1234")
88 | cond_check=0/1 - execute program with normal condition checks or not (only first "then" is executed) (default=0)
89 | |
90 | scripterrors.cgi | Searches for the last 10 lines in /var/log/messages containing script runtime errors and outputs them.
91 | sid=string - security access token id
92 | |
93 | state.cgi | Outputs one or more devices with their channels and current values.
94 | sid=string - security access token id
95 | device_id=list - returns values of specified devices (e.g. "1234,5678")
96 | channel_id=list - returns values of specified channels (e.g. "1234,5678")
97 | datapoint_id=list - returns Value() for datapoint with id (e.g. "1234,5678")
98 | |
99 | statechange.cgi | Allows to change the state of one or more devices.
100 | sid=string - security access token id
101 | ise_id=list - selects the devices with the specified ids (e.g. "1234,5678")
102 | new_value=list - new values for device states (e.g. "0.20,1.45")
103 | |
104 | statelist.cgi | Outputs all devices with channels and their current values.
105 | sid=string - security access token id
106 | ise_id=int - output only channels and values of device with specified id (e.g. "1234")
107 | show_internal=0/1 - adds internal channels also (default=0)
108 | show_remote=0/1 - adds output of virtual remote channels (default=0)
109 | |
110 | systemNotification.cgi | Outputs the currently existing system notifications.
111 | sid=string - security access token id
112 | |
113 | systemNotificationClear.cgi | Clears the current active system notifications (if not sticky).
114 | sid=string - security access token id
115 | |
116 | sysvar.cgi | Outputs a single system variable with its corresponding values.
117 | sid=string - security access token id
118 | ise_id=int - the id of the system variable to output (e.g. "1234")
119 | text=true/false - outputs or suppressed the text for string variables (default=true)
120 | |
121 | sysvarlist.cgi | Outputs all system variables with their corresponding values.
122 | sid=string - security access token id
123 | text=true/false - outputs or suppressed the text for string variables (default=false)
124 | |
125 | tokenlist.cgi | Lists all registered security access tokens
126 | sid=string - security access token id
127 | |
128 | tokenregister.cgi | Registers a new security access token
129 | sid=string - security access token id
130 | desc=string - description for new token id
131 | |
132 | tokenrevoke.cgi | Revokes an existing security access token
133 | sid=string - security access token id
134 | |
135 | update.cgi | ???
136 | sid=string - security access token id
137 | checkupdate=list - ???
138 | maxdurchlaeufe=int - ??? (default=7)
139 | |
140 | version.cgi | Outputs version of XML-API.
141 | |
142 | }]
143 | } else {
144 | puts "not authenticated"
145 | }
146 | puts ""
147 | puts ""
148 |
--------------------------------------------------------------------------------
/xmlapi/mastervalue.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | load tclrpc.so
3 | source session.tcl
4 | source common.tcl
5 |
6 | puts "Content-Type: text/xml; charset=iso-8859-1"
7 | puts ""
8 | puts -nonewline ""
9 |
10 | if {[info exists sid] && [check_session $sid]} {
11 |
12 | set device_id ""
13 | set requested_names ""
14 | catch {
15 | set input $env(QUERY_STRING)
16 | set pairs [split $input &]
17 | foreach pair $pairs {
18 | if {0 != [regexp "^device_id=(.*)$" $pair dummy val]} {
19 | set device_id $val
20 | continue
21 | }
22 | if {0 != [regexp "^requested_names=(.*)$" $pair dummy val]} {
23 | set requested_names $val
24 | continue
25 | }
26 | }
27 | }
28 |
29 | read_interfaces
30 |
31 | set devids [split $device_id ,]
32 | if { $requested_names == "" } {
33 | set allMasterValues "*"
34 | } else {
35 | set allMasterValues ""
36 | set requestedNames [split $requested_names ,]
37 | }
38 |
39 | foreach devid $devids {
40 | array set values [rega_script {
41 | integer iseId = "} $devid {";
42 | var oDevice = dom.GetObject(iseId);
43 | var address = oDevice.Address();
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("");
59 | }
60 | }]
61 | set deviceAddress $values(address)
62 | set deviceType $values(deviceType)
63 | set deviceInterface $values(deviceInterface)
64 |
65 | puts -nonewline $values(STDOUT)
66 |
67 | # simple check against unknown device id
68 | if { $deviceType == "null" } {
69 | puts -nonewline {DEVICE NOT FOUND}
72 | } else {
73 | # initialize variable, could fail in catch block below
74 | set channel ""
75 | if {[string compare -nocase -length 4 "HmIP" "$deviceInterface"] == 0 ||
76 | [string compare -nocase -length 4 "HmIP" "$deviceType"] == 0 } {
77 | # HmIP requires to add :0 to deviceAddress
78 | set channel ":0"
79 | }
80 |
81 | # call xmlrpc to get the MASTER paramset
82 | set ausgabe ""
83 | catch {set ausgabe [xmlrpc $interfaces($deviceInterface) getParamset [list string "$deviceAddress$channel"] [list string "MASTER"] ] }
84 |
85 | foreach { bezeichnung wert } $ausgabe {
86 | if { ($allMasterValues == "*" || [lsearch $requestedNames $bezeichnung] >= 0) } {
87 | puts -nonewline {}
92 | }
93 | }
94 |
95 | puts -nonewline {}
96 | }
97 | }
98 | } else {
99 | puts -nonewline {}
100 | }
101 | puts ""
102 |
--------------------------------------------------------------------------------
/xmlapi/mastervaluechange.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | load tclrpc.so
3 | source session.tcl
4 | source common.tcl
5 |
6 | puts "Content-Type: text/xml; charset=iso-8859-1"
7 | puts ""
8 | puts -nonewline ""
9 |
10 | if {[info exists sid] && [check_session $sid]} {
11 |
12 | set device_id ""
13 | set name ""
14 | set value ""
15 | catch {
16 | set input $env(QUERY_STRING)
17 | set pairs [split $input &]
18 | foreach pair $pairs {
19 | if {0 != [regexp "^device_id=(.*)$" $pair dummy val]} {
20 | set device_id $val
21 | continue
22 | }
23 | if {0 != [regexp "^name=(.*)$" $pair dummy val]} {
24 | set name $val
25 | continue
26 | }
27 | if {0 != [regexp "^value=(.*)$" $pair dummy val]} {
28 | set value $val
29 | continue
30 | }
31 | }
32 | }
33 |
34 | read_interfaces
35 |
36 | set rec_devids [split $device_id "\,"]
37 | set rec_mvaluename [split $name "\,"]
38 | set rec_mvaluevalue [split $value "\,"]
39 |
40 | for {set counter 0} {$counter<[llength $rec_devids]} {incr counter} {
41 | set devid [lindex $rec_devids $counter]
42 |
43 | set item [lindex $rec_mvaluename $counter]
44 | set val [lindex $rec_mvaluevalue $counter]
45 | set cmd "{$item {string $val}}"
46 |
47 | array set values [rega_script {
48 | integer iseId = "} $devid {";
49 | var oDevice = dom.GetObject(iseId);
50 | var address = oDevice.Address();
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("");
66 | }
67 | }]
68 | set deviceAddress $values(address)
69 | set deviceType $values(deviceType)
70 | set deviceInterface $values(deviceInterface)
71 |
72 | puts -nonewline $values(STDOUT)
73 |
74 | # simple check against unknown device id
75 | if { $deviceType == "null" } {
76 | puts -nonewline {DEVICE NOT FOUND}
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 | }
87 |
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] ] }
91 |
92 | puts -nonewline {}
97 | puts -nonewline {}
98 | }
99 | }
100 | } else {
101 | puts -nonewline {}
102 | }
103 | puts ""
104 |
--------------------------------------------------------------------------------
/xmlapi/once.tcl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/homematic-community/XML-API/d13c53f7850388bcffc5e3bc26f3f6145ef96be3/xmlapi/once.tcl
--------------------------------------------------------------------------------
/xmlapi/programactions.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | source session.tcl
3 |
4 | puts "Content-Type: text/xml; charset=iso-8859-1"
5 | puts ""
6 | puts -nonewline ""
7 |
8 | if {[info exists sid] && [check_session $sid]} {
9 |
10 | set program_id "-1"
11 | set active ""
12 | set visible ""
13 | catch {
14 | set input $env(QUERY_STRING)
15 | set pairs [split $input &]
16 | foreach pair $pairs {
17 | if {0 != [regexp "^program_id=(.*)$" $pair dummy val]} {
18 | set program_id $val
19 | continue
20 | }
21 | if {0 != [regexp "^active=(.*)$" $pair dummy val]} {
22 | set active $val
23 | continue
24 | }
25 | if {0 != [regexp "^visible=(.*)$" $pair dummy val]} {
26 | set visible $val
27 | continue
28 | }
29 | }
30 | }
31 |
32 | array set res [rega_script {
33 | integer prgId = } $program_id {;
34 | string active = "} $active {";
35 | string visible = "} $visible {";
36 | if (prgId > 0) {
37 | object obj = dom.GetObject(prgId);
38 | if (obj && obj.IsTypeOf(OT_PROGRAM)) {
39 | if ((active == "false") || (active == "true")){
40 | obj.Active(active == "true");
41 | }
42 | if ((visible == "false") || (visible == "true")){
43 | obj.Visible(visible == "true");
44 | }
45 | Write(obj);
46 | }
47 | }
48 | }]
49 |
50 | if { $res(STDOUT) != "" } {
51 | puts -nonewline ""
52 | } else {
53 | puts -nonewline {}
54 | }
55 | } else {
56 | puts -nonewline {}
57 | }
58 | puts ""
59 |
--------------------------------------------------------------------------------
/xmlapi/programlist.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | source session.tcl
3 |
4 | puts "Content-Type: text/xml; charset=iso-8859-1"
5 | puts ""
6 | puts -nonewline ""
7 |
8 | if {[info exists sid] && [check_session $sid]} {
9 |
10 | array set res [rega_script {
11 |
12 | string sProgramId;
13 | object oProgram;
14 | foreach (sProgramId, dom.GetObject(ID_PROGRAMS).EnumUsedIDs())
15 | {
16 | oProgram = dom.GetObject(sProgramId);
17 | if(oProgram != null)
18 | {
19 | Write("");
37 | }
38 | }
39 |
40 | }]
41 |
42 | if { $res(STDOUT) != "" } {
43 | puts -nonewline $res(STDOUT)
44 | }
45 | } else {
46 | puts -nonewline {}
47 | }
48 | puts ""
49 |
--------------------------------------------------------------------------------
/xmlapi/protocol.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | source session.tcl
3 |
4 | puts "Content-Type: text/xml; charset=iso-8859-1"
5 | puts ""
6 | puts -nonewline ""
7 |
8 | if {[info exists sid] && [check_session $sid]} {
9 |
10 | set start "0"
11 | set show "0"
12 | set clear "0"
13 | catch {
14 | set input $env(QUERY_STRING)
15 | set pairs [split $input &]
16 | foreach pair $pairs {
17 | if {0 != [regexp "^start=(.*)$" $pair dummy val]} {
18 | set start $val
19 | continue
20 | }
21 | if {0 != [regexp "^show=(.*)$" $pair dummy val]} {
22 | set show $val
23 | continue
24 | }
25 | if {0 != [regexp "^clear=(.*)$" $pair dummy val]} {
26 | set clear $val
27 | continue
28 | }
29 | }
30 | }
31 |
32 | set hm_script {
33 | integer iLastGroupIndex = 1;
34 | string sCollectedNames = "";
35 | string sCollectedValues = "";
36 | string sCollectedDateTimes = "";
37 | string sCollectedTimestamp = "";
38 | string s;
39 | integer iStart = }
40 |
41 | append hm_script $start
42 |
43 | append hm_script {;
44 | integer iCount = }
45 |
46 | append hm_script $show
47 |
48 | append hm_script {;
49 | integer eCount = dom.GetHistoryDataCount();
50 | integer clear = }
51 |
52 | append hm_script $clear
53 |
54 | append hm_script {;
55 | integer rCount;
56 | if (iCount == "0") {
57 | iCount = eCount;
58 | }
59 | Write("");
64 | }
65 |
66 | append hm_script {
67 |
68 | if (clear == "1") {
69 | var clearHistory = dom.ClearHistoryData();
70 | WriteLine("");
71 | } else {
72 |
73 | foreach( s, dom.GetHistoryData( iStart, iCount, &rCount ) )
74 | {
75 | integer iGroupIndex = s.StrValueByIndex(";",0).ToInteger();
76 | string sDatapointId = s.StrValueByIndex(";",1);
77 | string sRecordedValue = s.StrValueByIndex(";",2);
78 | string sDateTime = s.StrValueByIndex(";",3);
79 | string sTimestamp = s.StrValueByIndex(";",3).ToTime().ToInteger();
80 | string sDatapointName = "";
81 | object oHistDP = dom.GetObject( sDatapointId );
82 | if( oHistDP )
83 | {
84 | object oDP = dom.GetObject( oHistDP.ArchiveDP() );
85 | if( oDP )
86 | {
87 | sDatapointName = oDP.Name();
88 | boolean bSysVar = (oDP.IsTypeOf(OT_VARDP) || oDP.IsTypeOf(OT_ALARMDP));
89 | if( !bSysVar )
90 | {
91 | object oCH = dom.GetObject( oDP.Channel() );
92 | if( oCH )
93 | {
94 | sDatapointName = oCH.Name();
95 | }
96 | }
97 |
98 | if( iLastGroupIndex != iGroupIndex )
99 | {
100 | Write("
");
106 | sCollectedNames = "";
107 | sCollectedValues = "";
108 | iLastGroupIndex = iGroupIndex;
109 | }
110 |
111 | string id = oDP.ID();
112 | string sRet = "";
113 | string sValue = sRecordedValue;
114 | Call("/esp/functions.fn::WriteDPText()");
115 | sRecordedValue = system.GetVar("sRet");
116 |
117 | sCollectedNames = sDatapointName;
118 | sCollectedDateTimes = sDateTime;
119 | sCollectedTimestamp = sTimestamp;
120 |
121 | if( !sCollectedValues.Length() )
122 | {
123 | sCollectedValues = sRecordedValue;
124 | }
125 | else
126 | {
127 | sCollectedValues = sCollectedValues#", "#sRecordedValue;
128 | }
129 |
130 | }
131 | }
132 |
133 | }
134 | if( sCollectedValues.Length() )
135 | {
136 | Write("
");
142 | }
143 | }
144 | }
145 |
146 | array set res [rega_script $hm_script]
147 |
148 | if { $res(STDOUT) != "" } {
149 | puts -nonewline $res(STDOUT)
150 | }
151 | } else {
152 | puts -nonewline {}
153 | }
154 | puts ""
155 |
--------------------------------------------------------------------------------
/xmlapi/roomlist.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | source session.tcl
3 |
4 | puts "Content-Type: text/xml; charset=iso-8859-1"
5 | puts ""
6 | puts -nonewline ""
7 |
8 | if {[info exists sid] && [check_session $sid]} {
9 | array set res [rega_script {
10 |
11 | object oRoom;
12 | string sRoomId;
13 | string sRoomName;
14 | string sChannelId;
15 |
16 | foreach (sRoomId, dom.GetObject(ID_ROOMS).EnumUsedIDs())
17 | {
18 | oRoom = dom.GetObject(sRoomId);
19 |
20 | Write("");
22 |
23 | foreach(sChannelId, oRoom.EnumUsedIDs())
24 | {
25 | Write("");
26 | }
27 |
28 | Write("");
29 | }
30 |
31 | }]
32 |
33 | if { $res(STDOUT) != "" } {
34 | puts -nonewline $res(STDOUT)
35 | }
36 | } else {
37 | puts -nonewline {}
38 | }
39 | puts ""
40 |
--------------------------------------------------------------------------------
/xmlapi/rssilist.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | # !*****************************************************************************
3 | # !* rssilist.cgi
4 | # !* Signalqualitaet aller funk komponenten
5 | # !* Autor: Dirk Szymanski
6 | # !*****************************************************************************
7 | source session.tcl
8 |
9 | puts "Content-Type: text/xml; charset=iso-8859-1"
10 | puts ""
11 | puts -nonewline ""
12 |
13 | if {[info exists sid] && [check_session $sid]} {
14 |
15 | load tclrpc.so
16 | source common.tcl
17 |
18 | set RSSI_BAD -120.0
19 | set RSSI_MEDIUM -100.0
20 | set RSSI_GOOD -20.0
21 |
22 | read_interfaces
23 |
24 | set url $interfaces(BidCos-RF)
25 |
26 | if { [ catch {
27 | #check if the interface supports rssi
28 | #failure of this call will throw us out of here
29 | xmlrpc $url system.methodHelp rssiInfo
30 | } ] } { continue }
31 |
32 | array_clear rssi_map
33 | set rssi_list [xmlrpc $url rssiInfo ]
34 | array set rssi_map $rssi_list
35 |
36 | foreach dev [lsort [array names rssi_map]] {
37 | puts -nonewline ""
38 | }
39 |
40 | } else {
41 | puts -nonewline {}
42 | }
43 | puts ""
44 |
--------------------------------------------------------------------------------
/xmlapi/runprogram.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | source session.tcl
3 |
4 | puts "Content-Type: text/xml; charset=iso-8859-1"
5 | puts ""
6 | puts -nonewline ""
7 |
8 | if {[info exists sid] && [check_session $sid]} {
9 |
10 | set program_id "-1"
11 | set cond_check 0
12 | catch {
13 | set input $env(QUERY_STRING)
14 | set pairs [split $input &]
15 | foreach pair $pairs {
16 | if {0 != [regexp "^program_id=(.*)$" $pair dummy val]} {
17 | set program_id $val
18 | continue
19 | }
20 | if {0 != [regexp "^cond_check=(.*)$" $pair dummy val]} {
21 | set cond_check $val
22 | continue
23 | }
24 | }
25 | }
26 |
27 | # execut with condition check or without
28 | if { $cond_check == 1 } {
29 | array set res [rega_script "if ($program_id > 0) { object obj = dom.GetObject($program_id); if (obj && obj.IsTypeOf(OT_PROGRAM)) { obj.State(1); Write(obj); }}"]
30 | } else {
31 | array set res [rega_script "if ($program_id > 0) { object obj = dom.GetObject($program_id); if (obj && obj.IsTypeOf(OT_PROGRAM)) { obj.ProgramExecute(); Write(obj); }}"]
32 | }
33 |
34 | if { $res(STDOUT) != "" } {
35 | puts -nonewline ""
36 | } else {
37 | puts -nonewline {}
38 | }
39 | } else {
40 | puts -nonewline {}
41 | }
42 | puts ""
43 |
--------------------------------------------------------------------------------
/xmlapi/scripterrors.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | # Sucht in den letzten 10 Zeilen von /var/log/messages nach Homematic-Script Fehlermeldungen
3 | # 11'2012 - hobbyquaker https://github.com/hobbyquaker
4 | source session.tcl
5 |
6 | puts "Content-Type: text/xml; charset=iso-8859-1"
7 | puts ""
8 | puts -nonewline ""
9 |
10 | if {[info exists sid] && [check_session $sid]} {
11 |
12 | set Datei [open "|/usr/bin/tail -n 10 /var/log/messages" r]
13 | while {[gets $Datei Zeile] >= 0} {
14 | if { [regexp Error.*near $Zeile] } {
15 | regexp {([a-zA-Z]+ [0-9]+ [0-9\:]+) .+ local0.err ReGaHss: ERROR: SyntaxError\: Error ([0-9]+) at row ([0-9]+) col ([0-9]+)} $Zeile line time code row col
16 | puts -nonewline ""
22 | }
23 | }
24 | } else {
25 | puts -nonewline {}
26 | }
27 | puts ""
28 |
--------------------------------------------------------------------------------
/xmlapi/session.tcl:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | load tclrega.so
3 |
4 | catch {
5 | set raddr $env(REMOTE_ADDR)
6 | set input $env(QUERY_STRING)
7 | set pairs [split $input &]
8 | set sid ""
9 | foreach pair $pairs {
10 | if {0 != [regexp "^sid=(.*)$" $pair dummy val]} {
11 | set sid $val
12 | break
13 | }
14 | }
15 | }
16 |
17 | proc get_tokens {} {
18 | set filename "/etc/config/addons/xmlapi/token.list"
19 |
20 | array set tokens {}
21 | if {! [catch {set fd [open $filename r] } errmsg]} {
22 | array set tokens [read $fd]
23 | close $fd
24 | }
25 |
26 | return [array get tokens]
27 | }
28 |
29 | proc save_tokens tokenlist {
30 | set filename "/etc/config/addons/xmlapi/token.list"
31 |
32 | array set tokens $tokenlist
33 | if {! [catch {set fd [open $filename w] } errmsg]} {
34 | puts $fd [array get tokens]
35 | close $fd
36 | }
37 | }
38 |
39 | proc register_token descr {
40 | # get tokens
41 | array set tokens [get_tokens]
42 |
43 | # function to generate a random string of 16 characters
44 | # cf. https://wiki.tcl-lang.org/page/Generating+random+strings
45 | set newToken [subst [string repeat {[format %c [expr {int(rand() * 26) + (rand() > .5 ? 97 : 65)}]]} 16]]
46 |
47 | # add token to array
48 | set tokens($newToken) $descr
49 |
50 | # save tokens
51 | save_tokens [array get tokens]
52 |
53 | return $newToken
54 | }
55 |
56 | proc revoke_token tid {
57 | # get tokens
58 | array set tokens [get_tokens]
59 |
60 | if {[info exists tokens($tid)]} {
61 | # remove token from array
62 | unset tokens($tid)
63 |
64 | # write out new token list
65 | save_tokens [array get tokens]
66 | return 1
67 | }
68 |
69 | return 0
70 | }
71 |
72 | proc check_session session_id {
73 | global raddr
74 | # check for api tokens first and then check
75 | # for webui session ids as well as a fallback
76 | if {[regexp {^([0-9a-zA-Z]{16})$} $session_id all sidnr]} {
77 | # get tokens
78 | array set tokens [get_tokens]
79 |
80 | # check if sid exists in token array
81 | if {[info exists tokens($session_id)]} {
82 | return 1
83 | }
84 | } elseif {[regexp {^@([0-9a-zA-Z]{10})@$} $session_id all sidnr]} {
85 | set res [lindex [rega_script "Write(system.GetSessionVarStr('$sidnr'));"] 1]
86 | if {$res != ""} {
87 | return 1
88 | }
89 | } elseif {$raddr == "127.0.0.1"} {
90 | # allow all xmlapi requests from localhost without
91 | # any sid
92 | return 1
93 | }
94 | return 0
95 | }
96 |
--------------------------------------------------------------------------------
/xmlapi/state.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | source session.tcl
3 |
4 | puts "Content-Type: text/xml; charset=iso-8859-1"
5 | puts ""
6 | puts -nonewline ""
7 |
8 | if {[info exists sid] && [check_session $sid]} {
9 |
10 | set device_id ""
11 | set channel_id ""
12 | set datapoint_id ""
13 | catch {
14 | set input $env(QUERY_STRING)
15 | set pairs [split $input &]
16 | foreach pair $pairs {
17 | if {0 != [regexp "^device_id=(.*)$" $pair dummy val]} {
18 | set device_id $val
19 | continue
20 | }
21 | if {0 != [regexp "^channel_id=(.*)$" $pair dummy val]} {
22 | set channel_id $val
23 | continue
24 | }
25 | if {0 != [regexp "^datapoint_id=(.*)$" $pair dummy val]} {
26 | set datapoint_id $val
27 | continue
28 | }
29 | }
30 | }
31 |
32 | array set res [rega_script {
33 |
34 | string sDevIds = "} $device_id {";
35 | string sChannelIds = "} $channel_id {";
36 | string sDatapointIds = "} $datapoint_id {";
37 | string sChnId;
38 | string sDPId;
39 |
40 | if (sDatapointIds.Length() > 0 ) {
41 |
42 | string sDatapointId;
43 | foreach(sDatapointId, sDatapointIds.Split(",")) {
44 |
45 | object oDatapoint = dom.GetObject(sDatapointId);
46 | if (oDatapoint.IsTypeOf(OT_DP)) {
47 | Write("");
52 | }
53 | }
54 |
55 | } else {
56 |
57 | if (sChannelIds.Length() > 0 ) {
58 |
59 | string sChannelId;
60 | foreach(sChannelId, sChannelIds.Split(",")) {
61 | object oChannel2 = dom.GetObject(sChannelId);
62 |
63 | if (sDevIds.Length() > 0 ) {
64 | sDevIds = sDevIds # "," # oChannel2.Device().ToString();
65 | } else {
66 | sDevIds = oChannel2.Device().ToString();
67 | }
68 | }
69 | }
70 |
71 | string sDevId;
72 | foreach(sDevId, sDevIds.Split(",")) {
73 |
74 | object oDevice = dom.GetObject(sDevId);
75 | integer iDevInterfaceId = oDevice.Interface();
76 | object oDeviceInterface = dom.GetObject(iDevInterfaceId);
77 |
78 | if( (oDeviceInterface) && (oDevice.ReadyConfig()) && (oDevice.Name() != "Zentrale") && (oDevice.Name() != "HMW-RCV-50 BidCoS-Wir") && (oDevice.IsTypeOf(OT_DEVICE)) ) {
79 | Write(""); ! device tag schliessen
92 |
93 | foreach(sChnId, oDevice.Channels()) {
94 | object oChannel = dom.GetObject(sChnId);
95 | if ((!oChannel.Internal()) || oChannel.Internal()) {
96 |
97 | Write("");
102 |
103 |
104 | foreach(sDPId, oChannel.DPs().EnumUsedIDs()) {
105 | object oDP = dom.GetObject(sDPId);
106 | if(oDP) {
107 | string dp = oDP.Name().StrValueByIndex(".", 2);
108 |
109 | if( (dp != "ON_TIME") && (dp != "INHIBIT") && (dp != "CMD_RETS") && (dp != "CMD_RETL") && (dp != "CMD_SETS") && (dp != "CMD_SETL") ) {
110 | Write("");
123 | }
124 | }
125 | }
126 | Write("");
127 | }
128 | }
129 | Write("");
130 | }
131 | }
132 | }
133 | }]
134 |
135 | if { $res(STDOUT) != "" } {
136 | puts -nonewline $res(STDOUT)
137 | }
138 | } else {
139 | puts -nonewline {}
140 | }
141 | puts ""
142 |
--------------------------------------------------------------------------------
/xmlapi/statechange.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | source session.tcl
3 |
4 | puts "Content-Type: text/xml; charset=iso-8859-1"
5 | puts ""
6 | puts -nonewline ""
7 |
8 | if {[info exists sid] && [check_session $sid]} {
9 |
10 | set ise_id ""
11 | set new_value ""
12 | catch {
13 | set input $env(QUERY_STRING)
14 | set pairs [split $input &]
15 | foreach pair $pairs {
16 | if {0 != [regexp "^ise_id=(.*)$" $pair dummy val]} {
17 | set ise_id $val
18 | continue
19 | }
20 | if {0 != [regexp "^new_value=(.*)$" $pair dummy val]} {
21 | set new_value $val
22 | continue
23 | }
24 | }
25 | }
26 |
27 | regsub -all {%20} $new_value { } new_value
28 | regsub -all {%21} $new_value {!} new_value
29 | regsub -all {%23} $new_value {#} new_value
30 | regsub -all {%25} $new_value {%} new_value
31 | regsub -all {%2A} $new_value * new_value
32 | regsub -all {%2F} $new_value {/} new_value
33 | regsub -all {%3C} $new_value {<} new_value
34 | regsub -all {%3E} $new_value {>} new_value
35 | regsub -all {%3F} $new_value {?} new_value
36 | regsub -all {%5E} $new_value {^} new_value
37 | regsub -all {%3D} $new_value {=} new_value
38 | regsub -all {%2C} $new_value {,} new_value
39 |
40 | if { [string match "rgb*" $new_value ] || [string match "*=*" $new_value ] } {
41 | array set res [rega_script "Write(dom.GetObject($ise_id).State('$new_value'));"]
42 |
43 | if {$res(STDOUT) != "null"} {
44 | if {$res(STDOUT) == "true"} {
45 | set success "true"
46 | } else {
47 | set success "false"
48 | }
49 | puts -nonewline "";
50 | } else {
51 | puts -nonewline "";
52 | }
53 |
54 | } else {
55 |
56 | set rec_ise_id [split $ise_id "\,"]
57 |
58 | # only split new_value in case we have more ise_id
59 | if { [llength $rec_ise_id] > 1 } {
60 | set rec_new_value [split $new_value "\,"]
61 | } else {
62 | set rec_new_value [list $new_value]
63 | }
64 |
65 | for {set x 0} {$x<[llength $rec_ise_id]} {incr x} {
66 |
67 | array set res [rega_script "Write(dom.GetObject([lindex $rec_ise_id $x]).State('[lindex $rec_new_value $x]'));"]
68 |
69 | if {$res(STDOUT) != "null"} {
70 | if {$res(STDOUT) == "true"} {
71 | set success "true"
72 | } else {
73 | set success "false"
74 | }
75 | puts -nonewline "";
76 | } else {
77 | puts -nonewline "";
78 | }
79 | }
80 | }
81 | } else {
82 | puts -nonewline {}
83 | }
84 | puts ""
85 |
--------------------------------------------------------------------------------
/xmlapi/statelist.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | source session.tcl
3 |
4 | puts "Content-Type: text/xml; charset=iso-8859-1"
5 | puts ""
6 | puts -nonewline ""
7 |
8 | if {[info exists sid] && [check_session $sid]} {
9 |
10 | set ise_id 0
11 | set show_internal 0
12 | set show_remote 0
13 | catch {
14 | set input $env(QUERY_STRING)
15 | set pairs [split $input &]
16 | foreach pair $pairs {
17 | if {0 != [regexp "^ise_id=(.*)$" $pair dummy val]} {
18 | set ise_id $val
19 | continue
20 | }
21 | if {0 != [regexp "^show_internal=(.*)$" $pair dummy val]} {
22 | set show_internal $val
23 | continue
24 | }
25 | if {0 != [regexp "^show_remote=(.*)$" $pair dummy val]} {
26 | set show_remote $val
27 | continue
28 | }
29 | }
30 | }
31 |
32 | set comm "var ise_id=$ise_id;\n"
33 | append comm "var show_internal=$show_internal;\n"
34 | append comm "var show_remote=$show_remote;\n"
35 |
36 | if { $ise_id != 0 } then {
37 |
38 | append comm {
39 | object obj = dom.GetObject(ise_id);
40 | if(obj.TypeName() == "HSSDP")
41 | {
42 | object oDP = obj;
43 | string dp = oDP.Name().StrValueByIndex(".", 2);
44 |
45 | Write("");
58 | }
59 | }
60 |
61 | } else {
62 |
63 | append comm {
64 |
65 | string sDevId;
66 | string sChnId;
67 | string sDPId;
68 |
69 | foreach (sDevId, root.Devices().EnumUsedIDs())
70 | {
71 | object oDevice = dom.GetObject(sDevId);
72 | integer iDevInterfaceId = oDevice.Interface();
73 | object oDeviceInterface = dom.GetObject(iDevInterfaceId);
74 |
75 | boolean isRemote = ( ("HMW-RCV-50" == oDevice.HssType()) || ("HM-RCV-50" == oDevice.HssType()) || ("HmIP-RCV-50" == oDevice.HssType()) );
76 |
77 | if( ( oDeviceInterface ) && ( oDevice.ReadyConfig() ) && ( ( isRemote == false ) || ( show_remote == 1 ) ) )
78 | {
79 | Write(""); ! device tag schliessen
92 |
93 | foreach(sChnId, oDevice.Channels())
94 | {
95 | object oChannel = dom.GetObject(sChnId);
96 | if ( (! oChannel.Internal()) || oChannel.Internal() )
97 | {
98 | Write("");
120 |
121 | foreach(sDPId, oChannel.DPs().EnumUsedIDs())
122 | {
123 | object oDP = dom.GetObject(sDPId);
124 | if(oDP)
125 | {
126 | string dp = oDP.Name().StrValueByIndex(".", 2);
127 |
128 | if( (dp != "ON_TIME") && (dp != "INHIBIT") && (dp != "CMD_RETS") && (dp != "CMD_RETL") && (dp != "CMD_SETS") && (dp != "CMD_SETL") )
129 | {
130 | Write("");
147 | }
148 | }
149 | }
150 | Write("");
151 | }
152 | }
153 | Write("");
154 | }
155 | }
156 | }
157 |
158 | array set res [rega_script $comm]
159 |
160 | if { $res(STDOUT) != "" } {
161 | puts -nonewline $res(STDOUT)
162 | }
163 | }
164 | } else {
165 | puts -nonewline {}
166 | }
167 | puts ""
168 |
--------------------------------------------------------------------------------
/xmlapi/systemNotification.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | source session.tcl
3 |
4 | puts "Content-Type: text/xml; charset=iso-8859-1"
5 | puts ""
6 | puts -nonewline ""
7 |
8 | if {[info exists sid] && [check_session $sid]} {
9 |
10 | set hm_script {
11 | object oTmpArray = dom.GetObject(ID_SERVICES);
12 |
13 | if( oTmpArray ) {
14 | string sTmp;
15 |
16 | foreach(sTmp, oTmpArray.EnumIDs()){
17 |
18 | object oTmp = dom.GetObject( sTmp );
19 |
20 | if( oTmp ){
21 | if( oTmp.IsTypeOf( OT_ALARMDP ) && ( oTmp.AlState() == asOncoming ) ){
22 |
23 | var trigDP = dom.GetObject(oTmp.AlTriggerDP());
24 | if( trigDP ) {
25 | Write("");
35 | }
36 | }
37 | }
38 | }
39 | }
40 | }
41 |
42 | array set res [rega_script $hm_script]
43 |
44 | if { $res(STDOUT) != "" } {
45 | puts -nonewline $res(STDOUT)
46 | }
47 | } else {
48 | puts -nonewline {}
49 | }
50 | puts ""
51 |
--------------------------------------------------------------------------------
/xmlapi/systemNotificationClear.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | source session.tcl
3 |
4 | puts "Content-Type: text/xml; charset=iso-8859-1"
5 | puts ""
6 | puts -nonewline ""
7 |
8 | if {[info exists sid] && [check_session $sid]} {
9 |
10 | set hm_script {
11 | string itemID;
12 | string address;
13 | object aldp_obj;
14 |
15 | foreach(itemID, dom.GetObject(ID_DEVICES).EnumUsedIDs()) {
16 | address = dom.GetObject(itemID).Address();
17 | aldp_obj = dom.GetObject("AL-" # address # ":0.STICKY_UNREACH");
18 | if (aldp_obj) {
19 | if (aldp_obj.Value()) {
20 | aldp_obj.AlReceipt();
21 | }
22 | }
23 | }
24 | }
25 |
26 | array set res [rega_script $hm_script]
27 |
28 | if { $res(STDOUT) != "" } {
29 | puts -nonewline $res(STDOUT)
30 | }
31 | } else {
32 | puts -nonewline {}
33 | }
34 | puts ""
35 |
--------------------------------------------------------------------------------
/xmlapi/sysvar.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | source session.tcl
3 |
4 | puts "Content-Type: text/xml; charset=iso-8859-1"
5 | puts ""
6 | puts -nonewline ""
7 |
8 | if {[info exists sid] && [check_session $sid]} {
9 |
10 | set text "true"
11 | set ise_id "-1"
12 | catch {
13 | set input $env(QUERY_STRING)
14 | set pairs [split $input &]
15 | foreach pair $pairs {
16 | if {0 != [regexp "^text=(.*)$" $pair dummy val]} {
17 | set text $val
18 | continue
19 | }
20 | if {0 != [regexp "^ise_id=(.*)$" $pair dummy val]} {
21 | set ise_id $val
22 | continue
23 | }
24 | }
25 | }
26 |
27 | set hm_script {
28 | object oSysVar;
29 | string sSysVarId;
30 | string sShowText=
31 | }
32 |
33 | append hm_script $text
34 |
35 | append hm_script {;
36 | string iSysVarId=}
37 |
38 | append hm_script $ise_id
39 |
40 | append hm_script {;
41 |
42 | foreach (sSysVarId, dom.GetObject(ID_SYSTEM_VARIABLES).EnumUsedIDs()){
43 |
44 | oSysVar = dom.GetObject(sSysVarId);
45 |
46 | if (oSysVar.ID() == iSysVarId) {
47 |
48 | Write("");
83 | }
84 | }
85 | }
86 |
87 | array set res [rega_script $hm_script]
88 |
89 | if { $res(STDOUT) != "" } {
90 | puts -nonewline $res(STDOUT)
91 | }
92 | } else {
93 | puts -nonewline {}
94 | }
95 | puts ""
96 |
--------------------------------------------------------------------------------
/xmlapi/sysvarlist.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | source session.tcl
3 |
4 | puts "Content-Type: text/xml; charset=iso-8859-1"
5 | puts ""
6 | puts -nonewline ""
7 |
8 | if {[info exists sid] && [check_session $sid]} {
9 |
10 | set text "false"
11 | catch {
12 | set input $env(QUERY_STRING)
13 | set pairs [split $input &]
14 | foreach pair $pairs {
15 | if {0 != [regexp "^text=(.*)$" $pair dummy val]} {
16 | set text $val
17 | continue
18 | }
19 | }
20 | }
21 |
22 | set hm_script {
23 | object oSysVar;
24 | string sSysVarId;
25 | string sShowText=
26 | }
27 |
28 | append hm_script $text
29 |
30 | append hm_script {;
31 |
32 | foreach (sSysVarId, dom.GetObject(ID_SYSTEM_VARIABLES).EnumUsedIDs()) {
33 | oSysVar = dom.GetObject(sSysVarId);
34 | Write("");
75 | }
76 |
77 | }
78 |
79 | array set res [rega_script $hm_script]
80 |
81 | if { $res(STDOUT) != "" } {
82 | puts -nonewline $res(STDOUT)
83 | }
84 | } else {
85 | puts -nonewline {}
86 | }
87 | puts ""
88 |
--------------------------------------------------------------------------------
/xmlapi/tokenlist.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | #
3 | # script to list all currently registred API tokens
4 | #
5 | # parameters: none
6 | # return: list of currently active API tokens
7 | #
8 |
9 | source session.tcl
10 |
11 | puts "Content-Type: text/xml; charset=iso-8859-1"
12 | puts ""
13 | puts -nonewline ""
14 |
15 | if {[info exists sid] && [check_session $sid]} {
16 |
17 | # get tokens
18 | array set tokens [get_tokens]
19 |
20 | foreach {token desc} [array get tokens] {
21 | puts "$token"
22 | }
23 |
24 | } else {
25 | puts -nonewline {}
26 | }
27 | puts ""
28 |
--------------------------------------------------------------------------------
/xmlapi/tokenregister.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | source session.tcl
3 |
4 | puts "Content-Type: text/xml; charset=iso-8859-1"
5 | puts ""
6 | puts -nonewline ""
7 |
8 | if {[info exists sid] && [check_session $sid]} {
9 |
10 | set desc ""
11 | set ise_id "-1"
12 | catch {
13 | set input $env(QUERY_STRING)
14 | set pairs [split $input &]
15 | foreach pair $pairs {
16 | if {0 != [regexp "^desc=(.*)$" $pair dummy val]} {
17 | set desc $val
18 |
19 | # replace URL encoded parts
20 | regsub -all {%20} $desc { } desc
21 | regsub -all {%21} $desc {!} desc
22 | regsub -all {%23} $desc {#} desc
23 | regsub -all {%25} $desc {%} desc
24 | regsub -all {%25} $desc {%} desc
25 | regsub -all {%2A} $desc * desc
26 | regsub -all {%2F} $desc {/} desc
27 | regsub -all {%3F} $desc {?} desc
28 | regsub -all {%5E} $desc {^} desc
29 | regsub -all {%3D} $desc {=} desc
30 | regsub -all {%2C} $desc {,} desc
31 |
32 | # disable certain invalid chars
33 | regsub -all {%3C} $desc {_} desc
34 | regsub -all {<} $desc {_} desc
35 | regsub -all {%3E} $desc {_} desc
36 | regsub -all {>} $desc {_} desc
37 | regsub -all {%27} $desc {_} desc
38 | regsub -all {'} $desc {_} desc
39 | break
40 | }
41 | }
42 | }
43 |
44 | set newToken [register_token $desc]
45 | if { $newToken != "" } {
46 | puts "$newToken"
47 | } else {
48 | puts ""
49 | }
50 |
51 | } else {
52 | puts -nonewline {}
53 | }
54 | puts ""
55 |
--------------------------------------------------------------------------------
/xmlapi/tokenrevoke.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | source session.tcl
3 |
4 | puts "Content-Type: text/xml; charset=iso-8859-1"
5 | puts ""
6 | puts -nonewline ""
7 |
8 | if {[info exists sid] && [check_session $sid]} {
9 |
10 | set result [revoke_token $sid]
11 | if { $result == 1 } {
12 | puts ""
13 | } else {
14 | puts ""
15 | }
16 |
17 | } else {
18 | puts -nonewline {}
19 | }
20 | puts ""
21 |
--------------------------------------------------------------------------------
/xmlapi/update-check.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 |
3 | set checkURL "https://raw.githubusercontent.com/homematic-community/XML-API/master/VERSION"
4 | set downloadURL "https://github.com/homematic-community/XML-API/releases"
5 |
6 | catch {
7 | set input $env(QUERY_STRING)
8 | set pairs [split $input &]
9 | foreach pair $pairs {
10 | if {$pair == "cmd=download"} {
11 | set cmd "download"
12 | break
13 | }
14 | }
15 | }
16 |
17 | if { [info exists cmd ] && $cmd == "download"} {
18 | puts -nonewline "Content-Type: text/html; charset=utf-8\r\n\r\n"
19 | puts -nonewline ""
20 | } else {
21 | puts -nonewline "Content-Type: text/plain; charset=utf-8\r\n\r\n"
22 | catch {
23 | set newversion [ exec /usr/bin/wget -qO- --no-check-certificate $checkURL ]
24 | }
25 | if { [info exists newversion] } {
26 | puts $newversion
27 | } else {
28 | puts "n/a"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/xmlapi/update.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | source session.tcl
3 |
4 | puts "Content-Type: text/xml; charset=iso-8859-1"
5 | puts ""
6 | puts -nonewline ""
7 |
8 | if {[info exists sid] && [check_session $sid]} {
9 |
10 | set checkupdate ""
11 | set maxdurchlaeufe 7
12 | catch {
13 | set input $env(QUERY_STRING)
14 | set pairs [split $input &]
15 | foreach pair $pairs {
16 | if {0 != [regexp "^checkupdate=(.*)$" $pair dummy val]} {
17 | set checkupdate $val
18 | continue
19 | }
20 | if {0 != [regexp "^maxdurchlaeufe=(.*)$" $pair dummy val]} {
21 | set maxdurchlaeufe $val
22 | continue
23 | }
24 | }
25 | }
26 |
27 | catch {
28 | set idlist [split [string trim $checkupdate] ";"]
29 | set resultids ""
30 | set zaehler 0
31 | while { ([llength $resultids] < 1) && ($zaehler < $maxdurchlaeufe) } {
32 | foreach pair $idlist {
33 | if {$pair != {} } then {
34 | set vp [split $pair "="]
35 |
36 | set id [lindex $vp 0]
37 | set timestamp [lindex $vp 1]
38 |
39 | set res [rega "dom.GetObject($id).Timestamp().ToInteger();"]
40 |
41 | if { $res == $timestamp } {
42 | continue
43 | }
44 |
45 | # unterschiedlich, also id merken
46 | array set res_arr [rega_script "object o=dom.GetObject($id);\nvar value=o.Value();\nvar lastupdate=o.Timestamp().ToInteger();\nvar type=o.TypeName();"]
47 | # puts -nonewline $res_arr(STDOUT)
48 | puts -nonewline ""
49 | lappend resultids $id
50 | }
51 | }
52 | if { [llength $resultids] < 1 } {
53 | after 500
54 | incr zaehler
55 | }
56 | }
57 | }
58 | } else {
59 | puts -nonewline {}
60 | }
61 | puts ""
62 |
63 |
64 |
--------------------------------------------------------------------------------
/xmlapi/version.cgi:
--------------------------------------------------------------------------------
1 | #!/bin/tclsh
2 | set filename "/www/addons/xmlapi/VERSION"
3 | set fd [open $filename r]
4 | set version ""
5 | if { $fd >=0 } {
6 | gets $fd version
7 | close $fd
8 | }
9 |
10 | puts "Content-Type: text/xml; charset=iso-8859-1"
11 | puts ""
12 | puts -nonewline ""
13 |
14 | puts -nonewline $version
15 |
16 | puts ""
17 |
--------------------------------------------------------------------------------
/xmlapi/xml.tcl:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/homematic-community/XML-API/d13c53f7850388bcffc5e3bc26f3f6145ef96be3/xmlapi/xml.tcl
--------------------------------------------------------------------------------