Fuel/Gas Prices integration

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

Thats not great, I think the only options around this is to either email them, use a proxy or another source needs to be used.

I added some additional protections to prevent overloading the API with random update intervals of 1 day + 1-240mins + 1-60secs but as they are implementing some IP blocks, there is little I can do myself.

Will update the docs and update handler for directlease though to handle this a bit more gracefully.

I get this exact problem “Please wait, starting…” I have uininstalled/removed folder, reinstalled via HACS custom respository, rebooted. Still the same problem. Any ideas? Thanks.

I have tried release 2024.1.0 and latest beta version (2024.2.0b1) - same problem with both.

Not sure if these log entries are related…

Can you create an issue on GitHub with the full debug logs please?

I think when you get a ban it permanent… Still now Im blocked.

Yes, I think you will need to email them, perhaps ask why the mobile app isn’t working properly and they would be more inclined to investigate.

Struggling to get this to work
I have added it to HACS< downloaded - Restarted
in the logs it says

File "/config/custom_components/fuel_prices/__init__.py", line 73, in async_setup_entry
    raise CannotConnect from err
custom_components.fuel_prices.CannotConnect

Well I thought I followed the instructions, maybe not. I get this error when trying to add the integration.
It just gets stuck on trying to add the integration for the first time:

Logger: homeassistant.util.package
Source: util/package.py:123
First occurred: 18:28:46 (2 occurrences)
Last logged: 18:30:33

Unable to install package reverse-geocode==1.4.1: error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [34 lines of output] Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module> main() File "/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main json_out['return_val'] = hook(**hook_input['kwargs']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 152, in prepare_metadata_for_build_wheel whl_basename = backend.build_wheel(metadata_directory, config_settings) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pip-build-env-qbiklxe1/overlay/lib/python3.12/site-packages/mesonpy/__init__.py", line 1020, in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pip-build-env-qbiklxe1/overlay/lib/python3.12/site-packages/mesonpy/__init__.py", line 1073, in build_wheel with _project(config_settings) as project: File "/usr/local/lib/python3.12/contextlib.py", line 137, in __enter__ return next(self.gen) ^^^^^^^^^^^^^^ File "/tmp/pip-build-env-qbiklxe1/overlay/lib/python3.12/site-packages/mesonpy/__init__.py", line 947, in _project yield Project(source_dir, build_dir, meson_args, editable_verbose) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pip-build-env-qbiklxe1/overlay/lib/python3.12/site-packages/mesonpy/__init__.py", line 662, in __init__ self._meson = _get_meson_command(pyproject_config.get('meson')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pip-build-env-qbiklxe1/overlay/lib/python3.12/site-packages/mesonpy/__init__.py", line 982, in _get_meson_command meson_version = subprocess.run(cmd + ['--version'], check=False, text=True, capture_output=True).stdout ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/subprocess.py", line 548, in run with Popen(*popenargs, **kwargs) as process: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/local/lib/python3.12/subprocess.py", line 1953, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) PermissionError: [Errno 13] Permission denied: 'meson' [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details.
Unable to install package reverse-geocode==1.4.1: error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [34 lines of output] Traceback (most recent call last): File "/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in <module> main() File "/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main json_out['return_val'] = hook(**hook_input['kwargs']) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 152, in prepare_metadata_for_build_wheel whl_basename = backend.build_wheel(metadata_directory, config_settings) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pip-build-env-np3ush57/overlay/lib/python3.12/site-packages/mesonpy/__init__.py", line 1020, in wrapper return func(*args, **kwargs) ^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pip-build-env-np3ush57/overlay/lib/python3.12/site-packages/mesonpy/__init__.py", line 1073, in build_wheel with _project(config_settings) as project: File "/usr/local/lib/python3.12/contextlib.py", line 137, in __enter__ return next(self.gen) ^^^^^^^^^^^^^^ File "/tmp/pip-build-env-np3ush57/overlay/lib/python3.12/site-packages/mesonpy/__init__.py", line 947, in _project yield Project(source_dir, build_dir, meson_args, editable_verbose) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pip-build-env-np3ush57/overlay/lib/python3.12/site-packages/mesonpy/__init__.py", line 662, in __init__ self._meson = _get_meson_command(pyproject_config.get('meson')) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/tmp/pip-build-env-np3ush57/overlay/lib/python3.12/site-packages/mesonpy/__init__.py", line 982, in _get_meson_command meson_version = subprocess.run(cmd + ['--version'], check=False, text=True, capture_output=True).stdout ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/subprocess.py", line 548, in run with Popen(*popenargs, **kwargs) as process: ^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/subprocess.py", line 1026, in __init__ self._execute_child(args, executable, preexec_fn, close_fds, File "/usr/local/lib/python3.12/subprocess.py", line 1953, in _execute_child raise child_exception_type(errno_num, err_msg, err_filename) PermissionError: [Errno 13] Permission denied: 'meson' [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details.

After I hard refresh the page and try to install it again, I get this:

Logger: homeassistant.config_entries
Source: config_entries.py:2757
First occurred: 18:31:00 (1 occurrences)
Last logged: 18:31:00

Error occurred loading flow for integration fuel_prices: No module named 'pyfuelprices'

This has been reported for raspberry pi’s at least. Currently they aren’t supported by this integration.

What device do you have?