My concern is almost more of a pipe dream than possible in reality, but I’ll try here. I have a semi smart heating control. This can be called up within the network via the IP address of the controller. An interface opens which allows reading sensors, changing settings, etc. (like that, but its just a demo here https://myhdg-demo.hdg-bavaria.com). I would like to integrate these sensors into smart home, but the company offers absolutely no documentation and no API. Is there a simple way to pick up all the changing values via the IP address of the heating control and integrate them as sensors? I have no idea how I would address the actual sensors, I would need something that would figure this out on its own. It has to work somehow, otherwise I wouldn’t be able to read these values via the IP address in this “HDG Control” environment. Or am I wrong? Thank you for your help!
If that demo page is exactly as your local system presents it, then you can use a scrape sensor to pull individual values, as the numbers you want are in the HTML.
Do a right-click / View Source on your web page (not through F12 / DevTools) and see if you can see the numbers. For example, the Heizkessel page (HDG WebControl) on that demo has this at line 73:
<div class="canvasInfoContainer" style=" left:63.5%; top:55.925925925926%; ">
<div class="canvasInvoText" title="Kesseltemperatur">
<span data-id="22003" data-type="text" class="live">78 °C</span>
</div>
</div>
That can be pulled out in a scrape sensor with a select
of:
div[title="Kesseltemperatur"] span
and a value_template
(to strip out the °C) of:
{{ value|select('in','-.0123456789')|join }}
However, if the values are dynamically-populated — not in the HTML as loaded, but pulled in via XMLHTTP / Ajax — it will be more complicated and you’ll have to see what network requests are being made to get the data, using DevTools in your browser.
Well, that did work pretty well with your explanation, thank you! I used these settings at the beginning:
Only one problem, he imports the current value (101 Celsius), but now it looks like its stuck there, even if it dropped to 95 in the last 5 minutes according the HDG interface, so it seems he doesnt reload it in home assistant, am I understanding this right? How can I solve this? Or is he looking only every 10 minutes?
Unfortunately, I don’t think you can change the default 10 minute refresh on scrape sensors created via the UI. You have two options:
- Create an automation that forces an update more frequently (Time pattern trigger of
\2
for example, no condition, action to call servicehomeassistant.update_entity
) - Delete the UI scrape sensor and re-create in
configuration.yaml
:
scrape:
- resource: http://192.168.178.94/index.php?hdg_group=1
sensor:
- name: Kesseltemperatur
select: "div[title='Kesseltemperatur'] span"
value_template: "{{ value|select('in','-.0123456789')|join }}"
device_class: temperature
unit_of_measurement: "°C"
That made it work for me, thank you very much!
scrape:
- resource: http://192.168.178.94/index.php?hdg_group=1
scan_interval: 60
sensor:
- name: KesseltemperaturV1
select: "div[title='Kesseltemperatur'] span"
value_template: "{{ value|select('in','-.0123456789')|join }}"
device_class: temperature
unit_of_measurement: "°C"
I have to add one question, they used special characters as an title of an sensor. It seems, that special charaters are a problem? How can I solve this?
- name: sensor_HDG_OG_Radiatoren_Vorlauftemperatur
select: "div[title='Vorlauffühler'] span"
value_template: "{{ value|select('in','-.0123456789')|join }}"
device_class: temperature
unit_of_measurement: "°C"
HTML entity ü
is u-umlaut. This should work:
select: "div[title='Vorlauffühler'] span"
or just avoid the problem:
select: "span[data-id='26000']"