And I would like to get the data from here. I have seen another post regarding how to get XML data but it does not work for me since all the variables are in the same route.
This is the sensor I have in my configuration.yaml:
How could i get the data from every variable? Thank you
Please paste code as formatted text, not screenshots.
The XML to JSON conversion will turn the multiple variable elements into a single list of dicts each with an id and value. Here’s one I had to make manually because you didn’t include the code as text:
…but then you need to choose which value you want.
You could pull it all into attributes:
sensor:
- platform: rest
resource: YOUR URL THAT I AM NOT GOING TO COPY FROM A SCREENSHOT
value_template: "{{ now() }}"
json_attributes:
- values
…but then you would need to extract the data from that. I would use the Restful integration instead, and do it all in one step:
rest:
- resource: YOUR URL THAT I AM NOT GOING TO COPY FROM A SCREENSHOT
sensor:
- name: Iluminacion Fuerza AE
value_template: >
{{ (value_json['values']['variable']
|selectattr('id','eq','ILUMINACION_FUERZA.AE')
|first)['value'] }}"
- name: Iluminacion Fuerza AE1
value_template: >
{{ (value_json['values']['variable']
|selectattr('id','eq','ILUMINACION_FUERZA.AE1')
|first)['value'] }}"
[and so on for the other sensors]