Hi,
I have had this REST sensor working for years now:
sensor:
- platform: rest
resource: https://sedeaplicaciones.minetur.gob.es/ServiciosRESTCarburantes/PreciosCarburantes/EstacionesTerrestres/FiltroProvincia/08
name: Alcampo Sant Quirze
scan_interval: 1800
value_template: >-
{%- for petrol in value_json.ListaEESSPrecio -%}
{%- if petrol["IDEESS"] | int == 12474 -%}
{{ (petrol["Precio Gasolina 95 E5"] | capitalize | replace(",",".")) | round(3) }}
{%- endif -%}
{%- endfor -%}
unit_of_measurement: '€/L'
- platform: rest
resource: https://sedeaplicaciones.minetur.gob.es/ServiciosRESTCarburantes/PreciosCarburantes/EstacionesTerrestres/FiltroProvincia/08
name: Rovira Caldes
scan_interval: 1800
value_template: >-
{%- for petrol in value_json.ListaEESSPrecio -%}
{%- if petrol["IDEESS"] | int == 13191 -%}
{{ (petrol["Precio Gasolina 95 E5"] | capitalize | replace(",",".") | float-0.02) | round(3) }}
{%- endif -%}
{%- endfor -%}
unit_of_measurement: '€/L'
- platform: rest
resource: https://sedeaplicaciones.minetur.gob.es/ServiciosRESTCarburantes/PreciosCarburantes/EstacionesTerrestres/FiltroProvincia/08
name: BP C-58
scan_interval: 1800
value_template: >-
{%- for petrol in value_json.ListaEESSPrecio -%}
{%- if petrol["IDEESS"] | int == 2347 -%}
{{ (petrol["Precio Gasolina 95 E5"] | capitalize | replace(",",".")) | round(3) }}
{%- endif -%}
{%- endfor -%}
unit_of_measurement: '€/L'
- platform: rest
resource: https://sedeaplicaciones.minetur.gob.es/ServiciosRESTCarburantes/PreciosCarburantes/EstacionesTerrestres/FiltroProvincia/08
name: BP Santiga
scan_interval: 1800
value_template: >-
{%- for petrol in value_json.ListaEESSPrecio -%}
{%- if petrol["IDEESS"] | int == 2248 -%}
{{ (petrol["Precio Gasolina 95 E5"] | capitalize | replace(",",".")) | round(3) }}
{%- endif -%}
{%- endfor -%}
unit_of_measurement: '€/L'
- platform: rest
resource: https://sedeaplicaciones.minetur.gob.es/ServiciosRESTCarburantes/PreciosCarburantes/EstacionesTerrestres/FiltroProvincia/08
name: Vilacarburants Low Cost
scan_interval: 1800
value_template: >-
{%- for petrol in value_json.ListaEESSPrecio -%}
{%- if petrol["IDEESS"] | int == 14599 -%}
{{ (petrol["Precio Gasolina 95 E5"] | capitalize | replace(",",".")) | round(3) }}
{%- endif -%}
{%- endfor -%}
unit_of_measurement: '€/L'
Recently I notticed it stopped working so I tried to tweak a little bit the configuration:
rest:
- resource: https://sedeaplicaciones.minetur.gob.es/ServiciosRESTCarburantes/PreciosCarburantes/EstacionesTerrestres/FiltroProvinciaProducto/08/1
scan_interval: 1800
timeout: 60
verify_ssl: false
sensor:
- name: Alcampo Sant Quirze
unique_id: alcampo_sant_quirze
value_template: >-
{%- for petrol in value_json.ListaEESSPrecio -%}
{%- if petrol["IDEESS"] | int == 12474 -%}
{{ (petrol["PrecioProducto"] | capitalize | replace(",",".")) | round(3) }}
{%- endif -%}
{%- endfor -%}
unit_of_measurement: '€/L'
- name: Rovira Caldes
unique_id: rovira_caldes
value_template: >-
{%- for petrol in value_json.ListaEESSPrecio -%}
{%- if petrol["IDEESS"] | int == 13191 -%}
{{ (petrol["PrecioProducto"] | capitalize | replace(",",".") | float-0.02) | round(3) }}
{%- endif -%}
{%- endfor -%}
unit_of_measurement: '€/L'
- name: BP C-58
unique_id: bp_c_58
value_template: >-
{%- for petrol in value_json.ListaEESSPrecio -%}
{%- if petrol["IDEESS"] | int == 2347 -%}
{{ (petrol["PrecioProducto"] | capitalize | replace(",",".")) | round(3) }}
{%- endif -%}
{%- endfor -%}
unit_of_measurement: '€/L'
- name: Vilacarburants Low Cost
unique_id: vilacarburants_low_cost
value_template: >-
{%- for petrol in value_json.ListaEESSPrecio -%}
{%- if petrol["IDEESS"] | int == 14599 -%}
{{ (petrol["PrecioProducto"] | capitalize | replace(",",".")) | round(3) }}
{%- endif -%}
{%- endfor -%}
unit_of_measurement: '€/L'
- name: Baricentro
unique_id: baricentro
value_template: >-
{%- for petrol in value_json.ListaEESSPrecio -%}
{%- if petrol["IDEESS"] | int == 2969 -%}
{{ (petrol["PrecioProducto"] | capitalize | replace(",",".")) | round(3) }}
{%- endif -%}
{%- endfor -%}
unit_of_measurement: '€/L'
In both cases the sensors now are not created and I get this error in the logs:
2025-03-21 12:49:11.585 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: https://sedeaplicaciones.minetur.gob.es/ServiciosRESTCarburantes/PreciosCarburantes/EstacionesTerrestres/FiltroProvinciaProducto/08/1 failed with
2025-03-21 12:50:41.577 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: https://sedeaplicaciones.minetur.gob.es/ServiciosRESTCarburantes/PreciosCarburantes/EstacionesTerrestres/FiltroProvinciaProducto/08/1 failed with
2025-03-21 12:50:51.605 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: https://sedeaplicaciones.minetur.gob.es/ServiciosRESTCarburantes/PreciosCarburantes/EstacionesTerrestres/FiltroProvinciaProducto/08/1 failed with
2025-03-21 12:52:41.585 ERROR (MainThread) [homeassistant.components.rest.data] Error fetching data: https://sedeaplicaciones.minetur.gob.es/ServiciosRESTCarburantes/PreciosCarburantes/EstacionesTerrestres/FiltroProvinciaProducto/08/1 failed with
I can load the URL in my browser, so I assume this is not the problem. Anyone knows how the log should continue?
Thank you!