" '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

Do you have issues with the hoyer api ?

The sensor is now unavailable since yesterday 18:20
But the api call delivers this so they might have changed that output file I guess

{
  "products": [
    {
      "id": 1,
      "name": "Bestpreis",
      "description": [
        "unser günstigstes Angebot",
        "bewährte Standard-Qualität"
      ],
      "basePrice": 75.83,
      "prices": {
        "priceNet": "75,79",
        "priceGross": "90,19",
        "taxes": "14,40",
        "priceTotalNet": "2.273,70",
        "priceTotalGross": "2.705,70",
        "taxesTotal": "432,00",
        "withAction": null,
        "totalWithAction": null,
        "priceActionDifference": 0
      },
      "isPremium": false,
      "isClimateNeutral": false,
      "days": 36,
      "deliveryTimeType": "standard"
    },
    {
      "id": 4,
      "name": "Eco-Heizöl",
      "description": [
        "unser Premium-Heizöl",
        "mehr Effizienz und Haltbarkeit"
      ],
      "basePrice": 75.83,
      "prices": {
        "priceNet": "77,79",
        "priceGross": "92,57",
        "taxes": "14,78",
        "priceTotalNet": "2.333,70",
        "priceTotalGross": "2.777,10",
        "taxesTotal": "443,40",
        "withAction": null,
        "totalWithAction": null,
        "priceActionDifference": 0
      },
      "isPremium": true,
      "isClimateNeutral": false,
      "days": 36,
      "deliveryTimeType": "standard"
    },
    {
      "id": 6,
      "name": "Express",
      "description": [
        "Lieferung innerhalb von 2 Werktagen",
        "bewährte Standard-Qualität"
      ],
      "basePrice": 75.83,
      "prices": {
        "priceNet": "94,12",
        "priceGross": "112,00",
        "taxes": "17,88",
        "priceTotalNet": "2.823,60",
        "priceTotalGross": "3.360,00",
        "taxesTotal": "536,40",
        "withAction": null,
        "totalWithAction": null,
        "priceActionDifference": 0
      },
      "isPremium": false,
      "isClimateNeutral": false,
      "days": 2,
      "deliveryTimeType": "express48"
    }
  ],
  "settings": {
    "delivery_times": {
      "standard": {
        "name": "Standard (innerh. 36 Werktage)",
        "add": "0,00"
      },
      "short": {
        "name": "verk. Lieferzeit (innerh. 10 Werktage)",
        "add": "416,50"
      },
      "express48": {
        "name": "Express 48h",
        "add": "654,50"
      }
    },
    "wish_date_forerun_days": 10,
    "delivery_time_days": "36",
    "delivery_time_short_days": "10",
    "min_wish_date": "2024-09-18",
    "max_wish_date": "2024-11-08",
    "feast_days": [
      "2024-10-03"
    ],
    "payment_types": {
      "payment_cash_add": {
        "id": 1,
        "name": "Barzahlung",
        "add": "0,00"
      },
      "payment_ec_add": {
        "id": 2,
        "name": "EC-Karte",
        "add": "0,00"
      }
    },
    "hoses": {
      "1": {
        "name": "40m",
        "add": "0,00"
      },
      "2": {
        "name": "60m",
        "add": "35,70"
      },
      "3": {
        "name": "80m",
        "add": "71,40"
      }
    },
    "time_frames": [],
    "anti_freeze_add": "23,21",
    "delivery_time_add": "0,00",
    "premium_add": "2,38",
    "ggvs_add": "49,50",
    "unloading_points_add": "23,80",
    "climate_neutral_add": null,
    "show_message": "0"
  }
}

The configuration I posted above still works fine today.

1 Like

thanks,
it is working again.
It was my fault cause I had broken the rest sensor and had not seen the warning during start.

In my yaml I had placed a sensor under rest which had broken the system.
Since yesterday evening prices are back when I found out about the error / warning.