Fuel/Gas Prices integration

You are right, i can see in another major city the data, but not in the searched smaller city.
5 miles radius would be enough for stations.
When i check Spritpreisrechner, both are showing results.

Working:
48.277495
14.294849
5miles

Not working: (or only showing 4 from 10 possible stations)
48.212120650046984
14.287071446311938
5miles

Thank you, I will take a look. Perhaps there is some new API configurations that need to be applied.

1 Like

I’ve just released version 2024.11.0 which should fix these issues. It seems data collection by region is quite complex compared to what it once was as they split out into hundreds of different sub-regions (postal code areas).

While testing their API wasn’t returning fuel price information.

1 Like

You are the best :slight_smile:
Its working for me

1 Like

I have one additional question, not directly related to the plugin
I would like to create a button on dashboard to start a navigation in Android to the Cheapest Station. This would mean i would need to extract the address attribute from the entity and then configure a button.
Anybody did something like this already or has an tip how to do this?

I’ve used a notification to do it (button on home screen to get cheapest station in 5 miles, then an action within the notification to start navigation), but you might be able to broadcast an intent instead. Because I’m in the UK, I can use the name of the fuel station to navigate, but to use the address you would just change data.fuels[0]['name'] within the uri action at the bottom to data.fuels[0]['address']

sequence:
  - data:
      type: B7
      location:
        latitude: |
          {{ state_attr('device_tracker.sm_s918b', 'latitude') | float }}
        longitude: |
          {{ state_attr('device_tracker.sm_s918b', 'longitude') | float }}
        radius: |
          {{ 5 * 1609.34 }}
    response_variable: data
    action: fuel_prices.find_fuels
  - if:
      - condition: template
        value_template: "{{ (data.fuels | count) > 0 }}"
    then:
      - metadata: {}
        data:
          title: Fuel Search Result
          message: |-
            Cheapest Fuel Station: {{ data.fuels[0]['name'] }}
            Price (per litre): {{ data.fuels[0]['cost'] }}
          data:
            car_ui: true
            notification_icon: mdi:car
            actions:
              - action: URI
                title: Navigate
                uri: |
                  {{ "deep-link://waze://?q=" + data.fuels[0]['name'] }}
        action: notify.mobile_app_sm_s918b

This is really cool, thanks.
So this means you created a action to check which are the cheapest prices based on your phone location?
Could you share this code with us? Exactly this was something i would like to achieve, but wanted to start with something simpler :smiley:

No problem, yes this is based on the location of my phone, the above code block contains the sequence of the script itself that I created in Home Assistant.

I have another script that takes into account the current fuel level in my car, calculates how much it will cost to fill and sends a similar notification.

Replace device_tracker.sm_s918b in the above with the entity ID of your own device tracker, and notify.mobile_app_sm_s918b with the notify service. Might need to change the Price (per litre) too if measured differently.