Seite 1 von 3

Openhab 2 mit http Bindung

Verfasst: 27. Jul 2020 13:25
von JuergenA
Hallo zusammen,

ich versuche mich nun schon seit Tagen an der HTTP-Bindung. Ich habe eine UVR1611 von technische Alternative und einen BL-NET davon. Beispiele im Netz und hier im Forum führten leider absolut nicht zum Erfolg.

meine HTML Seite sieht im Code so aus:

Code: Alles auswählen

<!--2.0-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<style type="text/css">
  body {font-size: 14px; font-family: Verdana, Arial, Helvetica, sans-serif; background-repeat: no-repeat; background-color: transparent; background: transparent; margin: 0px; padding: 0px;}
  #frame {text-align: left; vertical-align: top; position: relative; margin-left: 0;}

/*########## CSS-ID: Positionen und Darstellung der Anzeigeparameter ##########*/
#pos0{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:93px; left:56px; }
#pos1{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:138px; left:54px; }
#pos2{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:186px; left:53px; }
#pos3{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:232px; left:54px; }
#pos4{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:281px; left:54px; }
#pos5{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:327px; left:51px; }
#pos6{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:374px; left:50px; }
#pos7{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:419px; left:51px; }
#pos8{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:465px; left:49px; }
#pos9{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:510px; left:46px; }
#pos10{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:553px; left:48px; }
#pos11{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:597px; left:49px; }
#pos12{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:640px; left:52px; }
#pos13{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:7px; left:54px; }
#pos14{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:54px; left:53px; }
#pos15{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:14px; left:673px; }
#pos16{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:109px; left:675px; }
#pos17{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:189px; left:673px; }
#pos18{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:235px; left:673px; }
#pos19{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:283px; left:671px; }
#pos20{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:327px; left:670px; }
#pos21{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:370px; left:671px; }
#pos22{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:420px; left:673px; }
#pos23{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:466px; left:676px; }
#pos24{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:514px; left:678px; }
#pos25{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:65px; left:674px; }
#pos26{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:151px; left:675px; }
</style>
<script type="text/javascript">
<!--
 var Title ="Onlineschema";  // Titeltext im Browserfenster
 var GraphicFile = "GRAFIK.gif";  // Pfad der Grafikdatei
 var Width = "2452px";
 var Height = "3496px";
 
//### Intervallzeit [in Sekunden] fr eine automatische Aktualisierung der Messwerte: ###
//### < "30" = keine automatische Aktualisierung ###
//--------------------------------------------------
 var AutoRefreshTime = "30";

//### Linktext für manuelle Aktualisierung der Messwerte: ###
//### "" = kein Link für manuelle Aktualisierung ###
//--------------------------------------------------
 var RefreshLink ="";
 
 function set_dimenson_para (){
 document.getElementById("frame").style.width = Width;
 document.getElementById("frame").style.hight = Height;
 }
 -->
</script>
 
 </head>
 <body onload="set_dimenson_para ()">
 <div id="frame">
 <!--########## Definitionen der Anzeigeparameter ##########-->
<div id="pos0">Aussentemperatur: 29,3</div>
<div id="pos1">Warmwasser: 72,4</div>
<div id="pos2">Puffer oben: 73,0</div>
<div id="pos3">Puffer mitte: 72,6</div>
<div id="pos4">Puffer unten: 72,3</div>
<div id="pos5">Solar Ruecklauf: 68,3</div>
<div id="pos6">Heizkreis1 Vorlauf: 39,4</div>
<div id="pos7">Heizkreis1 Ruecklauf: 46,4</div>
<div id="pos8">Zirkulation: 38,1</div>
<div id="pos9">Kollektortemperatur: 88,9</div>
<div id="pos10">Kessel Vorlauf: 28,2</div>
<div id="pos11">Heizkreis2 Vorlauf: 38,8</div>
<div id="pos12">Heizkreis2 Ruecklauf: 46,1</div>
<div id="pos13">Uhrzeit: 12:50:00</div>
<div id="pos14">Datum: 27.07.2020</div>
<div id="pos15">Ladepumpe: AUS</div>
<div id="pos16">Solarpumpe: EIN</div>
<div id="pos17">Mischer1_auf: AUS</div>
<div id="pos18">Mischer1_zu: AUS</div>
<div id="pos19">Brenneranforderung: AUS</div>
<div id="pos20">Heizkreispumpe1: AUS</div>
<div id="pos21">Zirkulationspumpe: AUS</div>
<div id="pos22">Mischer2_auf: AUS</div>
<div id="pos23">Mischer2_zu: AUS</div>
<div id="pos24">Heizkreispumpe2: AUS</div>
<div id="pos25">Drehzahl Ladepumpe: 0</div>
<div id="pos26">Drehzahl Solarpumpe: 21</div>
</div>
</body>
</html>
meine http.cfg hat folgende beiträge:

Code: Alles auswählen

# timeout in milliseconds for the http requests (optional, defaults to 5000)
#timeout=

# the interval in milliseconds when to find new refresh candidates
# (optional, defaults to 1000)
#granularity=

# whether to substitute the current time or state value into the URL
# (optional, defaults to true)
#format=

# configuration of the first cache item
#<id1>.url=
#<id1>.updateInterval=

# configuration of the second cache item  
#<id2>.url=
#<id2>.updateInterval=

