Page 1 of 1

HTTP/HTTPS poller xml parser

Posted: Tuesday 22 November 2022 0:07
by damdub
Hello
I'm aiming to retrieve data from my heat pump. I'm using HTTP/HTTPS poller & an xml parser script.

The heat pump is providing data into an xml file.
The data from this xml wich I'm trying to retrieve is "ACTUAL TEMPERATURE 2"
Here is a litte portion of the xml file (which is pretty big) containing the "ACTUAL TEMPERATURE 2" data. Actual value which I want to retreive in domoticz is "22,1°C".

Code: Select all

<div class="clear"></div></div>
        <form id="werte" action="#" onsubmit="saveValues(this);return false;"><div id="content">
    <div class="span-11 append-1" style="float:left"><table class="info"><tr><th colspan="2" class="round-top">ROOM TEMPERATURE</th></tr>  <tr class="even">
    <td class="key">ACTUAL TEMPERATURE 2</td>
    <td class="value">22,1°C</td>
  </tr>


I've created a lua xml parser script which I want to use to retreive data and use it in domoticz

Code: Select all

s = request['content'];

local ACTUAL_TEMPERATURE_2 = domoticz_applyXPath(s,'<td class="key">ACTUAL TEMPERATURE 2</td><td class="value">(.-)</td>')

domoticz_updateDevice(343,'',ACTUAL_TEMPERATURE_2)
This is not working.
Domoticz logs show an error
" Error getting data from url"

Is there somebody who could help me correct my lua script ?
Thank you in advance

Re: HTTP/HTTPS poller xml parser

Posted: Tuesday 22 November 2022 0:17
by waltervl
Could be because it does not look like xml but html data.

The error could also be that it is not getting any data at all due to misconfiguration.

Re: HTTP/HTTPS poller xml parser

Posted: Tuesday 22 November 2022 1:14
by damdub
Hello and thank you for your reply

Maybe I'm wrong but I was confident taht it was xml, but maybe xml can be embedded in html ? Sorry for my incompetence

Here are the first lines of the file which I'm trying to parse.

Code: Select all

<?xml version="1.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" lang="de">
<head>
xml ? html ? parsable ? :?

Re: HTTP/HTTPS poller xml parser

Posted: Tuesday 22 November 2022 9:37
by waltervl
I am also no expert but normally xml does not have html statements in it.
I think you have to set the path to the value starting with head

Perhaps you can test it with an online Xpath tester: https://www.freeformatter.com/xpath-tester.html
Also take a look at the Xpath examples on the end of that page.

Re: HTTP/HTTPS poller xml parser

Posted: Friday 30 December 2022 13:16
by bewo
Hey damdub,

is your parser working? If not, there are multiple ways to parse your values.

First of all i would check if the heatpump gives you really an html answer. Maybe this is only the browser output.
Just post the whole answer from your heatpump und the request.

Then we'll get this. ;)