Manipulating XML with Node-Red

Hello,

Very newbie with node-red , I have a mechanically controlled dual-flow fan which generates an XML file containing informations such as temperatures or fan speeds.

With Node-Red, I get the values ​​I'm interested this way in debug node : payload.form.text[11]['value']

But how can i send the same isolated value to a HomeAssistant Node for example ?

Thank for help :slight_smile:

Can you post a snippet of your XML data?

My electricity company provides an XML file containing the date and qty (kwh) used. I pass through an XML node and then an JSONata expression to sort out the data I want. See my thread here.

Hello Grant,

Thank for help. Here is a sample, as new memeber i cannot send files :slight_smile:

<form>
<text>
<id>FanLevel</id>
<value>Nominale</value>
</text>
<text>
<id>VolumenstromZu</id>
<value>170 m3/h</value>
</text>
<text>
<id>VolumenstromAb</id>
<value>170 m3/h</value>
</text>
<text>
<id>DrehzahlZu</id>
<value>1493 rpm</value>
</text>
<text>
<id>DrehzahlAb</id>
<value>1105 rpm</value>
</text>
<text>
<id>FilterRestGeraet</id>
<value>0 Jour</value>
</text>
<text>
<id>FilterSchmutzGeraet</id>
<value>-</value>
</text>
<text>
<id>FilterRestAussen</id>
<value>-</value>
</text>
<text>
<id>FilterRestRaum</id>
<value>-</value>
</text>
<text>
<id>SollDruck</id>
<value>-</value>
</text>
<text>
<id>IstDruck</id>
<value>-</value>
</text>
<text>
<id>TempRaum</id>
<value>27.0 °C</value>
</text>
<text>
<id>T_AUL_vor_EWT</id>
<value>- °C</value>
</text>
<text>
<id>T_Lufteintritt</id>
<value>24.4 °C</value>
</text>
<text>
<id>T_Zuluft</id>
<value>24.6 °C</value>
</text>
<text>
<id>T_Abluft</id>
<value>27.0 °C</value>
</text>
<text>
<id>T_Fortluft</id>
<value>25.6 °C</value>
</text>
<text>
<id>RfIntern</id>
<value>49 %</value>
</text>
<text>
<id>Sensor1</id>
<value>-</value>
</text>
<text>
<id>Sensor2</id>
<value>-</value>
</text>
<text>
<id>Sensor3</id>
<value>-</value>
</text>
<text>
<id>Sensor4</id>
<value>-</value>
</text>
<text>
<id>SensorRfExtern</id>
<value>0 %</value>
</text>
<text>
<id>SensorLqExtern</id>
<value>0 ppm</value>
</text>
<text>
<id>Fan_State1</id>
<value>marche</value>
</text>
<text>
<id>Fan_State2</id>
<value>marche</value>
</text>
<text>
<id>BypassZustand</id>
<value>ouvert</value>
</text>
<text>
<id>VhrZustand</id>
<value>-</value>
</text>
<text>
<id>SchaltBasis</id>
<value>arrêt</value>
</text>
<text>
<id>ZoneZustand</id>
<value>-</value>
</text>
<text>
<id>SoleZp1</id>
<value>-</value>
</text>
<text>
<id>LuftZp1</id>
<value>-</value>
</text>
<text>
<id>NhrZp1</id>
<value>-</value>
</text>
<text>
<id>BSTD_FL</id>
<value>257 h</value>
</text>
<text>
<id>BSTD_RL</id>
<value>1 h</value>
</text>
<text>
<id>BSTD_NL</id>
<value>13006 h</value>
</text>
<text>
<id>BSTD_IL</id>
<value>1496 h</value>
</text>
<text>
<id>BSTD_Luftgesamt</id>
<value>14760 h</value>
</text>
<text>
<id>BSTD_Schaltkontakt</id>
<value>0 h</value>
</text>
<text>
<id>BSTD_SoleUwp</id>
<value>-</value>
</text>
<text>
<id>BSTD_Zone</id>
<value>-</value>
</text>
<text>
<id>BSTD_LuftEwt</id>
<value>-</value>
</text>
<text>
<id>BSTD_Nhr</id>
<value>-</value>
</text>
<text>
<id>SwVersionLT</id>
<value>1.2.4</value>
</text>
<text>
<id>SwVersionBDE</id>
<value>-</value>
</text>
<text>
<id>SwVersionSnr</id>
<value>M202795221JHAZR19417</value>
</text>
<text>
<id>InetDhcp</id>
<value>Statique</value>
</text>
<text>
<id>InetIp</id>
<value>192.168.10.210</value>
</text>
<text>
<id>InetSubnet</id>
<value>255.255.255.0</value>
</text>
<text>
<id>InetGateway</id>
<value>192.168.10.1</value>
</text>
<text>
<id>InetDns</id>
<value>192.168.10.1</value>
</text>
<text>
<id>InetStatusServer</id>
<value>connecté</value>
</text>
<text>
<id>EnOceanDev1</id>
<value>-</value>
</text>
<text>
<id>EnOceanDev2</id>
<value>-</value>
</text>
<text>
<id>EnOceanDev3</id>
<value>-</value>
</text>
<text>
<id>EnOceanDev4</id>
<value>-</value>
</text>
<text>
<id>EnOceanDev5</id>
<value>-</value>
</text>
<text>
<id>EnOceanDev6</id>
<value>-</value>
</text>
<text>
<id>EnOceanDev7</id>
<value>-</value>
</text>
<text>
<id>EnOceanDev8</id>
<value>-</value>
</text>
<text>
<id>aktuellesDatum</id>
<value>27.07.2022 11:43</value>
</text>
<text>
<id>Sensor1Typ</id>
<value>-</value>
</text>
<text>
<id>Sensor1Benennung</id>
<value>-</value>
</text>
<text>
<id>Sensor2Typ</id>
<value>-</value>
</text>
<text>
<id>Sensor2Benennung</id>
<value>-</value>
</text>
<text>
<id>Sensor3Typ</id>
<value>-</value>
</text>
<text>
<id>Sensor3Benennung</id>
<value>-</value>
</text>
<text>
<id>Sensor4Typ</id>
<value>-</value>
</text>
<text>
<id>Sensor4Benennung</id>
<value>-</value>
</text>
<text>
<id>EnOceanDev1Value</id>
<value>Aucune valeur de mesure</value>
</text>
<text>
<id>EnOceanDev2Value</id>
<value>Aucune valeur de mesure</value>
</text>
<text>
<id>EnOceanDev3Value</id>
<value>Aucune valeur de mesure</value>
</text>
<text>
<id>EnOceanDev4Value</id>
<value>Aucune valeur de mesure</value>
</text>
<text>
<id>EnOceanDev5Value</id>
<value>Aucune valeur de mesure</value>
</text>
<text>
<id>EnOceanDev6Value</id>
<value>Aucune valeur de mesure</value>
</text>
<text>
<id>EnOceanDev7Value</id>
<value>Aucune valeur de mesure</value>
</text>
<text>
<id>EnOceanDev8Value</id>
<value>Aucune valeur de mesure</value>
</text>
</form>

