Update – this does not work anymore. The owner of “Drivstoffappen” has changed the API, so this won’t work any longer.
It is possible to see the fuel prices in Norway in Home Assistant!
This solution is based on an API from the “Drivstoffappen”. This is an application into which current fuel prices are entered. Therefore, not the various petrol stations that give the fuel price, but users who update the prices in the app.
It is a great advantage that you have downloaded the “Drivstoffappen” on your phone, both to be able to help update prices and also to find the correct name of the petrol station.
To manage this, we need to use Node-Red and one extra custom integration. It is not difficult if you follow these steps.
A prerequisite is that Node-Red is installed on the Home Assistant.
First – start by installing “Node-RED Companion Integration”. The easiest way is to install this via HACS. Follow the steps on this page: https://github.com/zachowj/hass-node-red
“Node-RED Companion Integration” ensures, among other things, that you can create and update sensors in the Home Assistant.
After the “Node-RED Companion Integration” has been installed, you can start adding the Node-Red automation. This automation makes sure to fetch the fuel prices at “your” petrol station every 10 minutes.
Import the JSON code below into Node-Red. Select “import” in the menu and enter the code at the end of this post.
Afterward, you have to update the gas stations with “your” gas stations.
Start by editing the function node, and replace the name of the gas station with “your” gas station. You can find the correct name in the “Drivstoffappen” on your phone.
Next, edit the sensor node. Select “Add new HA-entity-config” and press the pencil. Fill in the information for your new sensor.
When this is done, just run a “Deploy” and the automation is underway.
What remains then is to enter the new Entity Sensor in the Home Assistant and place it exactly as you want.
Node-Red JSON code:
[
{
"id": "2447f70b5f1095ba",
"type": "tab",
"label": "Drivstoffpriser",
"disabled": false,
"info": "",
"env": []
},
{
"id": "9103052baf82e5d0",
"type": "inject",
"z": "2447f70b5f1095ba",
"name": "Hvert 10 min",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "600",
"crontab": "",
"once": false,
"onceDelay": 0.1,
"topic": "",
"payload": "",
"payloadType": "date",
"x": 160,
"y": 280,
"wires": [
[
"687284b792794184"
]
]
},
{
"id": "687284b792794184",
"type": "http request",
"z": "2447f70b5f1095ba",
"name": "",
"method": "GET",
"ret": "obj",
"paytoqs": "ignore",
"url": "https://api.drivstoffappen.no/api/stations?stationType=0&countryCode=NO",
"tls": "",
"persist": false,
"proxy": "",
"insecureHTTPParser": false,
"authType": "",
"senderr": false,
"headers": [
{
"keyType": "other",
"keyValue": "Content-Type",
"valueType": "other",
"valueValue": "application/json"
},
{
"keyType": "other",
"keyValue": "X-API-KEY",
"valueType": "other",
"valueValue": "2CD114509703F6E0A976C32FCB79C4F62966EEC6"
},
{
"keyType": "other",
"keyValue": "User-Agent",
"valueType": "other",
"valueValue": "Drivstoffappen/1.3.8 (com.raskebiler.drivstoff.appen; build:130; iOS 15.2.1) Alamofire/5.4.4"
}
],
"x": 350,
"y": 280,
"wires": [
[
"18ec6499f1fefde8",
"e7e0a907d77667f2",
"283d51c6efeddbb7",
"85dd9827b7d9a90c",
"e577f959c4c3e385"
]
]
},
{
"id": "18ec6499f1fefde8",
"type": "function",
"z": "2447f70b5f1095ba",
"name": "",
"func": "msg.payload = msg.payload.filter(e => e.discountInfo == 'Circle K Elverum');\nmsg.payload[0].stationDetails = msg.payload[0].stationDetails.filter(e => e.type == '95' || e.type == 'D' )\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 540,
"y": 100,
"wires": [
[
"d8f8677688dcec6f"
]
]
},
{
"id": "d8f8677688dcec6f",
"type": "ha-sensor",
"z": "2447f70b5f1095ba",
"name": "Circle K Elverum",
"entityConfig": "382bb93f5f3315cd",
"version": 0,
"state": "payload[0].stationDetails[0].price",
"stateType": "msg",
"attributes": [
{
"property": "price95",
"value": "payload[0].stationDetails[0].price",
"valueType": "msg"
},
{
"property": "lastUpdated95",
"value": "payload[0].stationDetails[0].lastUpdated",
"valueType": "msg"
},
{
"property": "latitude",
"value": "payload[0].latitude",
"valueType": "msg"
},
{
"property": "longitude",
"value": "payload[0].longitude",
"valueType": "msg"
},
{
"property": "pictureUrl",
"value": "payload[0].pictureUrl",
"valueType": "msg"
},
{
"property": "priceD",
"value": "payload[0].stationDetails[1].price",
"valueType": "msg"
},
{
"property": "lastUpdatedD",
"value": "payload[0].stationDetails[1].lastUpdated",
"valueType": "msg"
}
],
"inputOverride": "allow",
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "data"
}
],
"x": 730,
"y": 100,
"wires": [
[]
]
},
{
"id": "e7e0a907d77667f2",
"type": "function",
"z": "2447f70b5f1095ba",
"name": "",
"func": "msg.payload = msg.payload.filter(e => e.discountInfo == 'Shell Elverum');\nmsg.payload[0].stationDetails = msg.payload[0].stationDetails.filter(e => e.type == '95' || e.type == 'D' )\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 540,
"y": 160,
"wires": [
[
"ff52aedd7202b596"
]
]
},
{
"id": "ff52aedd7202b596",
"type": "ha-sensor",
"z": "2447f70b5f1095ba",
"name": "Shell Elverum",
"entityConfig": "718fc7ac0b47cdbb",
"version": 0,
"state": "payload[0].stationDetails[0].price",
"stateType": "msg",
"attributes": [
{
"property": "price95",
"value": "payload[0].stationDetails[0].price",
"valueType": "msg"
},
{
"property": "lastUpdated95",
"value": "payload[0].stationDetails[0].lastUpdated",
"valueType": "msg"
},
{
"property": "latitude",
"value": "payload[0].latitude",
"valueType": "msg"
},
{
"property": "longitude",
"value": "payload[0].longitude",
"valueType": "msg"
},
{
"property": "pictureUrl",
"value": "payload[0].pictureUrl",
"valueType": "msg"
},
{
"property": "priceD",
"value": "payload[0].stationDetails[1].price",
"valueType": "msg"
},
{
"property": "lastUpdatedD",
"value": "payload[0].stationDetails[1].lastUpdated",
"valueType": "msg"
}
],
"inputOverride": "allow",
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "data"
}
],
"x": 720,
"y": 160,
"wires": [
[]
]
},
{
"id": "283d51c6efeddbb7",
"type": "function",
"z": "2447f70b5f1095ba",
"name": "",
"func": "msg.payload = msg.payload.filter(e => e.discountInfo == 'Uno-X Elverum');\nmsg.payload[0].stationDetails = msg.payload[0].stationDetails.filter(e => e.type == '95' || e.type == 'D' )\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 540,
"y": 220,
"wires": [
[
"eedf23f500ebf1c0"
]
]
},
{
"id": "eedf23f500ebf1c0",
"type": "ha-sensor",
"z": "2447f70b5f1095ba",
"name": "Uno-X Elverum",
"entityConfig": "983f428eef5a9e1a",
"version": 0,
"state": "payload[0].stationDetails[0].price",
"stateType": "msg",
"attributes": [
{
"property": "price95",
"value": "payload[0].stationDetails[0].price",
"valueType": "msg"
},
{
"property": "lastUpdated95",
"value": "payload[0].stationDetails[0].lastUpdated",
"valueType": "msg"
},
{
"property": "latitude",
"value": "payload[0].latitude",
"valueType": "msg"
},
{
"property": "longitude",
"value": "payload[0].longitude",
"valueType": "msg"
},
{
"property": "pictureUrl",
"value": "payload[0].pictureUrl",
"valueType": "msg"
},
{
"property": "priceD",
"value": "payload[0].stationDetails[1].price",
"valueType": "msg"
},
{
"property": "lastUpdatedD",
"value": "payload[0].stationDetails[1].lastUpdated",
"valueType": "msg"
}
],
"inputOverride": "allow",
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "data"
}
],
"x": 720,
"y": 220,
"wires": [
[]
]
},
{
"id": "85dd9827b7d9a90c",
"type": "function",
"z": "2447f70b5f1095ba",
"name": "",
"func": "msg.payload = msg.payload.filter(e => e.discountInfo == 'Esso Myklegard');\nmsg.payload[0].stationDetails = msg.payload[0].stationDetails.filter(e => e.type == '95' || e.type == 'D' )\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 540,
"y": 280,
"wires": [
[
"7b7e07abe7c9f208"
]
]
},
{
"id": "7b7e07abe7c9f208",
"type": "ha-sensor",
"z": "2447f70b5f1095ba",
"name": "Esso Myklegard",
"entityConfig": "811ae830afde2585",
"version": 0,
"state": "payload[0].stationDetails[0].price",
"stateType": "msg",
"attributes": [
{
"property": "price95",
"value": "payload[0].stationDetails[0].price",
"valueType": "msg"
},
{
"property": "lastUpdated95",
"value": "payload[0].stationDetails[0].lastUpdated",
"valueType": "msg"
},
{
"property": "latitude",
"value": "payload[0].latitude",
"valueType": "msg"
},
{
"property": "longitude",
"value": "payload[0].longitude",
"valueType": "msg"
},
{
"property": "pictureUrl",
"value": "payload[0].pictureUrl",
"valueType": "msg"
},
{
"property": "priceD",
"value": "payload[0].stationDetails[1].price",
"valueType": "msg"
},
{
"property": "lastUpdatedD",
"value": "payload[0].stationDetails[1].lastUpdated",
"valueType": "msg"
}
],
"inputOverride": "allow",
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "data"
}
],
"x": 720,
"y": 280,
"wires": [
[]
]
},
{
"id": "e577f959c4c3e385",
"type": "function",
"z": "2447f70b5f1095ba",
"name": "",
"func": "msg.payload = msg.payload.filter(e => e.discountInfo == 'YX 7-Eleven Løten');\nmsg.payload[0].stationDetails = msg.payload[0].stationDetails.filter(e => e.type == '95' || e.type == 'D' )\nreturn msg;",
"outputs": 1,
"noerr": 0,
"initialize": "",
"finalize": "",
"libs": [],
"x": 540,
"y": 340,
"wires": [
[
"aaebe496457cccdb"
]
]
},
{
"id": "aaebe496457cccdb",
"type": "ha-sensor",
"z": "2447f70b5f1095ba",
"name": "YX 7-Eleven Løten",
"entityConfig": "c086a775ed92f659",
"version": 0,
"state": "payload[0].stationDetails[0].price",
"stateType": "msg",
"attributes": [
{
"property": "price95",
"value": "payload[0].stationDetails[0].price",
"valueType": "msg"
},
{
"property": "lastUpdated95",
"value": "payload[0].stationDetails[0].lastUpdated",
"valueType": "msg"
},
{
"property": "latitude",
"value": "payload[0].latitude",
"valueType": "msg"
},
{
"property": "longitude",
"value": "payload[0].longitude",
"valueType": "msg"
},
{
"property": "pictureUrl",
"value": "payload[0].pictureUrl",
"valueType": "msg"
},
{
"property": "priceD",
"value": "payload[0].stationDetails[1].price",
"valueType": "msg"
},
{
"property": "lastUpdatedD",
"value": "payload[0].stationDetails[1].lastUpdated",
"valueType": "msg"
}
],
"inputOverride": "allow",
"outputProperties": [
{
"property": "payload",
"propertyType": "msg",
"value": "",
"valueType": "data"
}
],
"x": 730,
"y": 340,
"wires": [
[]
]
},
{
"id": "382bb93f5f3315cd",
"type": "ha-entity-config",
"server": "52505f54.3e78d",
"deviceConfig": "",
"name": "Circle K Elverum",
"version": "6",
"entityType": "sensor",
"haConfig": [
{
"property": "name",
"value": "Circle K Elverum"
},
{
"property": "icon",
"value": "mdi:gas-station"
},
{
"property": "entity_category",
"value": ""
},
{
"property": "device_class",
"value": ""
},
{
"property": "unit_of_measurement",
"value": ""
},
{
"property": "state_class",
"value": ""
}
],
"resend": false,
"debugEnabled": false
},
{
"id": "718fc7ac0b47cdbb",
"type": "ha-entity-config",
"server": "52505f54.3e78d",
"deviceConfig": "",
"name": "Shell Elverum",
"version": "6",
"entityType": "sensor",
"haConfig": [
{
"property": "name",
"value": "Shell Elverum"
},
{
"property": "icon",
"value": "mdi:gas-station"
},
{
"property": "entity_category",
"value": ""
},
{
"property": "device_class",
"value": ""
},
{
"property": "unit_of_measurement",
"value": ""
},
{
"property": "state_class",
"value": ""
}
],
"resend": false,
"debugEnabled": false
},
{
"id": "983f428eef5a9e1a",
"type": "ha-entity-config",
"server": "52505f54.3e78d",
"deviceConfig": "",
"name": "Uno-X Elverum",
"version": "6",
"entityType": "sensor",
"haConfig": [
{
"property": "name",
"value": "Uno-X Elverum"
},
{
"property": "icon",
"value": "mdi:gas-station"
},
{
"property": "entity_category",
"value": ""
},
{
"property": "device_class",
"value": ""
},
{
"property": "unit_of_measurement",
"value": ""
},
{
"property": "state_class",
"value": ""
}
],
"resend": false,
"debugEnabled": false
},
{
"id": "811ae830afde2585",
"type": "ha-entity-config",
"server": "52505f54.3e78d",
"deviceConfig": "",
"name": "Esso Mykelgard",
"version": "6",
"entityType": "sensor",
"haConfig": [
{
"property": "name",
"value": "Esso Mykelgard"
},
{
"property": "icon",
"value": "mdi:gas-station"
},
{
"property": "entity_category",
"value": ""
},
{
"property": "device_class",
"value": ""
},
{
"property": "unit_of_measurement",
"value": ""
},
{
"property": "state_class",
"value": ""
}
],
"resend": false,
"debugEnabled": false
},
{
"id": "c086a775ed92f659",
"type": "ha-entity-config",
"server": "ec6b4330.077a3",
"deviceConfig": "",
"name": "sensor config for YX 7-Eleven Løten",
"version": "6",
"entityType": "sensor",
"haConfig": [
{
"property": "name",
"value": "YX 7-Eleven Løten"
},
{
"property": "icon",
"value": "mdi:gas-station"
},
{
"property": "entity_category",
"value": ""
},
{
"property": "device_class",
"value": ""
},
{
"property": "unit_of_measurement",
"value": "Kr"
},
{
"property": "state_class",
"value": ""
}
],
"resend": true,
"debugEnabled": false
},
{
"id": "52505f54.3e78d",
"type": "server",
"name": "Home Assistant",
"version": 5,
"addon": true,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": false,
"heartbeatInterval": "30",
"areaSelector": "friendlyName",
"deviceSelector": "friendlyName",
"entitySelector": "friendlyName",
"statusSeparator": "at: ",
"statusYear": "hidden",
"statusMonth": "short",
"statusDay": "numeric",
"statusHourCycle": "h23",
"statusTimeFormat": "h:m",
"enableGlobalContextStore": true
},
{
"id": "ec6b4330.077a3",
"type": "server",
"name": "Home Assistant",
"version": 5,
"addon": true,
"rejectUnauthorizedCerts": true,
"ha_boolean": "y|yes|true|on|home|open",
"connectionDelay": true,
"cacheJson": true,
"heartbeat": false,
"heartbeatInterval": "30",
"areaSelector": "friendlyName",
"deviceSelector": "friendlyName",
"entitySelector": "friendlyName",
"statusSeparator": "at: ",
"statusYear": "hidden",
"statusMonth": "short",
"statusDay": "numeric",
"statusHourCycle": "h23",
"statusTimeFormat": "h:m",
"enableGlobalContextStore": true
}
]