" 'value_json' is undefined when rendering " for a german oilprice API

Could anyone help me, getting the actual oilprice in germany?

Found this api and like to get the “basePrice” inside the first “product”:

https://api.hoyer.de/rest/heatingoil/41564/2000/1

Tried this

- platform: rest
  name: OilSensor
  resource: "https://api.hoyer.de/rest/heatingoil/41564/2000/1"
  value_template: "{{ value_json.products[0].basePrice | float | round(1)}}"
  scan_interval: 600

but I’m always getting this error:

* Template variable error: 'value_json' is undefined when rendering '{{ value_json.products[0].basePrice | float | round(1)}}'

Or maybe someone has an other working solution for an actual oilprice in germany?

It appears that the server does not like the user agent sent by HA.

Adding a user agent header like in the following does seem to work:

sensor:
- platform: rest
  name: OilSensor
  resource: "https://api.hoyer.de/rest/heatingoil/41564/2000/1"
  value_template: "{{ value_json.products[0].basePrice | float | round(1)}}"
  scan_interval: 600
  headers:
    user-agent: Mozilla/5.0
1 Like

THX, for this hint!

Do you know any other german oil price service partners that offer api access to their oil prices ?

Is Hoyer the only one ?

I tried it out and it worked like a charme but they do not deliver here so I was wondering it esyoill or heizoel24.de would also have such kind of offer .

thanks for sharing