Hello there,
once again I have a flow to read values from my Heating-Systems Web-UI an puts the data into an SQL-DB. First part to the problem was solved by @E1cid (thank you again) here: html-parce-to-sql-flow-optimization
Unfortunately there are other pages with different structure, where the desired values are not in the plain HTML.
The HTML look like:
<div class="span-7 ialigned">
<h3 class="title">RAUMTEMP. NACHT</h3>
</div>
<div class="values span-7">
<div class="editors">
<a onmousedown="change('val7','+',10,30,'0.1',true);return false;" href="javascript://">
<img src="./pics/button_higher.png">
</a>
<a id="editorslower" onmousedown="change('val7','-',10,30,'0.1',true);return false;" href="javascript://" style="clear:left;">
<img src="./pics/button_lower.png">
</a>
</div>
<input type="text" tabindex="2" value="" name="val7" id="val7" class="edit upndown" style="width:3.6em">
<script language="javascript" type="text/javascript">
valSettings['val7'] = new Array();
valSettings['val7']['type'] = 'float'; valSettings['val7']['min'] = '10';
valSettings['val7']['max'] = '30';
jsvalues['7'] = new Array();
jsvalues['7']['id']='val7';
jsvalues['7']['val']='21,5';
</script>
</div>
<div class="values span-1 append-1">°C</div>
<div class="green round-right span-8 last">
<p>Gültige Werte: Eingabe zwischen<br />10 °C und 30 °C</p>
</div>
</div> <div class="calibration round span-24 last" id="calval58">
I want to get "RAUMTEMP. NACHT" and the corresponding Value "21,5".
My current try looks like:
[
{
"id": "092ceda1e64fd139",
"type": "html",
"z": "cb085eef1cd8e696",
"name": "",
"property": "payload",
"outproperty": "payload",
"tag": "script.val, .title",
"ret": "text",
"as": "single",
"x": 400,
"y": 320,
"wires": [
[
"83830f8dcc177657",
"e1b27dd0d724abbc"
]
]
},
{
"id": "83830f8dcc177657",
"type": "function",
"z": "cb085eef1cd8e696",
"name": "parse http",
"func": "const output = {};\nfor(let i = 0; i < msg.payload.length; i += 2){\n let value = parseFloat(msg.payload[i+1].replace(\",\", \".\"))\n if(isNaN(value)) value = 0;\n let key = msg.payload[i].replace(/[^A-Za-z0-9]+/g,\" \").trim().replace(/\\s/g, \"_\");\n output[key] = value\n}\n\nmsg.payload = output;\n\nmsg.topic = \"task8\";\n\nreturn msg;\n",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 560,
"y": 320,
"wires": [
[
"199c9a19fd72d8bb",
"bec8eab33bfc6b0c"
]
]
},
{
"id": "7519ac97c48ffcc9",
"type": "http request",
"z": "cb085eef1cd8e696",
"name": "LWZ",
"method": "GET",
"ret": "txt",
"paytoqs": "ignore",
"url": "192.168.2.120/?s=4,0",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [],
"x": 230,
"y": 320,
"wires": [
[
"092ceda1e64fd139",
"690670859ec91b41"
]
]
}
]
With that I get the "titles" quite well but I couldn't manage to get the value
If someone is willing to help me any advice is highly appreciated.
Best Regards
Michael