Input a xml structure from a remote data logger

Hi all :grinning:
how can i use a xml structure from a rermote data-logger in emoncms ?
is it possible? the logger has an api and i get the following result as xml:

<sensor>
    <id>104</id>
    <name>Temperatur Batterie</name>
    <current>23.37</current>
    <unit>°C</unit>
    <minmax>
        <today>
            <min>
                <value>22.75</value>
                <date>03.05.2020 00:02:01</date>
                <timestamp>1588456921</timestamp>
            </min>
            <max>
                <value>23.43</value>
                <date>03.05.2020 08:12:05</date>
                <timestamp>1588486325</timestamp>
            </max>
        </today>
        <absolute>
            <min>
                <value>13.50</value>
                <date>04.12.2015 07:23:21</date>
                <timestamp>1449210201</timestamp>
            </min>
            <max>
                <value>32.43</value>
                <date>14.01.2020 13:24:11</date>
                <timestamp>1579004651</timestamp>
            </max>
        </absolute>
    </minmax>
</sensor>

i would like to show the temperatur in emoncms. emoncms is installed on raspberry.
Thanks in advance!
Johann

Summary

This text will be hidden

Summary

This text will be hidden

Edit by Mod to format XML

Hi Johann, welcome.

No there isn’t. You would need to process it first; Node-RED and Home Assistant have some builtin methods. Alternatively a Python script.

Have you looked to see if there is an option to tell the API to give you the data as JSON? Even then it will need processing into Key:Value pairs.

Hi Brian, first, thanks for the feedback. currently i convert the xml request into a json format with a php function. Now when i call the covert-script, the output is the following:

{“sensor”:{“id”:“104”,“name”:“Temperatur Batterie”,“current”:“23.81”,“unit”:"\u00b0C",“minmax”:{“today”:{“min”:{“value”:“21.81”,“date”:“03.05.2020 08:32:47”,“timestamp”:“1588487567”},“max”:{“value”:“23.87”,“date”:“03.05.2020 12:21:01”,“timestamp”:“1588501261”}},“absolute”:{“min”:{“value”:“13.50”,“date”:“04.12.2015 07:23:21”,“timestamp”:“1449210201”},“max”:{“value”:“32.43”,“date”:“14.01.2020 13:24:11”,“timestamp”:“1579004651”}}}}}

but how can i make a input in emoncms?
Many Thanks! Regards Johann

On the ‘Inputs’ page, top right,
image
Click on the API help.

You can either input via MQTT or HTTP API.

Both will take a JSON structure - the structure is listed there.

{"power1":100,"power2":200,"power3":300,"time":"2020-05-03T10:58:08+00:00"}

Time can be in epoch format as you have. If you do not specify a time, the received time is used.

MQTT topic format is emon/node/sensor

ah ok, thanks! i try with the url:
192.168.178.11/emoncms/input/post?node=emontx&fulljson=http://localhost/xmltojson.php&apikey=66xxxxxe9xx6fxxxxx3xx3e461xxxxx8

but the request failed with the message:
{“success”: false, “message”: “Input in not a valid JSON object”}

Do you have an idea whats wrong?

Yes, unless you changed the data above it does not match the required structure!

edit

fulljson=http://localhost/xmltojson.php

I am not sure this will work… although interesting if it does.