So I’ve just got an inverter for my solar production and I can read the data from and XML that the inverter provides. I wanted to add one of these values to HA for monitoring my energy consumption but I don’t really know how to make a sensor with the rest integration. I’m confused with the json_attributes_path, json_attributes and value_template…
The link is very normal to visit the xml: http://10.0.0.13/measurements.xml
Below you can see the XML I see when I visit the webpage.
<root>
<Device Name="StecaGrid 3611..." ... IpAddress="10.0.0.13" DateTime="2023-11-22T15:09:30" MilliSeconds="120">
<Measurements>
<Measurement Value="234.6" Unit="V" Type="AC_Voltage"/>
<Measurement Value="1.462" Unit="A" Type="AC_Current"/>
<Measurement Value="345.2" Unit="W" Type="AC_Power"/>
<Measurement Value="342.9" Unit="W" Type="AC_Power_fast"/>
<Measurement Value="50.000" Unit="Hz" Type="AC_Frequency"/>
<Measurement Value="190.3" Unit="V" Type="DC_Voltage1"/>
<Measurement Value="192.5" Unit="V" Type="DC_Voltage2"/>
<Measurement Value="0.964" Unit="A" Type="DC_Current1"/>
<Measurement Value="0.995" Unit="A" Type="DC_Current2"/>
<Measurement Value="345.7" Unit="V" Type="LINK_Voltage"/>
<Measurement Unit="W" Type="GridPower"/>
<Measurement Unit="W" Type="GridConsumedPower"/>
<Measurement Unit="W" Type="GridInjectedPower"/>
<Measurement Unit="W" Type="OwnConsumedPower"/>
<Measurement Value="100.0" Unit="%" Type="Derating"/>
</Measurements>
</Device>
</root>
I want to make a sensor that reads the AC_Power but I don’t know how to setup the configuration for it. This is what I already have in rest.yaml:
- resource: http://10.0.0.13/measurements.xml
scan_interval: 10
sensor:
headers:
- content_type: "text/xml"
name: "AC Power"
unit_of_measurement: "W"
json_attributes_path: "x.Device.Measurements[2]"
json_attributes:
- Value
value_template: "{{ value_json.Value }}"
I’m stuck on this so any help is welcome, I’m fairly new to configuring sensors. I also saw multiscrape but I’m not sure if it’s compatible with xml.