I have a one-wire temp-sensors to LAN interface which provides an xml document with all sensor ids and temperature values. This is an example result:
<response>
<sensor>
<id>28FF6412E3124578369587</id>
<temp>12.34</temp>
</sensor>
<sensor>
<id>28FF6412E3124578369588</id>
<temp>13.48</temp>
</sensor>
<sensor>
<id>28FF6412E3124578369589</id>
<temp>55.1</temp>
</sensor>
<!--
Many more sensor tags
-->
</response>
No I try to use the RESTful api.
This is my configuration so far:
rest:
- method: GET
scan_interval: 60
resource: http://192.168.5.111/status.xml
sensor:
- name: "FullMessage"
value_template: "{{ value_json }}"
- name: "Example"
value_template: "{{ value_json.response.sensor.0.temp }}"
- name: "How to do this"
value_template: "{{ value_json.response.sensor.[? search for id 28FF6412E3124578369587].temp }}"
My problem is that there is no guarantee that the first id is always at the first position, so I have to search for the id and take the next temp value.
A look into the “FullMessage” entity shows the xml data converted to json:
[
{'id': '28FF6412E3124578369587', 'temp': '12.34'},
{'id': '28FF6412E3124578369588', 'temp': '13.48'},
{'id': '28FF6412E3124578369589', 'temp': '55.1'}
]
I guess I could search with the json_attribute_path but I’m not sure if I can use the result as value.
I tried this filter:
$.response.sensors[?(@.id=="28FF6412E3124578369587")].temp
Is there a way I can solve that problem?