Hi everyone,
I got a smart meter which provides a XML-formatted endpoint to read all interesting values (used energy, produced by solar, energy returned to grid, …) and I am trying to make use of these values by integrating them in my HomeAssistant using the RESTful integration. Unfortunately this XML-format is not easily compatible with this json_path + json_attributes approach and I am not experienced enough with templating to figure out how to properly bind these values to sensor entities.
The XML looks something like this:
<values>
<value id="toGridValue">0.31 kW</value>
<value id="dateValue">2021-08-18</value>
<value id="timeValue">23:05:52 Uhr</value>
...
</values>
which will result in a JSON like this:
{
"values": {
"value": [
{
"#text": "0.37 kW",
"@id": "toGridValue"
},
{
"#text": "2021-08-18",
"@id": "dateValue"
},
{
"#text": "21:42:25 Uhr",
"@id": "timeValue"
},
...
]
}
}
I could manually select a single metric using a json path like this $.values.value[?(@['@id'] == 'toGridValue')]['#text']
but this would mean I would have to fetch/query this endpoint for each and every metric I want to use instead of querying it just once and make use of all values. I just have no clue how to do this since the examples I found all have a resource that is structured in a way that can be used easier (e.g.: https://michilehr.de/how-to-integrate-an-external-api-into-home-assistant-an-example-with-the-ambee-pollen-api)
Could someone help me out and/or point me in the right direction?
Thanks in advance!