Skip to content

Commit

Permalink
reworked mastervalue.cgi and mastervaluechange.cgi to automatically
Browse files Browse the repository at this point in the history
choose the right interface url for the xmlrpc call to query and set the
MASTER paramset. This finally should allow to query and set all
supported HomeMatic interfaces like HmIP, HmIPW, BidCos-Wired as well as
third party interfaces like CuXD, etc. This closes #36.
  • Loading branch information
jens-maus committed Oct 17, 2023
1 parent f40b7d2 commit de9eae2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 14 deletions.
20 changes: 12 additions & 8 deletions xmlapi/mastervalue.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ if {[info exists sid] && [check_session $sid]} {
integer iseId = "} $devid {";
var oDevice = dom.GetObject(iseId);
var address = oDevice.Address();
string deviceInterface = (dom.GetObject(oDevice.Interface())).Name();
var deviceType = oDevice.HssType();
Write("<device");
Write(" name='");
Expand All @@ -54,6 +55,7 @@ if {[info exists sid] && [check_session $sid]} {
}]
set deviceAddress $values(address)
set deviceType $values(deviceType)
set deviceInterface $values(deviceInterface)

puts -nonewline $values(STDOUT)

Expand All @@ -64,15 +66,17 @@ if {[info exists sid] && [check_session $sid]} {
puts -nonewline {" error="true">DEVICE NOT FOUND</device>}
} else {
# initialize variable, could fail in catch block below
set ausgabe ""
if {[string compare -nocase -length 9 "HM-CC-VG-" $deviceType] == 0} {
catch {set ausgabe [xmlrpc $interfaces(VirtualDevices) getParamset [list string $deviceAddress] [list string "MASTER"] ] }
} elseif {[string compare -nocase -length 5 "HMIP-" $deviceType] == 0} {
catch {set ausgabe [xmlrpc $interfaces(HmIP-RF) getParamset [list string $deviceAddress] [list string "MASTER"] ] }
} else {
catch {set ausgabe [xmlrpc $interfaces(BidCos-RF) getParamset [list string $deviceAddress] [list string "MASTER"] ] }
set channel ""
if {[string compare -nocase -length 4 "HmIP" "$deviceInterface"] == 0 ||
[string compare -nocase -length 4 "HmIP" "$deviceType"] == 0 } {
# HmIP requires to add :0 to deviceAddress
set channel ":0"
}

# call xmlrpc to get the MASTER paramset
set ausgabe ""
catch {set ausgabe [xmlrpc $interfaces($deviceInterface) getParamset [list string "$deviceAddress$channel"] [list string "MASTER"] ] }

foreach { bezeichnung wert } $ausgabe {
if { ($allMasterValues == "*" || [lsearch $requestedNames $bezeichnung] >= 0) } {
puts -nonewline {<mastervalue name='}
Expand All @@ -89,4 +93,4 @@ if {[info exists sid] && [check_session $sid]} {
} else {
puts -nonewline {<not_authenticated/>}
}
puts "</mastervalue>"
puts "</mastervalue>"
19 changes: 13 additions & 6 deletions xmlapi/mastervaluechange.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ if {[info exists sid] && [check_session $sid]} {
integer iseId = "} $devid {";
var oDevice = dom.GetObject(iseId);
var address = oDevice.Address();
string deviceInterface = (dom.GetObject(oDevice.Interface())).Name();
var deviceType = oDevice.HssType();
Write("<device");
Write(" name='");
Expand All @@ -61,16 +62,22 @@ if {[info exists sid] && [check_session $sid]} {
}]
set deviceAddress $values(address)
set deviceType $values(deviceType)
set deviceInterface $values(deviceInterface)

puts -nonewline $values(STDOUT)

if {[string compare -nocase -length 9 "HM-CC-VG-" $deviceType] == 0} {
set ausgabe [xmlrpc $interfaces(VirtualDevices) putParamset [list string $deviceAddress] [list string "MASTER"] [list struct $cmd]]
} elseif {[string compare -nocase -length 5 "HMIP-" $deviceType] == 0} {
set ausgabe [xmlrpc $interfaces(HmIP-RF) putParamset [list string $deviceAddress] [list string "MASTER"] [list struct $cmd]]
} else {
set ausgabe [xmlrpc $interfaces(BidCos-RF) putParamset [list string $deviceAddress] [list string "MASTER"] [list struct $cmd]]
# initialize variable, could fail in catch block below
set channel ""
if {[string compare -nocase -length 4 "HmIP" "$deviceInterface"] == 0 ||
[string compare -nocase -length 4 "HmIP" "$deviceType"] == 0 } {
# HmIP requires to add :0 to deviceAddress
set channel ":0"
}

# call xmlrpc to set the MASTER paramset
set ausgabe ""
catch {set ausgabe [xmlrpc $interfaces($deviceInterface) putParamset [list string "$deviceAddress$channel"] [list string "MASTER"] [list struct $cmd] ] }

puts -nonewline {<mastervalue name='}
puts -nonewline $item
puts -nonewline {' value='}
Expand Down

0 comments on commit de9eae2

Please sign in to comment.