Reverse Geocode Sensor ("Places") using OpenStreetMap - custom component

Been working fine for ages and now get this occasionaly, any ideas ?

Thinking about it, not seen it before I updated to 101.2

Error doing job: Future exception was never retrieved

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 157, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 84, in create_connection
    raise err
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 74, in create_connection
    sock.connect(sa)
TimeoutError: [Errno 110] Operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 334, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7xxxxxxxxxxx0>: Failed to establish a new connection: [Errno 110] Operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='nominatim.openstreetmap.org', port=443): Max retries exceeded with url: /reverse?format=jsonv2&lat=53.xxxxxxxxxx&lon=-0.4xxxxxxxxxxxxxxxxx&addressdetails=1&namedetails=1&zoom=18&limit=1&[email protected] (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7xxxxxxxxxd0>: Failed to establish a new connection: [Errno 110] Operation timed out'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/places/sensor.py", line 427, in tsc_update
    self.do_update("Track State Change")
  File "/config/custom_components/places/sensor.py", line 539, in do_update
    osm_response = get(osm_url)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 75, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 60, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 533, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 646, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='nominatim.openstreetmap.org', port=443): Max retries exceeded with url: /reverse?format=jsonv2&lat=53.xxxxxxxxxxxxxxxx&lon=-0.4xxxxxxxxxxxxxxx&addressdetails=1&namedetails=1&zoom=18&limit=1&[email protected] (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7xxxxxxxfd0>: Failed to establish a new connection: [Errno 110] Operation timed out'))

Hi, there is no activity here but some open issues obviously. I think about using places instead of Google geocode. Is places still supported and active?

It is active and working fine. Running on Home Assistant 0.107.7

1 Like

Hi, I already activated the integration now and wondered, why city always showed ‘-’.
From my point of view, there is a bug in the code:
Existing code:

elif self._devicetracker_zone == "not_home":
                if city == ' ':
                    city = postal_town
                    if city == ' ':
                        city = county

The right code in my opinion:

elif self._devicetracker_zone == "not_home":
                if city == '-':
                    city = postal_town
                    if city == '-':
                        city = county

because you initialize the varibles here in line 568 to 581:

 place_neighbourhood = '-'
            street_number = ''
            street = 'Unnamed Road'
            city = '-'
            postal_town = '-'
            region = '-'

Am I on the right track?

I have this component running for some time now and I have no problems.

Hi, there is no activity here but some open issues obviously.

There are two open issues on Github. One is over a year old and I don’t have that problem and the other one is about really long state values and I don’t know why I would like to have at state like “zone,place,street_number,street,city,state,postal_code, county, country”.

I have changed the order for city and postal_town because one of them doesn’t contain an useful information for my location.

1 Like

From the clips you have provided, it looks to me like you have indeed found a bug. Your proposed fix for it also seems reasonable. I don’t manage the code anymore, but I believe you can propose your change on GitHub and initiate a pull request and someone should review and accept it.
(I assume that you have made the change in your local copy and tested it to ensure it works as expected…)

Hi Jim, I already tested it and it works indeed.
But I never opened a pull request before. I have definately no idea, how to do that :slight_smile: :thinking:

I actually don’t either. The process might be described on the Github page. I think you just upload your modified copy and request a “Pull”. But if you don’t even have a github account - maybe someone else here could do it for you?

I do have an account. And following your suggestion, I tried to discover how to create a pull request. Failed badly :slightly_smiling_face:

https://help.github.com/en/github/collaborating-with-issues-and-pull-requests/creating-a-pull-request shows the steps with pictures.

1 Like

Is anyone else having problems with Places recently?

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 157, in _new_conn
    (self._dns_host, self.port), self.timeout, **extra_kw
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/connection.py", line 61, in create_connection
    for res in socket.getaddrinfo(host, port, family, socket.SOCK_STREAM):
  File "/usr/local/lib/python3.7/socket.py", line 752, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name does not resolve

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 672, in urlopen
    chunked=chunked,
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 376, in _make_request
    self._validate_conn(conn)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 994, in _validate_conn
    conn.connect()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 300, in connect
    conn = self._new_conn()
  File "/usr/local/lib/python3.7/site-packages/urllib3/connection.py", line 169, in _new_conn
    self, "Failed to establish a new connection: %s" % e
urllib3.exceptions.NewConnectionError: <urllib3.connection.VerifiedHTTPSConnection object at 0x7f7ea221af10>: Failed to establish a new connection: [Errno -2] Name does not resolve

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 449, in send
    timeout=timeout
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 720, in urlopen
    method, url, error=e, _pool=self, _stacktrace=sys.exc_info()[2]
  File "/usr/local/lib/python3.7/site-packages/urllib3/util/retry.py", line 436, in increment
    raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='nominatim.openstreetmap.org', port=443): Max retries exceeded with url: /reverse?format=jsonv2&lat=999999&lon=999999&addressdetails=1&namedetails=1&zoom=18&limit=1&[email protected] (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f7ea221af10>: Failed to establish a new connection: [Errno -2] Name does not resolve'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 279, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 476, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/src/homeassistant/homeassistant/util/__init__.py", line 240, in wrapper
    result = method(*args, **kwargs)
  File "/config/custom_components/places/sensor.py", line 432, in update
    self.do_update("Scan Interval")
  File "/config/custom_components/places/sensor.py", line 539, in do_update
    osm_response = get(osm_url)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 76, in get
    return request('get', url, params=params, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/requests/adapters.py", line 516, in send
    raise ConnectionError(e, request=request)
requests.exceptions.ConnectionError: HTTPSConnectionPool(host='nominatim.openstreetmap.org', port=443): Max retries exceeded with url: /reverse?format=jsonv2&lat=999999&lon=999999&addressdetails=1&namedetails=1&zoom=18&limit=1&[email protected] (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x7f7ea221af10>: Failed to establish a new connection: [Errno -2] Name does not resolve'))

Seems like it’s a dead component now. :frowning:

No it’s not. It’s still working fine.

It’s working fine for me as well. No problems with this component for a lot of months.

When no one is writing here, maybe there are no bigger issues? :slight_smile:

Need some help with a template:

platform: template
sensors:
fabian_locatie:
friendly_name: “Locatie Fabian”
value_template: “{{ state_attr(‘sensor.fabian’, ‘street’) ,state_attr(‘sensor.fabian’, ‘street_number’) }}”

platform: template
sensors:
fabian_locatie:
friendly_name: “Locatie Fabian”
value_template: “(‘Streetname’, ‘151’)”

It prints now: “(‘Streetname’, ‘151’)”
want to have it: Streetname 151

Can’t figure it out, some direction is appriciated.

try:

value_template: >
  {% set street = state_attr('sensor.fabian','street') %} 
  {% set number = state_attr('sensor.fabian','street_number') %}
  {{street ~ ' ' ~ number}}
1 Like

I’m still strugeling with templates but every bit will help to inderstand them, this is working great, thank you so much, and reusable for other things :+1:

Hi, I don’t get this to work anymore after upgrade of home assistant? It only says: Platform error sensor.places - Integration ‘places’ not found.

Are you using the latest version of the custom component ?

Hi, yes I have downloaded the newest three files to custom_components/places folder