Fuel/Gas Prices integration

Hi all,

Since yesterday the Addon won’t start:

logger:%20homeassistant.config_entries%0ASource%3A%20config_entries.py%3A406%0AFirst%20occurred%3A%2006%3A11%3A29%20(1%20occurrences)%0ALast%20logged%3A%2006%3A11%3A29%0A%0AError%20setting%20up%20entry%20Fuel%20Prices%20for%20fuel_prices%0ATraceback%20(most%20recent%20call%20last)%3A%0A%20%20File%20%22/config/custom_components/fuel_prices/__init__.py%22,%20line%2067,%20in%20async_setup_entry%0A%20%20%20%20await%20fuel_prices.update()%0A%20%20File%20%22/usr/local/lib/python3.11/site-packages/pyfuelprices/__init__.py%22,%20line%2035,%20in%20update%0A%20%20%20%20await%20asyncio.gather(*coros)%0A%20%20File%20%22/usr/local/lib/python3.11/site-packages/pyfuelprices/__init__.py%22,%20line%2031,%20in%20update_src%0A%20%20%20%20await%20s.update(areas=a)%0A%20%20File%20%22/usr/local/lib/python3.11/site-packages/pyfuelprices/sources/__init__.py%22,%20line%20146,%20in%20update%0A%20%20%20%20raise%20UpdateFailedError(%0Apyfuelprices.sources.UpdateFailedError%0A%0AThe%20above%20exception%20was%20the%20direct%20cause%20of%20the%20following%20exception:%0A%0ATraceback%20(most%20recent%20call%20last):%0A%20%20File%20%22/usr/src/homeassistant/homeassistant/config_entries.py%22,%20line%20406,%20in%20async_setup%0A%20%20%20%20result%20=%20await%20component.async_setup_entry(hass,%20self)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%5E%0A%20%20File%20%22/config/custom_components/fuel_prices/__init__.py%22,%20line%2073,%20in%20async_setup_entry%0A%20%20%20%20raise%20CannotConnect%20from%20err%0Acustom_components.fuel_prices.CannotConnect%0A
  • Core: 2024.1.5
  • Supervisor: 2023.12.1
  • Operating System: 11.4
  • Frontend: 20240104.0

Great integration. Is there a data feed for Costco?

Hi, what data source(s) are you using?

Not currently, but looks like it could be scraped from their website.

Directlease (NLD)

Will take a look :slight_smile:

1 Like

Suddenly its working again :slight_smile:

1 Like

Awesome, just sat down to take a look at this. Perhaps the 3rd party service was down for a while.

1 Like

Directlease is blocking IP numbers that use the server otherwise then visiting the website. I did a test to manage outgoing traffic from HA over a VPN and now it working again. When switch back my original IP is back and in logs I see that im blocked.

Interesting, I wonder if there are some rate limits going on.

I’ll spin up a test instance and see what happens, I might need to do more caching.

What happens if you try the DirectLease mobile app? https://play.google.com/store/apps/details?id=com.app_it_up.dl_tankservice&hl=en&gl=US (or if it is unavailable DirectLease Tankservice - APK Download for Android | Aptoide)

Using the directlease app same. With own IP no info. When I’m on mobile data I get information

I will disable the automation and wait 24 hours. Let’s see if the block is removed.

1 Like

My entities seem to not be updating at all? I see the last updated date isnt changing, but i have seen that this might be a known issue.

However the prices arent updating either, and i have checked on the UK gov data that there is updated data.

Here still I’m.blocked by directlease. Even the mobile app doesn’t work on wifi. On mobile data it’s working. The Dutch gas prices integration also have same issues and now looking for a possible way to get the data

I have released a new beta which I believe fixes this but not 100% sure yet. Still testing

Belgium and Netherlands both use the same directlease integration. I didn’t come across this during testing.

What happens if you go to the following URL?

https://tankservice.app-it-up.com/Tankservice/v2/places?fmt=web&country=NL&country=BE&lang=en

It seems to have updated after updating to beta. also see the next update field is now filled. great work :slight_smile:

ill let you know if it updates automatically over the coming days! :slight_smile:

1 Like

In case someone wants it in the future.

Here is how to send a Text to speech notification to your phone that tells you the lowest price of the fuel in your area:

service: notify.mobile_app_sm_g991b
data:
  message: TTS
  title: "" 
  data:
    channel: alarm_stream_max
    tts_text: |-
      {% set name = ((states.device_tracker
        | selectattr('entity_id', 'in', integration_entities('fuel_prices'))
        | sort(attribute='attributes.B7', reverse=false)
        | map(attribute='attributes.brand')
        | list)[0])
      %}
      {% set price = ((states.device_tracker
        | selectattr('entity_id', 'in', integration_entities('fuel_prices'))
        | sort(attribute='attributes.B7', reverse=false)
        | map(attribute='attributes.B7')
        | list)[0])
      %}
      "Diesel is cheapest at {{ name }} today, the price is {{price}} Pence per litre"    
    priority: high
    ttl: 0

Simply change the wording to your fuel type, currency and unit of measurement and change the B7 to the name of the fuel type you get in your area :slight_smile:

I have priority set to high on the notification so it plays over do not disturb which automatically turns on when i am driving. You can of course change this if you prefer.

I have just set up this automation to play when homeassistant detects that i am on my way home. So when i am on my way back from work it will notify me so i can swing by the cheapest one around where i live :slight_smile:

2 Likes

A bit late to give you an answer, but you can with card mod:

      type: map
      entities:
        - entity: device_tracker.car
        - entity: device_tracker.asda
        - entity: device_tracker.morrisons
        - entity: device_tracker.tesco
      card_mod:
        style:
          ha-map:
            $:
              .leaflet-marker-icon:
                ha-entity-marker[entity-id='device_tracker.asda'] $: |
                  .marker {
                    font-size: 0px !important;
                   }
                   .marker::after {
                     content: "{{state_attr('device_tracker.asda','B7')}}";
                     font-size: 15px !important;
                   }
                ha-entity-marker[entity-id='device_tracker.morrisons'] $: |
                  .marker {
                    font-size: 0px !important;
                   }
                   .marker::after {
                     content: "{{state_attr('device_tracker.morrisons','B7')}}";
                     font-size: 15px !important;
                   }
                ha-entity-marker[entity-id='device_tracker.tesco'] $: |
                  .marker {
                    font-size: 0px !important;
                   }
                   .marker::after {
                     content: "{{state_attr('device_tracker.tesco','B7')}}";
                     font-size: 15px !important;
                   }
1 Like