# http binding fuer Technische Alternative BL-Net
blnet.url=http://10.5.3.250/GRAFIK1.html
blnet.updateInterval=60000
und mein BL-Net.items sieht so aus:

Code: Alles auswählen

String  WarmWasser      "Warmwasser [%.0f C]"   <temperature>   { http="<[blnet:60000:REGEX(.*?Warmwasser.*?))]" }
wenn ich mir dann die String-Variable Warmwasser aufrufe hat diese den Eintrag:

Code: Alles auswählen

<!--2.0-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<style type="text/css">
  body {font-size: 14px; font-family: Verdana, Arial, Helvetica, sans-serif; background-repeat: no-repeat; background-color: transparent; background: transparent; margin: 0px; padding: 0px;}
  #frame {text-align: left; vertical-align: top; position: relative; margin-left: 0;}

/*########## CSS-ID: Positionen und Darstellung der Anzeigeparameter ##########*/
#pos0{position:absolute; font-family: Calibri; font-size: 26pt; color: rgb(0,0,0); font-style: normal; font-weight: bold; text-align: left; top:93px; left:56px; }


ich habe schon die Seite mehrmals durch und auch versucht andere REGEX Einträge, aber er liest mir immer wieder den gleichen Text in die Variable.

Wo liegt denn mein Fehler?

Danke schon mal.

Gruß

Jürgen

Re: Openhab 2 mit http Bindung

Verfasst: 27. Jul 2020 20:36
von udo1toni
Dein REGEX Ausdruck ist verkehrt.
Probiere mal

Code: Alles auswählen

String  WarmWasser      "Warmwasser [%.0f C]"   <temperature>   { http="<[blnet:60000:REGEX(.*Warmwasser..(....).*)]" }
Das wären dann exakt vier Zeichen. (nn,n) Falls die Temperatur auch nur eine Vorkommastelle haben kann und kein Leerzeichen vorn dran steht, wäre eine Alternative, das </div> als hintere Grenze zu nehmen:

Code: Alles auswählen

REGEX(.*Warmwasser..(.*)</div>.*)
Allerdings macht REGEX hier gerne mal Sperenzchen und nimmt einfach ein späteres </div>.

Re: Openhab 2 mit http Bindung

Verfasst: 27. Jul 2020 20:53
von JuergenA
Danke für den Versuch, hat leider nichts gebracht. Liest immer noch den Text von oben in die Variable. Muss denn zum Http-Binding sonst noch etwas installiert werden? Oder ist das alles?

Re: Openhab 2 mit http Bindung

Verfasst: 27. Jul 2020 20:55
von udo1toni
REGEX muss auch installiert sein.

Re: Openhab 2 mit http Bindung

Verfasst: 27. Jul 2020 21:01
von udo1toni
Ach so... ein String Item kann mit der Formatierung %.0f nichts anfangen. Du musst stattdessen %s verwenden.
Du kannst an dieser Stelle leider auch kein Number Item verwenden, denn es wird ein Komma geliefert, wo openHAB einen Punkt erwartet.

Die Alternative wäre ein JavaScript als Transformation, da kannst Du dann im Script per REGEX filtern und das Komma durch einen Punkt ersetzen.

Re: Openhab 2 mit http Bindung

Verfasst: 27. Jul 2020 21:27
von JuergenA
Muß das Regex auch über Binding installiert werden? Wo finde ich das? In Openhab ist es unter Binding nicht drin.

Re: Openhab 2 mit http Bindung

Verfasst: 27. Jul 2020 21:36
von JuergenA
Ich hab´s gefunden unter transformation. Und nun sieht das Ganze doch schon besser aus. Meine Werte kommen nun endlich mal rein wie ich Sie brauche. Danke @udo1toni! Spitze wenn man so einen Partner im Forum hat.

Re: Openhab 2 mit http Bindung

Verfasst: 27. Jul 2020 21:53
von udo1toni
Immer gerne :)

Re: Openhab 2 mit http Bindung

Verfasst: 17. Aug 2020 14:36
von Johannes911
Hallo JuergenA,
es scheint mir fehlt zur erfolgreichen Kommunikation mit der UVR1611 über BL-NET noch etwas.

Ich kann fast den gleichen Inhalt im Item sehen, so wie oben gepostet, was mir dort aber fehlt sind die einzelnen Werte. Hast du dafür deine WEB-Site im BL-NET geändert, so dass die Werte bis ins ITEM ankommen?

Im events.log sehe ich auch, dass meine Werte nicht eingelesen werden, auf der WEB-Site werden aber ALLE dargestellt.
Gibt es da noch einen Tipp für mich?

Re: Openhab 2 mit http Bindung

Verfasst: 17. Aug 2020 16:15
von Johannes911
Es scheint als ob das http binding zu früh aufhört Daten einzulesen. Mit wireshark kann ich sehen dass alle benötigten Daten geliefert werden, im events.log fehlt aber ein großer Teil (endet immer wenn folgende Sequenz empfangen wurde: id="rld"></div></body></html>)
Da scheint es auf </html> zu reagieren. Insgesamt können auch gut 5 Sekunden vergehen bevor alle Daten angekommen sind.

Kann man da etwas ändern? Timeout länger machen, nicht auf </html> reagieren etc.?