python-ring-doorbell icon indicating copy to clipboard operation
python-ring-doorbell copied to clipboard

Binary Motion and Ding sensors no longer working

Open tescophil opened this issue 5 years ago • 18 comments

Updated to the latest master which solved my auth issue (incorporating PR #176), however the binary sensors for last_motion and ding no longer work. The last motion and last ding sensors do however update with the correct times.

I see these errors in my logs:

2020-01-10 14:58:10 ERROR (SyncWorker_8) [ring_doorbell] Error!! HTTPSConnectionPool(host='api.ring.com', port=443): Read timed out. (read timeout=5)
2020-01-10 14:58:11 ERROR (MainThread) [homeassistant.helpers.entity] Update for camera.front_door fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 421, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 416, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/local/lib/python3.7/http/client.py", line 1344, in getresponse
    response.begin()
  File "/usr/local/lib/python3.7/http/client.py", line 306, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.7/http/client.py", line 267, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/local/lib/python3.7/socket.py", line 589, in readinto
    return self._sock.recv_into(b)
  File "/usr/local/lib/python3.7/site-packages/urllib3/contrib/pyopenssl.py", line 326, in recv_into
    raise timeout("The read operation timed out")
socket.timeout: The read 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 400, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/local/lib/python3.7/site-packages/urllib3/packages/six.py", line 735, in reraise
    raise value
  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 423, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 331, in _raise_timeout
    self, url, "Read timed out. (read timeout=%s)" % timeout_value
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.ring.com', port=443): Read timed out. (read timeout=5)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 281, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 461, 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/components/ring/camera.py", line 185, in update
    video_url = self._camera.recording_url(last_recording_id)
  File "/usr/local/lib/python3.7/site-packages/ring_doorbell/doorbot.py", line 329, in recording_url
    req = self._ring.query(url, raw=True)
  File "/usr/local/lib/python3.7/site-packages/ring_doorbell/__init__.py", line 246, in query
    headers=auth_header, timeout=query_timeout)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 546, in get
    return self.request('GET', 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 529, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.ring.com', port=443): Read timed out. (read timeout=5)
2020-01-10 15:08:43 ERROR (SyncWorker_14) [ring_doorbell] Error!! HTTPSConnectionPool(host='api.ring.com', port=443): Read timed out. (read timeout=5)
2020-01-10 15:08:43 ERROR (MainThread) [homeassistant.core] Error doing job: Future exception was never retrieved
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 421, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 416, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/local/lib/python3.7/http/client.py", line 1344, in getresponse
    response.begin()
  File "/usr/local/lib/python3.7/http/client.py", line 306, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.7/http/client.py", line 267, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/local/lib/python3.7/socket.py", line 589, in readinto
    return self._sock.recv_into(b)
  File "/usr/local/lib/python3.7/site-packages/urllib3/contrib/pyopenssl.py", line 326, in recv_into
    raise timeout("The read operation timed out")
socket.timeout: The read 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 400, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/local/lib/python3.7/site-packages/urllib3/packages/six.py", line 735, in reraise
    raise value
  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 423, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 331, in _raise_timeout
    self, url, "Read timed out. (read timeout=%s)" % timeout_value
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.ring.com', port=443): Read timed out. (read timeout=5)

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 "/usr/src/homeassistant/homeassistant/components/ring/__init__.py", line 79, in timer_hub_refresh
    hub_refresh()
  File "/usr/src/homeassistant/homeassistant/components/ring/__init__.py", line 87, in hub_refresh
    camera.update()
  File "/usr/local/lib/python3.7/site-packages/ring_doorbell/generic.py", line 56, in update
    self._get_health_attrs()
  File "/usr/local/lib/python3.7/site-packages/ring_doorbell/generic.py", line 103, in _get_health_attrs
    self._health_attrs = self._ring.query(url).get('device_health')
  File "/usr/local/lib/python3.7/site-packages/ring_doorbell/__init__.py", line 246, in query
    headers=auth_header, timeout=query_timeout)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 546, in get
    return self.request('GET', 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 529, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.ring.com', port=443): Read timed out. (read timeout=5)
2020-01-10 15:12:22 ERROR (SyncWorker_12) [ring_doorbell] Error!! HTTPSConnectionPool(host='api.ring.com', port=443): Read timed out. (read timeout=5)
2020-01-10 15:12:22 ERROR (MainThread) [homeassistant.helpers.entity] Update for camera.front_door fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 421, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 416, in _make_request
    httplib_response = conn.getresponse()
  File "/usr/local/lib/python3.7/http/client.py", line 1344, in getresponse
    response.begin()
  File "/usr/local/lib/python3.7/http/client.py", line 306, in begin
    version, status, reason = self._read_status()
  File "/usr/local/lib/python3.7/http/client.py", line 267, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
  File "/usr/local/lib/python3.7/socket.py", line 589, in readinto
    return self._sock.recv_into(b)
  File "/usr/local/lib/python3.7/site-packages/urllib3/contrib/pyopenssl.py", line 326, in recv_into
    raise timeout("The read operation timed out")
socket.timeout: The read 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 400, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/usr/local/lib/python3.7/site-packages/urllib3/packages/six.py", line 735, in reraise
    raise value
  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 423, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/usr/local/lib/python3.7/site-packages/urllib3/connectionpool.py", line 331, in _raise_timeout
    self, url, "Read timed out. (read timeout=%s)" % timeout_value
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.ring.com', port=443): Read timed out. (read timeout=5)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 281, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 461, 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/components/ring/camera.py", line 185, in update
    video_url = self._camera.recording_url(last_recording_id)
  File "/usr/local/lib/python3.7/site-packages/ring_doorbell/doorbot.py", line 329, in recording_url
    req = self._ring.query(url, raw=True)
  File "/usr/local/lib/python3.7/site-packages/ring_doorbell/__init__.py", line 246, in query
    headers=auth_header, timeout=query_timeout)
  File "/usr/local/lib/python3.7/site-packages/requests/sessions.py", line 546, in get
    return self.request('GET', 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 529, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.ring.com', port=443): Read timed out. (read timeout=5)

tescophil avatar Jan 10 '20 16:01 tescophil

I am seeing the same issue with the auth fixes applied. So i can see my Ring cameras in HA again now. However binary sensors and dings are no longer working.

Kussie avatar Jan 10 '20 22:01 Kussie

I have been trying to test this with my doorbell for about 30 minutes now. I don't think this is related to auth at all. This seems to be related to the timeout on http requests. The default for everything is 5 seconds except for video download as 2 minutes. Maybe related to #165

Although eventually my states for motion and ding do update.

steve-gombos avatar Jan 10 '20 23:01 steve-gombos

Yeah these are not working now with the new version. Going to look into this when I have some time.

steve-gombos avatar Jan 12 '20 03:01 steve-gombos

Last motion and last activity update. Motion detected doesn't trigger at all with or without person detection enabled

brama1966 avatar Jan 12 '20 04:01 brama1966

Seeing the same thing here the binary sensors are not updating. Looking at the events page on the ring site it seems they changed the expected output?

Edit: Yup state shows as timed out for me: "kind":"motion","state":"timed_out"

dshokouhi avatar Jan 13 '20 00:01 dshokouhi

I'm seeing inconsistent behavior over the last day of letting this run on the dev branch of HA. Yesterday I wasn't getting any alerts, and the binary sensors weren't updating. Today I have been testing the last 10 minutes and have gotten every alert and binary sensor update. Kind of strange.

steve-gombos avatar Jan 13 '20 01:01 steve-gombos

The binary sensors are powered by the dings endpoint. I've tested it with @dshokouhi and after he moved in front of his camera, the endpoint kept returning an empty list.

balloob avatar Jan 14 '20 19:01 balloob

This is also what I was seeing when I was trying to reproduce this. Maybe an issue with the ring API? I also checked the alerts object from the devices endpoint, but that just returns connection=online for me always.

steve-gombos avatar Jan 14 '20 20:01 steve-gombos

I dont understand why the ding isnt working but i can understand why the motion isnt. The motion can't be treated as a binary sensor. Ring have added person detection. Which is a new smart alert feature you can enable. So alerts to my phone come as either There is a Person detected at the Front Door or There is Motion detect at the Front Door. So it's sending a video/snapshot to image process and return a Person or Motion, so the API will have changed. I just had a thought why the ding may have been changed as well. Since the person detect is now in a feature call smart alerts and not just a separate options means the are going to be more smart alerts. For the ding I would assume not just an alert but a picture of who is at the front door. And then that could be put in to different options like its courier, if there smart enough to detect that So the API has changed.

brama1966 avatar Jan 14 '20 22:01 brama1966

Person detection is actually showing in a separate response from what I can see on the event history page. Just now my binary sensors started to work again and report on/off appropriately. I think Ring is making changes ATM but I can see a CV property that shows person detected separately.

Here is a snippet from the response on the event history page

{"events":[{"doorbot_id":ID,"ding_id":ID,"ding_id_str":"ID","kind":"motion","state":"timed_out","favorite":false,"recorded":false,"recording_status":"ready","created_at":"2020-01-14T21:27:43Z","cv_properties":{"person_detected":null,"stream_broken":null,"detection_type":null}}

As you can see above person detected is separated, it has actually been there for a few months before it was even implemented.

image

We may just need to wait until Ring is done making changes because it feels like they are actively changing things right now.

dshokouhi avatar Jan 14 '20 22:01 dshokouhi

Yep looks like Ring are doing some changes behind the scenes somewhere, with zero changes on my side (No updates to anything) dings and motion alerts have started working again.

Kussie avatar Jan 15 '20 07:01 Kussie

Obviously a lot of charge going on at the moment. I've updated to the latest version of HA beta which incorporates the latest changes and I noticed that all the WiFi sensors are missing (doorbell and chime)

tescophil avatar Jan 15 '20 07:01 tescophil

I updated to 0.104 full release on my main HA instance, so will be monitoring the binary sensors for a few days to see if updates are occurring. I hadn't had issues with this on the last 0.104 beta on my dev instance. I don't have the track person setting enabled, since some have pointed that out as a potential issue.

steve-gombos avatar Jan 16 '20 04:01 steve-gombos

My binary sensors have been updating all day actually. Just note that they are no longer on for 2 minutes. They are only on for the amount of time the video is streaming. So if for example you have motion verification enabled and you only generate motion for 5 seconds you may not see anything. Dings seem to show up very quickly as well. Right now the ding/motion sensors update every 10 seconds. I am currently testing every 5 seconds against my 4 devices to see if we hit some type of rate limit because less than 10 seconds seems to be a miss for some events.

dshokouhi avatar Jan 16 '20 04:01 dshokouhi

My binary sensors are still updating. I also submitted a PR that was merged into HA to reduce the interval from 10 seconds to 5 so we should be seeing more frequent updates in the next major release.

https://github.com/home-assistant/home-assistant/pull/30858

dshokouhi avatar Jan 17 '20 18:01 dshokouhi

Yeah I have had this running for several days now with no issues to binary sensors. I think we can probably close this issue?

steve-gombos avatar Jan 18 '20 16:01 steve-gombos

My binary sensors stopped updating yesterday and I am only getting "Last Activity" updates in HA now. I'm running 0.104.3 of HA / HASSIO which is linked to 0.6.0 of this library. Has anyone else experienced this?

I'm not getting any ring related errors in the log though. With these Ring issues lately, I switched my automations to use IFTTT to detect Ring motion but I am still relying on Ring Motion Cleared from this library.

One observation I noticed is that I was getting the IFTTT motion event in HA slightly ahead of the motion event from this library which surprised me. I was expecting more latency.

davecpearce avatar Jan 22 '20 11:01 davecpearce

myring.active_alerts() stil returns empty array.

odenisenko-zz avatar Feb 27 '20 06:02 odenisenko-zz

There hasn't been any activity on this issue recently. This issue has been automatically marked as stale because of that. It will be closed if no further activity occurs. Please make sure to update to the latest ring_doorbell version and check if that solves the issue. Thank you for your contributions.

github-actions[bot] avatar Apr 18 '24 18:04 github-actions[bot]