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>°C"); //Isttemperatur Warmwasser
$variable2 = getHTMLValue($html, "writeln(Warmwasser);document.write(Solltemperatur)", "<td>°C"); //Solltemperatur Warmwasser
$variable3 = getHTMLValue($html, "write(Aussentemperatur)", "<td>°C"); //Außentemperatur
$variable4 = getHTMLValue($html, "write(Vorlauftemperatur)", "<td>°C"); //Vorlauftemperatur
$variable5 = getHTMLValue($html, "writeln(Ruecklauftemperatur);document.write(HkEins)", "<td>°C"); //Rücklauftemperatur
$variable6 = getHTMLValue($html, "writeln(Ruecklaufsolltemperatur);document.write(HkEins)", "<td>°C"); //Rücklaufsolltemperatur
$variable7 = getHTMLValue($html, "write(Wuelleneintritt)", "<td>°C"); //Wärmequelleneintritt
$variable8 = getHTMLValue($html, "write(Wuellenaustritt)", "<td>°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?