With payload.form.text[11]['value'] i can get TempRaum value = 27.0 °C in a debug node.

Do you get your XML file via HTTP GET? If yes, can you create a flow like this and show the output?

(in the debug pane, drill down to where you see the 27.0 value that you are seeking, and include that in a screenshot like I have done above with 1203 in my example)

Here is my flow :

[{"id":"39bdcd93b658df8c","type":"xml","z":"49a1a4b3849268a9","name":"","property":"payload","attr":"","chr":".text[11]","x":530,"y":440,"wires":[["e51da240e962975a"]]},{"id":"59e64e939a96fc12","type":"http request","z":"49a1a4b3849268a9","name":"VMC Maico WS320 detail.cgx","method":"GET","ret":"txt","paytoqs":"ignore","url":"http://192.168.10.210/details.cgx","tls":"","persist":false,"proxy":"","authType":"basic","senderr":false,"headers":[],"x":310,"y":440,"wires":[["39bdcd93b658df8c"]]},{"id":"e51da240e962975a","type":"debug","z":"49a1a4b3849268a9","name":"T° référence pièce","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.form.text[11]['value']","targetType":"msg","statusVal":"","statusType":"auto","x":590,"y":500,"wires":[]},{"id":"6e4057f7343692e7","type":"inject","z":"49a1a4b3849268a9","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":80,"y":440,"wires":[["59e64e939a96fc12"]]}]

All depends what output you require, here are some examples

