Weishaupt Manager - Exporting Data from a IP-Server (html-file

Hi,

I have a Weishaupt Manager for my heating system that has no API-Gateway or something like that. I can get access to the front-system via IP-Adress and with my old system IP-Symcon I can read the values via php.

So my old logic on IP-Symcon was:

<?php

// HTML-Seite abrufen
$html = file_get_contents("http://192.168.1.63/http/index/j_operatingdata.html");

// Variablen definieren und mit den entsprechenden Werten aus der HTML-Seite befüllen
$variable1 = getHTMLValue($html, "writeln(Temperatur);document.write(Warmwasser)", "<td>&deg;C"); //Isttemperatur Warmwasser
$variable2 = getHTMLValue($html, "writeln(Warmwasser);document.write(Solltemperatur)", "<td>&deg;C"); //Solltemperatur Warmwasser
$variable3 = getHTMLValue($html, "write(Aussentemperatur)", "<td>&deg;C"); //Außentemperatur
$variable4 = getHTMLValue($html, "write(Vorlauftemperatur)", "<td>&deg;C"); //Vorlauftemperatur
$variable5 = getHTMLValue($html, "writeln(Ruecklauftemperatur);document.write(HkEins)", "<td>&deg;C"); //Rücklauftemperatur
$variable6 = getHTMLValue($html, "writeln(Ruecklaufsolltemperatur);document.write(HkEins)", "<td>&deg;C"); //Rücklaufsolltemperatur
$variable7 = getHTMLValue($html, "write(Wuelleneintritt)", "<td>&deg;C"); //Wärmequelleneintritt
$variable8 = getHTMLValue($html, "write(Wuellenaustritt)", "<td>&deg;C"); //Wärmequellenaustritt

// Leerzeichen und Komma entfernen
$variable1 = str_replace(array(" ", ";"), "", $variable1);
$variable1 = str_replace(".",",", $variable1);
echo "Wasserist".$variable1;

$variable2 = str_replace(array(" ", ";"), "", $variable2);
$variable2 = str_replace(".",",", $variable2);
echo "SollWarm".$variable2;

$variable3 = str_replace(array(" ", ";"), "", $variable3);
$variable3 = str_replace(".",",", $variable3);
echo "Außentemp".$variable3;

$variable4 = str_replace(array(" ", ";"), "", $variable4);
$variable4 = str_replace(".",",", $variable4);
echo "Vorlauf".$variable4;

$variable5 = str_replace(array(" ", ";"), "", $variable5);
$variable5 = str_replace(".",",", $variable5);
echo "Rücklauf".$variable5;

$variable6 = str_replace(array(" ", ";"), "", $variable6);
$variable6 = str_replace(".",",", $variable6);
echo "Rücklaufsoll".$variable6;

$variable7 = str_replace(array(" ", ";"), "", $variable7);
$variable7 = str_replace(".",",", $variable7);
echo "Wärmeein".$variable7;

$variable8 = str_replace(array(" ", ";"), "", $variable8);
$variable8 = str_replace(".",",", $variable8);
echo "Wärmeaus".$variable8;


// Variablen in IP-Symcon speichern
SetValue(12216 /* ID der Variable 1 */, $variable1);
SetValue(24615 /* ID der Variable 2 */, $variable2);
SetValue(21404 /* ID der Variable 3 */, $variable3);
SetValue(23517 /* ID der Variable 4 */, $variable4);
SetValue(34070 /* ID der Variable 5 */, $variable5);
SetValue(36609 /* ID der Variable 6 */, $variable6);
SetValue(48005 /* ID der Variable 7 */, $variable7);
SetValue(35039 /* ID der Variable 8 */, $variable8);


// Erfolgsmeldung ausgeben
echo "Daten wurden erfolgreich in Variablen gespeichert!";

// Funktion zum Extrahieren des Werts aus dem HTML-Code
function getHTMLValue($html, $startPattern, $endTag) {
    $startPos = strpos($html, $startPattern);
    if ($startPos === false) {
        return null;
    }

    $startPos += strlen($startPattern);
    $endPos = strpos($html, $endTag, $startPos);
    if ($endPos === false) {
        return null;
    }

    $value = substr($html, $startPos, $endPos - $startPos);

    // HTML-Tags entfernen
    $value = strip_tags($value);

    return $value;
}
?>

I was trying with chatgpt for tranform it into Home Assistant but I didn’t succeed.

The actual configuration.yaml looks like this:

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

logger:
  default: warning
  logs:
    homeassistant.components.lcn: warning
    pypck.connection: warning
    homeassistant.components.scrape: debug

sensor:
  - platform: rest
    resource: "http://192.168.1.63/http/index/j_operatingdata.html"
    name: "Weishaupt Außentemperatur"
    value_template: "{{ value | regex_findall_index('Aussentemperatur</td>\\s*<td align=\"right\">(\\d+\\.\\d+)</td>', 0) }}"
    unit_of_measurement: "°C"
    scan_interval: 60
    headers:
      User-Agent: Mozilla/5.0

There is still an error in the protocolls:

Logger: homeassistant.helpers.entity
Quelle: helpers/entity.py:942
Erstmals aufgetreten: 11:18:37 (1116 Vorkommnisse)
Zuletzt protokolliert: 17:29:38

Update for sensor.weishaupt_aussentemperatur fails
Update for sensor.weishaupt_warmwasser_solltemperatur2 fails
Update for sensor.weishaupt_aussentemperatur2 fails
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 942, in async_update_ha_state
await self.async_device_update()
File “/usr/src/homeassistant/homeassistant/helpers/entity.py”, line 1300, in async_device_update
await self.async_update()
File “/usr/src/homeassistant/homeassistant/components/rest/entity.py”, line 64, in async_update
self._update_from_rest_data()
File “/usr/src/homeassistant/homeassistant/components/rest/sensor.py”, line 176, in _update_from_rest_data
value = self._value_template.async_render_with_possible_json_value(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/helpers/template.py”, line 805, in async_render_with_possible_json_value
render_result = _render_with_context(
^^^^^^^^^^^^^^^^^^^^^
File “/usr/src/homeassistant/homeassistant/helpers/template.py”, line 2729, in _render_with_context
return template.render(**kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^
File “/usr/local/lib/python3.12/site-packages/jinja2/environment.py”, line 1304, in render
self.environment.handle_exception()
File “/usr/local/lib/python3.12/site-packages/jinja2/environment.py”, line 939, in handle_exception
raise rewrite_traceback_stack(source=source)
File “”, line 1, in top-level template code
File “/usr/src/homeassistant/homeassistant/helpers/template.py”, line 2446, in regex_findall_index
return regex_findall(value, find, ignorecase)[index]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^
IndexError: list index out of range

Has anybody an idea how to get the information into variables on home-assistant?

Hier noch der Auszug aus der html-Datei

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- saved from url=(0051)http://192.168.1.63/http/index/j_operatingdata.html -->
<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<!--tagparser="/pcotagfilt"-->
  
  <meta http-equiv="refresh" content="30;URL=j_operatingdata.html">
  <link rel="SHORTCUT ICON" href="http://192.168.1.63/http/index_img/favicon.ico">
  <link rel="stylesheet" type="text/css" href="./diagnostic_files/styles.css">
  <title>diagnostic</title>
  <script type="text/javascript" src="./diagnostic_files/javascript_757c080409.js.Herunterladen"></script>
  <script type="text/javascript" src="./diagnostic_files/language.js.Herunterladen"></script><script type="text/javascript" src="./diagnostic_files/de_language.js.Herunterladen">
</head>
<body>
<script type="text/javascript" language="JavaScript" src="../script/pagefunctions.js"></script>
<link id="nordvpn-contentScript-extension-fonts" rel="stylesheet" href="./diagnostic_files/css"></head><body><a name="oben"></a>
<div class="logo"><a id="link" href="http://192.168.1.63/http/index/j_operatingdata.html"><img id="logo" src="./diagnostic_files/logo.gif" border="0" height="31" alt="" width="153"></a>
<script type="text/javascript">
document.getElementById('link').href=Linkadresse;
document.getElementById('logo').alt=Logo;
document.getElementById('logo').height=LogoH;
document.getElementById('logo').width=LogoW;
</script>
</div>
<!-- logo -->
<div class="sprachen">
<a>
<script>var date=new Array(3);
            date[0]=28;
            date[1]=10;
            date[2]=24;
            date[3]=("20");
            for (i=0;i<3;i++) {if (date[i]<10) date[i]="0"+date[i]}
            var date1=date[0]+"."+date[1]+"."+date[3]+date[2];
            document.writeln(date1);</script>28.10.2024
&nbsp;
       <script>var time=new Array(2);
            time[0]=9;
            time[1]=39;
            for (i=0;i<2;i++) {if (time[i]<10) time[i]="0"+time[i]}
            var time1=time[0]+":"+time[1];
            document.writeln(time1);</script>09:39

       <script>document.writeln(Uhr);</script>Uhr

</a>
</div>
<div class="weisserkasten">
<div class="suche">
<a id="hilfe" class="oben" rel="nofollow" target="_blank" href="http://192.168.1.63/http/index/j_operatingdata.html"><script>document.write(Hilfe);</script></a>
<a id="mail" class="oben" rel="nofollow" href="http://192.168.1.63/http/index/j_operatingdata.html"><script>document.write(emailkontakt);</script></a>
<script type="text/javascript">
document.getElementById('mail').href=Linkemailadresse;
document.getElementById('hilfe').href=Linkhilfe;
</script>
</div>
<br>
</div>
<div class="grauekaesten">
<div class="rotekaesten_unter">
<div class="hauptmenue">
<a href="http://192.168.1.63/http/index/j_index.html" id="startseite" title="Startseite"><script>document.write(Startseite);</script>Startseite</a>
<script type="text/javascript">
document.getElementById('startseite').title=Startseite;
</script>
<a href="http://192.168.1.63/http/index/j_clock.html" id="einstellungen" title="Einstellungen"><script>document.write(Einstellungen);</script>Einstellungen</a>
<script type="text/javascript">
document.getElementById('einstellungen').title=Einstellungen;
</script>
<a href="http://192.168.1.63/http/index/j_operatingdata.html" id="betriebsdaten" class="aktiv" title="Betriebsdaten"><script>document.write(Betriebsdaten);</script>Betriebsdaten</a>
<script type="text/javascript">
document.getElementById('betriebsdaten').title=Betriebsdaten;
</script>
<a href="http://192.168.1.63/http/index/j_history.html" id="historie" title="Historie"><script>document.write(Historie);</script>Historie</a>
<script type="text/javascript">
document.getElementById('historie').title=Historie;
</script>
<a href="http://192.168.1.63/http/index/j_service.html" id="service" title="Service"><script>document.write(Service);</script>Service</a>
<script type="text/javascript">
document.getElementById('service').title=Service;
</script>
<a href="http://192.168.1.63/http/index/j_contact.html" id="AZKontakt" title="Kontakt" style="display: none;"><script>document.write(Kontakt);</script>Kontakt</a>
<script type="text/javascript">
document.getElementById('AZKontakt').title=Kontakt;
var anz = '0';
if (anz == 1)
document.getElementById('AZKontakt').value = "";
else
document.getElementById('AZKontakt').style.display = 'none';
</script>
</div>
<!-- hauptmenue -->
<div class="zentral_unter" xstyle="border: 1px solid #FF0000; width: 950px">
<div class="untermenue1"></div>
<!-- untermenue1 -->
<div class="untermenue2">
<div class="untermenue2innen">
<ul class="eins">
</ul>
</div>
</div>
<!-- untermenue2 -->
<div class="inhalt">
<div class="csc-textpic csc-textpic-intext-right csc-textpic-border">
<div class="csc-textpic-imagewrap">
<dl class="csc-textpic-image csc-textpic-firstcol csc-textpic-lastcol" style="width: 252px;">
  <dd class="csc-textpic-caption"></dd>
</dl>
</div>
<div class="csc-textpic-text">
<h1>
<script>document.writeln(Betriebsdaten);</script>Betriebsdaten
</h1>
</div>
</div>
<div class="produkt">
<div class="csc-frame csc-frame-invisible">
<div class="csc-textpic csc-textpic-intext-left-nowrap">
<div style="margin-left: 5px;">
<div class="csc-textpic-text">
<div class="div_terminologieliste">
<table cellpadding="1" cellspacing="0" width="680">
 <tbody>
  <tr class="header">
   <td bgcolor="#dddddd" width="50%">
    <h3>
    <script>document.write(Beschreibung);</script>Beschreibung</h3>
   </td>
   <td align="right" bgcolor="#dddddd" width="30%">
    <h3>
    <script>document.writeln(AktuellerWert);</script>Aktueller Wert
</h3>
   </td>
   <td bgcolor="#dddddd" width="15%"></td>
   <td bgcolor="#dddddd" width="5%"></td>
  </tr>
<!-- Aussentemperatur -->
<tr>
 <td><script>document.write(Aussentemperatur);</script>Aussentemperatur</td>
 <td align="right">12.1</td>
 <td>°C</td>
 <td></td>
</tr>

just solved it with using node-RED instead