diff --git a/fhem/contrib/HMRPC/HMRPC.txt b/fhem/contrib/HMRPC/HMRPC.txt index 4e77f5475..2579c1c09 100644 --- a/fhem/contrib/HMRPC/HMRPC.txt +++ b/fhem/contrib/HMRPC/HMRPC.txt @@ -2,7 +2,7 @@ HMRPC - xmlrpc-basierte Homematic-Integration fuer fhem ======================================================= Von Oliver Wagner -V0.3 +V0.4 Uebersicht ---------- @@ -115,8 +115,8 @@ Problem auf der Service-Seite darzustellen. Aenderungen ----------- V0.3 - get-Methoden implementiert, als Aufruf von XML-RPC getValue() - - bei Boolean-Werten wurde bei false bei jedem Empfang faelschlicherweise - eine Notification ausgeloest + - bei Boolean-Werten wurde bei false bei jedem event-Empfang + faelschlicherweise eine Notification ausgeloest Anhang diff --git a/fhem/contrib/HMRPC/import_from_webui.bsh b/fhem/contrib/HMRPC/import_from_webui.bsh new file mode 100644 index 000000000..a61870de7 --- /dev/null +++ b/fhem/contrib/HMRPC/import_from_webui.bsh @@ -0,0 +1,100 @@ +#!/bin/bash +# +# This script gets the full device list from a running +# CCU1 and creates a prototype config file fragment +# for use with fhem and HMRPC. +# +# Note that this script assumes that the wired HMRPC +# device is called "hmw" and the RF HMRPC device +# is called "hmrf" +# +if [ -z "$1" ]; then + echo "Usage: import_from_webui.bsh " + exit 1 +fi +# We need a ISO-8859-1 locale now +export LANG=de_DE.ISO-8859-1 +wget http://$1:8181/tclrega.exe --post-data=' +string id; +string chid; +foreach(id, root.Devices().EnumUsedIDs()) +{ + var d=dom.GetObject(id); + foreach(chid,d.Channels().EnumUsedIDs()) + { + var ch=dom.GetObject(chid); + var i=dom.GetObject(ch.Interface()); + string rspec; + string rid; + foreach(rid,ch.ChnRoom()) + { + var r=dom.GetObject(rid); + rspec = rspec # r.Name() # "%"; + } + WriteLine(ch.Address() # "\t" # i.Name() # "\t" # ch.Name() # "\t" # rspec); + } + var i=dom.GetObject(d.Interface()); + WriteLine(d.Address()+"\t"+i.Name()+"\t"+d.Name()); +}' -q -O- | dos2unix | gawk --re-interval -- ' +BEGIN { + FS="\t" +} + +# +# Convert a WebUI name into something which fhem accepts in a config file +# +function sanitizeName(n) +{ + # Blanks + gsub(" ","_",n) + # Umlauts + gsub("\xe4","ae",n); + gsub("\xf6","oe",n); + gsub("\xfc","ue",n); + gsub("\xdf","ss",n); + gsub("\xc4","Ae",n); + gsub("\xd6","Oe",n); + gsub("\xdc","Ue",n); + # : (for unnamed devices) + gsub(":|/|-","_",n); + gsub("\\(|\\)","",n); + return tolower(n) +} + +function roomName(n) +{ + gsub(" ","",n) + gsub("%$","",n) + gsub("%",",",n) + return n; +} + +/^BidCos-|^[A-Z0-9]{10}(:[0-9]+)?/ { + name=sanitizeName($3) + while(usednames[name]) + { + # Ok name is in use. Are we perhaps the master device? + if(!index($1,":")) + { + name=name "_dev" + continue; + } + # Are suffixed by a name? Inc + if(match(name,"(.*)([0-9]+)",pa)) + { + name=pa[1] (pa[2]+1) + continue; + } + # Just append a "1" (might get inced in next iteration) + name = name "1" + } + usednames[name]=1 + print "define " name " HMDEV " $1 + print "attr " name " IODev " (index($2,"BidCos-RF")?"hmrf":"hmw") + if($4) + { + print "attr " name " room " roomName($4) + } + print "" +} +'