[{"id":"6e4057f7343692e7","type":"inject","z":"30af2d3e.d94ea2","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":210,"y":60,"wires":[["4214fb45.4b7354"]]},{"id":"4214fb45.4b7354","type":"template","z":"30af2d3e.d94ea2","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<form>\n<text>\n<id>FanLevel</id>\n<value>Nominale</value>\n</text>\n<text>\n<id>VolumenstromZu</id>\n<value>170 m3/h</value>\n</text>\n<text>\n<id>VolumenstromAb</id>\n<value>170 m3/h</value>\n</text>\n<text>\n<id>DrehzahlZu</id>\n<value>1493 rpm</value>\n</text>\n<text>\n<id>DrehzahlAb</id>\n<value>1105 rpm</value>\n</text>\n<text>\n<id>FilterRestGeraet</id>\n<value>0 Jour</value>\n</text>\n<text>\n<id>FilterSchmutzGeraet</id>\n<value>-</value>\n</text>\n<text>\n<id>FilterRestAussen</id>\n<value>-</value>\n</text>\n<text>\n<id>FilterRestRaum</id>\n<value>-</value>\n</text>\n<text>\n<id>SollDruck</id>\n<value>-</value>\n</text>\n<text>\n<id>IstDruck</id>\n<value>-</value>\n</text>\n<text>\n<id>TempRaum</id>\n<value>27.0 °C</value>\n</text>\n<text>\n<id>T_AUL_vor_EWT</id>\n<value>- °C</value>\n</text>\n<text>\n<id>T_Lufteintritt</id>\n<value>24.4 °C</value>\n</text>\n<text>\n<id>T_Zuluft</id>\n<value>24.6 °C</value>\n</text>\n<text>\n<id>T_Abluft</id>\n<value>27.0 °C</value>\n</text>\n<text>\n<id>T_Fortluft</id>\n<value>25.6 °C</value>\n</text>\n<text>\n<id>RfIntern</id>\n<value>49 %</value>\n</text>\n<text>\n<id>Sensor1</id>\n<value>-</value>\n</text>\n<text>\n<id>Sensor2</id>\n<value>-</value>\n</text>\n<text>\n<id>Sensor3</id>\n<value>-</value>\n</text>\n<text>\n<id>Sensor4</id>\n<value>-</value>\n</text>\n<text>\n<id>SensorRfExtern</id>\n<value>0 %</value>\n</text>\n<text>\n<id>SensorLqExtern</id>\n<value>0 ppm</value>\n</text>\n<text>\n<id>Fan_State1</id>\n<value>marche</value>\n</text>\n<text>\n<id>Fan_State2</id>\n<value>marche</value>\n</text>\n<text>\n<id>BypassZustand</id>\n<value>ouvert</value>\n</text>\n<text>\n<id>VhrZustand</id>\n<value>-</value>\n</text>\n<text>\n<id>SchaltBasis</id>\n<value>arrêt</value>\n</text>\n<text>\n<id>ZoneZustand</id>\n<value>-</value>\n</text>\n<text>\n<id>SoleZp1</id>\n<value>-</value>\n</text>\n<text>\n<id>LuftZp1</id>\n<value>-</value>\n</text>\n<text>\n<id>NhrZp1</id>\n<value>-</value>\n</text>\n<text>\n<id>BSTD_FL</id>\n<value>257 h</value>\n</text>\n<text>\n<id>BSTD_RL</id>\n<value>1 h</value>\n</text>\n<text>\n<id>BSTD_NL</id>\n<value>13006 h</value>\n</text>\n<text>\n<id>BSTD_IL</id>\n<value>1496 h</value>\n</text>\n<text>\n<id>BSTD_Luftgesamt</id>\n<value>14760 h</value>\n</text>\n<text>\n<id>BSTD_Schaltkontakt</id>\n<value>0 h</value>\n</text>\n<text>\n<id>BSTD_SoleUwp</id>\n<value>-</value>\n</text>\n<text>\n<id>BSTD_Zone</id>\n<value>-</value>\n</text>\n<text>\n<id>BSTD_LuftEwt</id>\n<value>-</value>\n</text>\n<text>\n<id>BSTD_Nhr</id>\n<value>-</value>\n</text>\n<text>\n<id>SwVersionLT</id>\n<value>1.2.4</value>\n</text>\n<text>\n<id>SwVersionBDE</id>\n<value>-</value>\n</text>\n<text>\n<id>SwVersionSnr</id>\n<value>M202795221JHAZR19417</value>\n</text>\n<text>\n<id>InetDhcp</id>\n<value>Statique</value>\n</text>\n<text>\n<id>InetIp</id>\n<value>192.168.10.210</value>\n</text>\n<text>\n<id>InetSubnet</id>\n<value>255.255.255.0</value>\n</text>\n<text>\n<id>InetGateway</id>\n<value>192.168.10.1</value>\n</text>\n<text>\n<id>InetDns</id>\n<value>192.168.10.1</value>\n</text>\n<text>\n<id>InetStatusServer</id>\n<value>connecté</value>\n</text>\n<text>\n<id>EnOceanDev1</id>\n<value>-</value>\n</text>\n<text>\n<id>EnOceanDev2</id>\n<value>-</value>\n</text>\n<text>\n<id>EnOceanDev3</id>\n<value>-</value>\n</text>\n<text>\n<id>EnOceanDev4</id>\n<value>-</value>\n</text>\n<text>\n<id>EnOceanDev5</id>\n<value>-</value>\n</text>\n<text>\n<id>EnOceanDev6</id>\n<value>-</value>\n</text>\n<text>\n<id>EnOceanDev7</id>\n<value>-</value>\n</text>\n<text>\n<id>EnOceanDev8</id>\n<value>-</value>\n</text>\n<text>\n<id>aktuellesDatum</id>\n<value>27.07.2022 11:43</value>\n</text>\n<text>\n<id>Sensor1Typ</id>\n<value>-</value>\n</text>\n<text>\n<id>Sensor1Benennung</id>\n<value>-</value>\n</text>\n<text>\n<id>Sensor2Typ</id>\n<value>-</value>\n</text>\n<text>\n<id>Sensor2Benennung</id>\n<value>-</value>\n</text>\n<text>\n<id>Sensor3Typ</id>\n<value>-</value>\n</text>\n<text>\n<id>Sensor3Benennung</id>\n<value>-</value>\n</text>\n<text>\n<id>Sensor4Typ</id>\n<value>-</value>\n</text>\n<text>\n<id>Sensor4Benennung</id>\n<value>-</value>\n</text>\n<text>\n<id>EnOceanDev1Value</id>\n<value>Aucune valeur de mesure</value>\n</text>\n<text>\n<id>EnOceanDev2Value</id>\n<value>Aucune valeur de mesure</value>\n</text>\n<text>\n<id>EnOceanDev3Value</id>\n<value>Aucune valeur de mesure</value>\n</text>\n<text>\n<id>EnOceanDev4Value</id>\n<value>Aucune valeur de mesure</value>\n</text>\n<text>\n<id>EnOceanDev5Value</id>\n<value>Aucune valeur de mesure</value>\n</text>\n<text>\n<id>EnOceanDev6Value</id>\n<value>Aucune valeur de mesure</value>\n</text>\n<text>\n<id>EnOceanDev7Value</id>\n<value>Aucune valeur de mesure</value>\n</text>\n<text>\n<id>EnOceanDev8Value</id>\n<value>Aucune valeur de mesure</value>\n</text>\n</form>","output":"str","x":400,"y":60,"wires":[["39bdcd93b658df8c"]]},{"id":"39bdcd93b658df8c","type":"xml","z":"30af2d3e.d94ea2","name":"","property":"payload","attr":"","chr":".text[11]","x":590,"y":40,"wires":[["e51da240e962975a","18d3af5f.158df1","790cc238.06b2d4"]]},{"id":"e51da240e962975a","type":"debug","z":"30af2d3e.d94ea2","name":"the complete payload","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":760,"y":100,"wires":[]},{"id":"18d3af5f.158df1","type":"change","z":"30af2d3e.d94ea2","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"$$.payload.form.text[id[0] = \"TempRaum\"].value.$number($split($,\" \")[0])","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":820,"y":20,"wires":[["6cbc0bfb.9d17bc"]]},{"id":"790cc238.06b2d4","type":"change","z":"30af2d3e.d94ea2","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.form.text[11].value[0]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":800,"y":60,"wires":[["526f4675.7627c"]]},{"id":"6cbc0bfb.9d17bc","type":"debug","z":"30af2d3e.d94ea2","name":"value converted to number","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1080,"y":20,"wires":[]},{"id":"526f4675.7627c","type":"debug","z":"30af2d3e.d94ea2","name":"value as is","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1030,"y":60,"wires":[]}]

I put your http request output in a template as others will not have access to your http data, this makes it easier for others to help and test their replies.

Thank you very much !!

Next step is send it to a mqtt sensor in home assistant :slight_smile:

Just a question, how to convert to decimal ? In your sample 28.2 become 28 :slight_smile:

it doe not here, show us how you implemented it.

Strange... I found how to get decimal with :
$$.payload.form.text[id[0] = "T_Fortluft"].value.$split($," ")[0]

Strange, that how i showed you in the example, except you are know leaving it as a string, not a number/float(decimal)

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.