@thinx wrote:
Hi there,
I’m trying to read the XML data from my solar inverter to be able to get the live yield from it. After retrieving the XML, HA converts it to JSON but the attributes are prefixed with an @ character. When trying to parse that into a value, the template development tool throws an error:
Error rendering template: TemplateSyntaxError: unexpected char ‘@’ at 520
I did everything I can think of using my own knowledge (escaping and so) but it ends here and I need help from the community.
value template
value_template: ‘{{ states.sensor.solar_inverter.attributes[“root”].Device.Measurements.Measurement[2].@Value }}’
HA converted XML to JSON
{
“root”: {
“Device”: {
“Measurements”: {
“Measurement”: [
{
“@Value”: “236.4”,
“@Unit”: “V”,
“@Type”: “AC_Voltage”
},
{
“@Value”: “4.960”,
“@Unit”: “A”,
“@Type”: “AC_Current”
},
{
“@Value”: “1163.9”,
“@Unit”: “W”,
“@Type”: “AC_Power”
}
]
},
“_DateTime”: “2020-04-08T08:53:32”
}
}
}Hope someone can help me
Posts: 2
Participants: 2