Benzinpreise in Home Assistant für Österreich

Kuman Raspberry Pi 3.5 inch Touchscreen Stift TFT Monitor LCD Display 320*480 Resolution with Protective Case + 3 x Heat Sinks+ Touch Pen for Raspberry Pi 3B+, Pi 2 Model B & Pi Model B SC11
Kuman Raspberry Pi 3.5 inch Touchscreen Stift TFT Monitor LCD Display 320*480 Resolution with Protective Case + 3 x Heat Sinks+ Touch Pen for Raspberry Pi 3B+, Pi 2 Model B & Pi Model B SC11
--

In Deutschland lassen wir uns unsere Benzinpreise mittels Tankerkönig anzeigen. Den Beitrag dazu findet ihr hier:
https://smarthomeyourself.de/wiki/homeassistant/benzinpreise-in-home-assistant-sortieren-und-anzeigen-mit-tankerkoenig

Leider gibt es hier keine Schnittstelle zu unseren Nachbarn nach Österreich.

Abhilfe schafft hier allerdings spritpreisrechner.at und die API von api.e-control.at


Als erstes brauchen wir die Koordinaten zu unseren Tankstellen. Diese finden wir am einfachsten über spritpreisrechner.at

Für diejenigen, die direkt an der Grenze wohnen, könnten ggfs. bei Adresse „ermitteln“ auswählen.

In meinem Beispiel habe ich direkt nach „Salzburg“ gesucht und bekomme alle umliegenden Tankstellen angezeigt.


Auf der Seite latlong.net suchen wir uns die Geo-Koordinaten für die Wildenhofer Diesel Tankstelle


Über api.e-control.at (Direktlink zum API-Creator) können wir nun anhand der Latitude und Longitude unseren puplic-api erstellen.

https://api.e-control.at/sprit/1.0/search/gas-stations/by-address?latitude=47.815800&longitude=13.050220&fuelType=DIE&includeClosed=true

Mit dieser API können wir uns nun einen REST-SENSOR erstellen.

# API Documentation
# https://api.e-control.at/sprit/1.0/doc/index.html?url=https://api.e-control.at/sprit/1.0/api-docs%3Fgroup%3Dpublic-api#/search/searchGasStationsByAddressUsingGET

- resource: https://api.e-control.at/sprit/1.0/search/gas-stations/by-address?latitude=47.815800&longitude=13.050220&fuelType=DIE&includeClosed=true
  scan_interval: 1800
  sensor:
    - name: fuel_price_bruck_die_1
      device_class: monetary
      value_template: "{{ value_json[0]['prices'][0]['amount'] }}"
      unit_of_measurement: "EUR"
      force_update: True
      json_attributes_path: "$[0]"
      json_attributes:
        - name
        - id
        - location
    - name: fuel_price_bruck_die_2
      device_class: monetary
      value_template: "{{ value_json[1]['prices'][0]['amount'] }}"
      unit_of_measurement: "EUR"
      force_update: True
      json_attributes_path: "$[1]"
      json_attributes:
        - name
        - id
        - location
    - name: fuel_price_bruck_die_3
      device_class: monetary
      value_template: "{{ value_json[2]['prices'][0]['amount'] }}"
      unit_of_measurement: "EUR"
      force_update: True
      json_attributes_path: "$[2]"
      json_attributes:
        - name
        - id
        - location
    - name: fuel_price_bruck_die_4
      device_class: monetary
      value_template: "{{ value_json[3]['prices'][0]['amount'] }}"
      unit_of_measurement: "EUR"
      force_update: True
      json_attributes_path: "$[3]"
      json_attributes:
        - name
        - id
        - location
    - name: fuel_price_bruck_die_5
      device_class: monetary
      value_template: "{{ value_json[4]['prices'][0]['amount'] }}"
      unit_of_measurement: "EUR"
      force_update: True
      json_attributes_path: "$[4]"
      json_attributes:
        - name
        - id
        - location

Zu guter letzt müssen wir diese Daten nur noch ins Dashboard bekommen.

Hier gibt es auch ein dutzend verschiedene Wege – diese sind natürlich jedem selbst überlassen!

type: entities
title: Salzburg
entities:
  - type: custom:template-entity-row
    icon: mdi:gas-station-outline
    entity: sensor.fuel_price_bruck_die_1
    state: '{{states.sensor.fuel_price_bruck_die_1.state_with_unit}}'
    name: '{{state_attr(''sensor.fuel_price_bruck_die_1'', ''name'')}}'
    secondary: >-
      {{state_attr('sensor.fuel_price_bruck_die_1', 'location')['postalCode']}}
      {{state_attr('sensor.fuel_price_bruck_die_1', 'location')['city']}},
      {{state_attr('sensor.fuel_price_bruck_die_1',
      'location')['address']|title}}
  - type: custom:template-entity-row
    icon: mdi:gas-station-outline
    entity: sensor.fuel_price_bruck_die_2
    state: '{{states.sensor.fuel_price_bruck_die_2.state_with_unit}}'
    name: '{{state_attr(''sensor.fuel_price_bruck_die_2'', ''name'')}}'
    secondary: >-
      {{state_attr('sensor.fuel_price_bruck_die_2', 'location')['postalCode']}}
      {{state_attr('sensor.fuel_price_bruck_die_2', 'location')['city']}},
      {{state_attr('sensor.fuel_price_bruck_die_2',
      'location')['address']|title}}
  - type: custom:template-entity-row
    icon: mdi:gas-station-outline
    entity: sensor.fuel_price_bruck_die_3
    state: '{{states.sensor.fuel_price_bruck_die_3.state_with_unit}}'
    name: '{{state_attr(''sensor.fuel_price_bruck_die_3'', ''name'')}}'
    secondary: >-
      {{state_attr('sensor.fuel_price_bruck_die_3', 'location')['postalCode']}}
      {{state_attr('sensor.fuel_price_bruck_die_3', 'location')['city']}},
      {{state_attr('sensor.fuel_price_bruck_die_3',
      'location')['address']|title}}
  - type: custom:template-entity-row
    icon: mdi:gas-station-outline
    entity: sensor.fuel_price_bruck_die_4
    state: '{{states.sensor.fuel_price_bruck_die_4.state_with_unit}}'
    name: '{{state_attr(''sensor.fuel_price_bruck_die_4'', ''name'')}}'
    secondary: >-
      {{state_attr('sensor.fuel_price_bruck_die_4', 'location')['postalCode']}}
      {{state_attr('sensor.fuel_price_bruck_die_4', 'location')['city']}},
      {{state_attr('sensor.fuel_price_bruck_die_4',
      'location')['address']|title}}
  - type: custom:template-entity-row
    icon: mdi:gas-station-outline
    entity: sensor.fuel_price_bruck_die_5
    state: '{{states.sensor.fuel_price_bruck_die_5.state_with_unit}}'
    name: '{{state_attr(''sensor.fuel_price_bruck_die_5'', ''name'')}}'
    secondary: >-
      {{state_attr('sensor.fuel_price_bruck_die_5', 'location')['postalCode']}}
      {{state_attr('sensor.fuel_price_bruck_die_5', 'location')['city']}},
      {{state_attr('sensor.fuel_price_bruck_die_5',
      'location')['address']|title}}

Weitere Möglichkeiten für eine Tankkarte findet ihr hier