How to figure out what causes this error message?

I have following error in my logs and can’t figure out what it is about:

Logger: homeassistant.components.rest
Source: components/rest/data.py:60
Integration: RESTful (documentation, issues)
First occurred: 6:29:26 PM (1 occurrences)
Last logged: 6:29:26 PM

Unexpected error fetching rest data data: Invalid type for url. Expected str or httpx.URL, got <class 'NoneType'>: None
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 191, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 150, in _async_update_data
    return await self.update_method()
  File "/usr/src/homeassistant/homeassistant/components/rest/data.py", line 60, in async_update
    response = await self._async_client.request(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1514, in request
    request = self.build_request(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 344, in build_request
    url = self._merge_url(url)
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 374, in _merge_url
    merge_url = URL(url)
  File "/usr/local/lib/python3.9/site-packages/httpx/_urls.py", line 102, in __init__
    raise TypeError(
TypeError: Invalid type for url.  Expected str or httpx.URL, got <class 'NoneType'>: None

I have deactivated all my custom REST sensors in the configuration. Hence, I don’t think it’s related to my own stuff. But where to start to dig for the issue?

Thanks for your input

There is rest sensors and restful integration… (not) quite the same… did you deactivate both?
RESTful - Home Assistant (home-assistant.io)

RESTful Sensor - Home Assistant (home-assistant.io)

I have everything commented out with the word “rest” in all my configuration files.

That’s all there is currently in the config/configuration.yaml file:

...
# rest: !include_dir_merge_named zxy_rest/
...

after out-commenting, did you restart HA? I am not even sure if that would help but I have seen the difference when adding rest stuff…
The only other thing I can think of is indeed that another integration is using it…the errors do not guide me too much too

1 Like

Now I feel stupid! :smiley:
Obviously I really didn’t restart. :man_facepalming:

But maybe you want to have a short look on my non working config as well?

when I place following in my configuration.yaml:

rest:
  - resource: !secret home_coordinates_diesel_url
    headers:
      accept: application/json
    scan_interval: 60
    sensor:
      - name: Pricing Home Diesel Price 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

It works like a charm.

But when I move it out into a file in a subdirectory (wich I did successfully for another bunch of REST sensors before), then it complains again regarding the URL.

zxy_rest/spritprice.yaml:

- resource: https://api.e-control.at/sprit/1.0/search/gas-stations/by-address?latitude=46.2534534&longitude=14.25345214&fuelType=DIE&includeClosed=false
  headers:
    accept: application/json
  scan_interval: 60
  sensor:
    - name: Pricing Home Diesel Price 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

And in configuration.yaml:

rest: !include_dir_merge_named zxy_rest/

Then I run into the error message again:

Logger: homeassistant.components.rest
Source: components/rest/data.py:60
Integration: RESTful (documentation, issues)
First occurred: 7:44:31 PM (1 occurrences)
Last logged: 7:44:31 PM

Unexpected error fetching rest data data: Invalid type for url. Expected str or httpx.URL, got <class 'NoneType'>: None
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 191, in _async_refresh
    self.data = await self._async_update_data()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 150, in _async_update_data
    return await self.update_method()
  File "/usr/src/homeassistant/homeassistant/components/rest/data.py", line 60, in async_update
    response = await self._async_client.request(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 1514, in request
    request = self.build_request(
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 344, in build_request
    url = self._merge_url(url)
  File "/usr/local/lib/python3.9/site-packages/httpx/_client.py", line 374, in _merge_url
    merge_url = URL(url)
  File "/usr/local/lib/python3.9/site-packages/httpx/_urls.py", line 102, in __init__
    raise TypeError(
TypeError: Invalid type for url.  Expected str or httpx.URL, got <class 'NoneType'>: None

I guess it’s to hot for my brain here already!

OK… so the culprit was found… which is something already.
For the split of configuration you have to look here, I believe you need to do something with adding those folders to include_dir_list or so … I am not using subdirs so no experience.

Splitting up the configuration - Home Assistant (home-assistant.io)

Yes, this is where the inspiration come from.

It works for some other files, but not for the rest config for some reason.
Have to dig into this later.

configuration.yaml is growing too fast! :smiley:

Edit: and thanks for taking a look!