Scrape sensor for bank exchange rates from XML

Hi guys,
9 months ago I have solved this issue with Tron is this topic.

[Scrape sensor for more entities - #13 by michal.bohac]

Now, the sensor for CSOB bank stopped working and giving me everyday info about the currency exchange rate.

They have changed the XML webpage from:
[https://www.csob.cz/portal/lide/kurzovni-listek-old]

to the new one:
[https://www.csob.cz/spa/exrate/exrates/2023-10-30/kurzovni-listek.xml]

It´s in princip completely the same, but only there is a new text before the current date is mentioned.

I tried to change the yonfiguration.yaml with the new link, but is not working.

  - resourcee_template: https://csob.cz/spa/exrate/exrates/-/date/{{ now().isoformat()[:10] }}/kurzovni-listek.xml
    scan_interval: 28800
    sensor:
      - name: Kurz CSOB CZK EUR
        unit_of_measurement: 'CZK/EUR'
        device_class: monetary
        value_template: "{{ (value_json.ExchangeRate.Country|selectattr('@ID','eq','EUR')|first)['FXcashless']['@Sale'] }}"
        
      - name: Kurz CSOB CZK GBP
        unit_of_measurement: 'CZK/GBP'
        device_class: monetary
        value_template: "{{ (value_json.ExchangeRate.Country|selectattr('@ID','eq','GBP')|first)['FXcashless']['@Sale'] }}"
         
      - name: Kurz CSOB CZK USD
        unit_of_measurement: 'CZK/USD'
        device_class: monetary
        value_template: "{{ (value_json.ExchangeRate.Country|selectattr('@ID','eq','USD')|first)['FXcashless']['@Sale'] }}"
        
      - name: Kurz CSOB CZK PLN
        unit_of_measurement: 'CZK/PLN'
        device_class: monetary
        value_template: "{{ (value_json.ExchangeRate.Country|selectattr('@ID','eq','PLN')|first)['FXcashless']['@Sale'] }}"

Any idea what could be wrong?

Thanks a lot

You could turn on debug logging for the scrape component to see if you get any valuable clues from the log messages.

Some guesses: Is there possibly some sort of timezone issue that is causing tomorrow’s date to be attempted to be fetched? Are quotes possibly needed around the resource_template value?

Hey man,
thanks for your answer. It is working for the other rest - Czech National Bank XML exchange rates.

rest:
  - resource: https://www.cnb.cz/cs/financni-trhy/devizovy-trh/kurzy-devizoveho-trhu/kurzy-devizoveho-trhu/denni_kurz.xml
    scan_interval: 28800
    sensor:
      - name: Kurz CZK/EUR
        unit_of_measurement: 'CZK/EUR'
        device_class: monetary
        value_template: "{{ value_json.kurzy.tabulka.radek|selectattr('@kod','eq','EUR')|map(attribute='@kurz')|first|replace(',','.') }}"

      - name: Kurz CZK/GBP
        unit_of_measurement: 'CZK/GBP'
        device_class: monetary
        value_template: "{{ value_json.kurzy.tabulka.radek|selectattr('@kod','eq','GBP')|map(attribute='@kurz')|first|replace(',','.') }}"

      - name: Kurz CZK/USD
        unit_of_measurement: 'CZK/USD'
        device_class: monetary
        value_template: "{{ value_json.kurzy.tabulka.radek|selectattr('@kod','eq','USD')|map(attribute='@kurz')|first|replace(',','.') }}"
        
      - name: Kurz CZK/PLN
        unit_of_measurement: 'CZK/PLN'
        device_class: monetary
        value_template: "{{ value_json.kurzy.tabulka.radek|selectattr('@kod','eq','PLN')|map(attribute='@kurz')|first|replace(',','.') }}"

This is still working well…only the second bank scraper stopped working…

SOLVED:

I hade to remove the -/date/ and it´s working fine again!