Hi. I am after reading the XML data from the following URL: https://uvdata.arpansa.gov.au/xml/uvvalues.xml and display only the UV index value for a certain city, say “Sydney”
Anyone can help how can I achieve this?
Hi. I am after reading the XML data from the following URL: https://uvdata.arpansa.gov.au/xml/uvvalues.xml and display only the UV index value for a certain city, say “Sydney”
Anyone can help how can I achieve this?
Have a look at the scrape sensor.
It should be able to do what you want
Or
'curl -k --silent "https://uvdata.arpansa.gov.au/xml/uvvalues.xml" | sed -n '122p' | cut -c 12-14'
will work as a command line sensor, although it will break if any changes are made to the page
Hi @muhammad.taimur did you ever get this to work for web scrape?
DW i got it to work. If anyone else wants here is the code
- platform: scrape
resource: https://uvdata.arpansa.gov.au/xml/uvvalues.xml
name: UV Index Sydney ARPANSA
select: "location > index"
index: 15
unit_of_measurement: "UV Index"
Thanks @vijaykbhatia I never came back to this post. But your code also works for me:
sensor:
- platform: scrape
resource: https://uvdata.arpansa.gov.au/xml/uvvalues.xml
name: UV Index Sydney ARPANSA
select: "location > index"
index: 15
unit_of_measurement: "UV Index"
This also worked for me:
sensor:
- platform: rest
name: ARPANSA UV Melbourne
resource: https://uvdata.arpansa.gov.au/xml/uvvalues.xml
state_class: measurement
unique_id: arpansa_uv_melbourne
value_template: "{{ value_json.stations.location[12].index }}"
Anyone have this die recently? The xml file now returns an error for me.
Works for me via RESTful request. Melbourne location moved to 11 from 12. I also unit_of_measurement: "UV Index"
might be helpful for integration with other things (i.e. AWTRIX display for UV/humidity blueprint)
sensors.yaml partial
- platform: rest
name: ARPANSA Melbourne UV Index
resource: https://uvdata.arpansa.gov.au/xml/uvvalues.xml
state_class: measurement
unique_id: arpansa_melbourne_uv_index
unit_of_measurement: "UV Index"
value_template: "{{ value_json.stations.location[11].index }}"