fhempy: ring (Ring Doorbell, Chime, ...)

Begonnen von dominik, 04 Januar 2021, 12:37:13

Vorheriges Thema - Nächstes Thema

MiKn

Zitat von: Mickie am 09 März 2022, 08:05:16
Guten Morgen.

Kann mir jemand sagen, warum das doif nicht meldet?
Müsste der nicht auf jede Änderung des Readings "alert_kind" reagieren inkl. Timestamp?

([rrring:alert_kind.*]) (set telegram_bot message Bewegung festgestellt)

ändert sich das reading auch? Bei mir geht es meißt nur einmal, danach nicht mehr, ich weißaber nicht ob es nur bei mir so ist.

bewa58

alert_kind ändert sich bei mir auch nicht.

habe gerade aber nen test gemacht:
bei "last_recording_id"  wird bei mir immer das reading aktualisiert.

Schaut euch auch mal die History Readings an. Vielleicht kann man daraus was bauen.
Habe da selbst noch nix gemacht, liegt noch im Keller, soll demnächst installiert werden.

Mickie

Gerade nochmal getestet. Das Reading ändert sich.
Danke für die Unterstützung

dominik

Zitat von: MiKn am 09 März 2022, 00:24:18
hmm, ich habe fhempy 0.1.268 am laufen und nach einem Neustart des Systems funktioniert Ring nicht mehr. Lösche ich das Device und lege es neu an, dann geht es bis zum Neustart von fhem, danach der selbe Fehler.

setstate fhempy_local opened
setstate fhempy_local 2022-03-09 00:20:57 hostname ubuntu
setstate fhempy_local 2022-03-09 00:20:57 os posix
setstate fhempy_local 2022-03-09 00:20:57 python 3.8.10
setstate fhempy_local 2022-03-09 00:20:57 release 5.4.0-104-generic
setstate fhempy_local 2022-03-09 00:20:57 state opened
setstate fhempy_local 2022-03-09 00:20:57 system Linux
setstate fhempy_local 2022-03-09 00:20:57 version 0.1.268


Failed to load module ring: Traceback (most recent call last):
  File "/home/fhem/.local/lib/python3.8/site-packages/fhempy/lib/fhem_pythonbinding.py", line 268, in _onMessage
    module_object = await utils.run_blocking(
  File "/home/fhem/.local/lib/python3.8/site-packages/fhempy/lib/utils.py", line 34, in run_blocking
    return await asyncio.get_event_loop().run_in_executor(pool, function)
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 848, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/fhem/.local/lib/python3.8/site-packages/fhempy/lib/ring/ring.py", line 9, in <module>
    from ring_doorbell import Auth, Ring
  File "/home/fhem/.local/lib/python3.8/site-packages/ring_doorbell/__init__.py", line 15, in <module>
    from .auth import Auth  # noqa
  File "/home/fhem/.local/lib/python3.8/site-packages/ring_doorbell/auth.py", line 5, in <module>
    from requests_oauthlib import OAuth2Session
  File "/home/fhem/.local/lib/python3.8/site-packages/requests_oauthlib/__init__.py", line 3, in <module>
    from .oauth1_auth import OAuth1
  File "/home/fhem/.local/lib/python3.8/site-packages/requests_oauthlib/oauth1_auth.py", line 10, in <module>
    from requests.utils import to_native_string
  File "/home/fhem/.local/lib/python3.8/site-packages/requests/utils.py", line 27, in <module>
    from . import certs
  File "/home/fhem/.local/lib/python3.8/site-packages/requests/__init__.py", line 135, in <module>
    from .models import Request, Response, PreparedRequest
  File "/home/fhem/.local/lib/python3.8/site-packages/requests/models.py", line 28, in <module>
    from .auth import HTTPBasicAuth
  File "/home/fhem/.local/lib/python3.8/site-packages/requests/auth.py", line 22, in <module>
    from .utils import parse_dict_header
ImportError: cannot import name 'parse_dict_header' from partially initialized module 'requests.utils' (most likely due to a circular import) (/home/fhem/.local/lib/python3.8/site-packages/requests/utils.py)


Mach bitte mal ein "pip show requests" und poste die Ausgabe.
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

MiKn

Zitatfhem@ubuntu:~$ pip show requests
Name: requests
Version: 2.27.1
Summary: Python HTTP for Humans.
Home-page: https://requests.readthedocs.io
Author: Kenneth Reitz
Author-email: me@kennethreitz.org
License: Apache 2.0
Location: /home/fhem/.local/lib/python3.8/site-packages
Requires: certifi, charset-normalizer, idna, urllib3
Required-by: casttube, requests-oauthlib, ring-doorbell, spotipy, tuya-connector-python, tuya-iot-py-sdk
fhem@ubuntu:~$


dominik

Installier bitte mal 2.26.0

sudo -u fhem bash
pip3 install requests==2.26.0

und teste dann den Neustart.
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

Per

Zitat von: Mickie am 09 März 2022, 08:05:16
([rrring:alert_kind.*]) (set telegram_bot message Bewegung festgestellt)
Musste erstmal suchen, wo das DOIF ist, üblicherweise packt man das in Code Tags.
Und DOIF RegEx packt man in "", also
(["rrring:alert_kind.*"])
wobei man manchmal mit der Syntax spielen muss, weil das gesamte Event noch Leer- oder Sonderzeichen enthält.

MiKn

Zitat von: dominik am 09 März 2022, 23:03:46
Installier bitte mal 2.26.0

sudo -u fhem bash
pip3 install requests==2.26.0

und teste dann den Neustart.

fhem@ubuntu:~$ pip3 install requests==2.26.0
Defaulting to user installation because normal site-packages is not writeable
Collecting requests==2.26.0
  Using cached requests-2.26.0-py2.py3-none-any.whl (62 kB)
Requirement already satisfied: charset-normalizer~=2.0.0 in ./.local/lib/python3.8/site-packages (from requests==2.26.0) (2.0.7)
Requirement already satisfied: idna<4,>=2.5 in ./.local/lib/python3.8/site-packages (from requests==2.26.0) (2.7)
Requirement already satisfied: certifi>=2017.4.17 in /usr/lib/python3/dist-packages (from requests==2.26.0) (2019.11.28)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in ./.local/lib/python3.8/site-packages (from requests==2.26.0) (1.24.3)
Installing collected packages: requests
  Attempting uninstall: requests
    Found existing installation: requests 2.27.1
    Uninstalling requests-2.27.1:
      Successfully uninstalled requests-2.27.1
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
spotipy 2.18.0 requires urllib3>=1.26.0, but you have urllib3 1.24.3 which is incompatible.
Successfully installed requests-2.26.0
WARNING: You are using pip version 22.0.3; however, version 22.0.4 is available.
You should consider upgrading via the '/usr/bin/python3 -m pip install --upgrade pip' command.


Traceback (most recent call last):
  File "/home/fhem/.local/lib/python3.8/site-packages/fhempy/lib/ring/ring.py", line 117, in update_loop
    await utils.run_blocking(functools.partial(self._ring.update_data))
  File "/home/fhem/.local/lib/python3.8/site-packages/fhempy/lib/utils.py", line 34, in run_blocking
    return await asyncio.get_event_loop().run_in_executor(pool, function)
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/fhem/.local/lib/python3.8/site-packages/ring_doorbell/__init__.py", line 52, in update_data
    self.create_session()
  File "/home/fhem/.local/lib/python3.8/site-packages/ring_doorbell/__init__.py", line 65, in create_session
    self.session = self.query(
  File "/home/fhem/.local/lib/python3.8/site-packages/ring_doorbell/__init__.py", line 107, in query
    return self.auth.query(
  File "/home/fhem/.local/lib/python3.8/site-packages/ring_doorbell/auth.py", line 96, in query
    self._oauth.token = self.refresh_tokens()
  File "/home/fhem/.local/lib/python3.8/site-packages/ring_doorbell/auth.py", line 56, in refresh_tokens
    token = self._oauth.refresh_token(
  File "/home/fhem/.local/lib/python3.8/site-packages/requests_oauthlib/oauth2_session.py", line 446, in refresh_token
    self.token = self._client.parse_request_body_response(r.text, scope=self.scope)
  File "/usr/lib/python3/dist-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 421, in parse_request_body_response
    self.token = parse_token_response(body, scope=scope)
  File "/usr/lib/python3/dist-packages/oauthlib/oauth2/rfc6749/parameters.py", line 431, in parse_token_response
    validate_token_parameters(params)
  File "/usr/lib/python3/dist-packages/oauthlib/oauth2/rfc6749/parameters.py", line 438, in validate_token_parameters
    raise_from_error(params.get('error'), params)
  File "/usr/lib/python3/dist-packages/oauthlib/oauth2/rfc6749/errors.py", line 405, in raise_from_error
    raise cls(**kwargs)
oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) token is invalid or does not exists
2022-03-09 23:17:56,253 - INFO     - fhempy.lib.pkg_installer: Attempting install of fhempy
2022-03-09 23:17:58,102 - INFO     - fhempy.lib.pkg_installer: Successfully installed fhempy update!
2022-03-09 23:17:58,484 - INFO     - fhempy.lib.fhem_pythonbinding: Starting fhempy...
2022-03-09 23:17:58,492 - INFO     - fhempy.lib.fhem_pythonbinding: Waiting for FHEM connection
2022-03-09 23:17:58,515 - INFO     - websockets.server: server listening on 0.0.0.0:15733
2022-03-09 23:18:08,269 - INFO     - websockets.server: connection open
2022-03-09 23:18:08,269 - INFO     - fhempy.lib.fhem_pythonbinding: Incoming FHEM connection: 127.0.0.1
2022-03-09 23:18:09,526 - ERROR    - RingDoorBell: Failed to update devices
Traceback (most recent call last):
  File "/home/fhem/.local/lib/python3.8/site-packages/ring_doorbell/auth.py", line 94, in query
    req = getattr(self._oauth, method.lower())(url, **kwargs)
  File "/home/fhem/.local/lib/python3.8/site-packages/requests/sessions.py", line 590, in post
    return self.request('POST', url, data=data, json=json, **kwargs)
  File "/home/fhem/.local/lib/python3.8/site-packages/requests_oauthlib/oauth2_session.py", line 477, in request
    url, headers, data = self._client.add_token(
  File "/usr/lib/python3/dist-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 198, in add_token
    raise TokenExpiredError()
oauthlib.oauth2.rfc6749.errors.TokenExpiredError: (token_expired)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/fhem/.local/lib/python3.8/site-packages/fhempy/lib/ring/ring.py", line 117, in update_loop
    await utils.run_blocking(functools.partial(self._ring.update_data))
  File "/home/fhem/.local/lib/python3.8/site-packages/fhempy/lib/utils.py", line 34, in run_blocking
    return await asyncio.get_event_loop().run_in_executor(pool, function)
  File "/usr/lib/python3.8/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/home/fhem/.local/lib/python3.8/site-packages/ring_doorbell/__init__.py", line 52, in update_data
    self.create_session()
  File "/home/fhem/.local/lib/python3.8/site-packages/ring_doorbell/__init__.py", line 65, in create_session
    self.session = self.query(
  File "/home/fhem/.local/lib/python3.8/site-packages/ring_doorbell/__init__.py", line 107, in query
    return self.auth.query(
  File "/home/fhem/.local/lib/python3.8/site-packages/ring_doorbell/auth.py", line 96, in query
    self._oauth.token = self.refresh_tokens()
  File "/home/fhem/.local/lib/python3.8/site-packages/ring_doorbell/auth.py", line 56, in refresh_tokens
    token = self._oauth.refresh_token(
  File "/home/fhem/.local/lib/python3.8/site-packages/requests_oauthlib/oauth2_session.py", line 446, in refresh_token
    self.token = self._client.parse_request_body_response(r.text, scope=self.scope)
  File "/usr/lib/python3/dist-packages/oauthlib/oauth2/rfc6749/clients/base.py", line 421, in parse_request_body_response
    self.token = parse_token_response(body, scope=scope)
  File "/usr/lib/python3/dist-packages/oauthlib/oauth2/rfc6749/parameters.py", line 431, in parse_token_response
    validate_token_parameters(params)
  File "/usr/lib/python3/dist-packages/oauthlib/oauth2/rfc6749/parameters.py", line 438, in validate_token_parameters
    raise_from_error(params.get('error'), params)
  File "/usr/lib/python3/dist-packages/oauthlib/oauth2/rfc6749/errors.py", line 405, in raise_from_error
    raise cls(**kwargs)
oauthlib.oauth2.rfc6749.errors.InvalidGrantError: (invalid_grant) token is invalid or does not exists



Neustart gemacht und alles wieder auf Status "connected:)!

dominik

Super! Kannst du bitte mal ein paar Restarts testen ob es sicher funktioniert?
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

MiKn

Zitat von: dominik am 09 März 2022, 23:22:28
Super! Kannst du bitte mal ein paar Restarts testen ob es sicher funktioniert?
ja, mach ich gerne. Meld mich dann.

MiKn

Jetzt wo fhempy wieder stabil läuft würde ich gerne mein Problem mit Ring ansprechen. Bei mir werden die Werte immer nur einmal aktualisiert und zwar nur kurz nach dem Neuanlegen von Ring in fhempy. Zu dem Zeitpunkt läßt sich noch set RingDoorBell Volumen ändern. Nach kurzer Zeit ist diese Möglihckeit weg und ein Anzeichen das Ring nicht mehr funktioniert.

Log Files anbei.

Danke,
MiKn

brain666

Zitat von: MiKn am 15 März 2022, 15:20:37
Jetzt wo fhempy wieder stabil läuft würde ich gerne mein Problem mit Ring ansprechen. Bei mir werden die Werte immer nur einmal aktualisiert und zwar nur kurz nach dem Neuanlegen von Ring in fhempy. Zu dem Zeitpunkt läßt sich noch set RingDoorBell Volumen ändern. Nach kurzer Zeit ist diese Möglihckeit weg und ein Anzeichen das Ring nicht mehr funktioniert.

Log Files anbei.

Danke,
MiKn

Das selbe Problem habe ich auch ich habe kein Abo bei Ring mehr das Problem ist aber auch mit Abo gewesen, dass nach einigen Tagen das Device zwar "connectet" ist
aber es ändern sich keine readings ausser "motion"

brain666

Die readings der Ring aktualisieren sich nicht alle gestern um 10:22:54 habe ich das Device vorher gelöscht und neu hinzugefügt.
das war genau die letze übertragen z.b. des readings vom battery_life

evtl. liegt es doch daran das ich kein abo mehr habe.

theoretisch sollte es aber auch ohne Abo funktionieren da die readings je empfangen werden wenn man das Device neu hinzufügt.


2022-03-30 08:04:12,650 - DEBUG    - RingDoorBell: Received dings: []
2022-03-30 08:04:13,225 - WARNING  - ring_doorbell.doorbot: Your Ring account does not have an active subscription.
2022-03-30 08:04:14,078 - WARNING  - asyncio: Executing <Task pending name='Task-65' coro=<ring.ring_login() running at /opt/fhem/.local/lib/python3.9/site-packages/fhempy/lib/ring/ring.py:110> wait_for=<Future pending cb=[<TaskWakeupMethWrapper object at 0x7f07846ceb50>()] created at /usr/lib/python3.9/asyncio/base_events.py:429> created at /usr/lib/python3.9/asyncio/tasks.py:361> took 0.330 seconds




Internals:
   .AttrList  deviceUpdateInterval dingPollInterval IODev:fhempy_peer_10_8_0_2,local_pybinding event-aggregator event-min-interval event-on-change-reading event-on-update-reading oldreadings stateFormat:textField-long timestamp-on-change-reading
   DEF        ring marco@hartung-besse.de "Haustür"
   FHEMPYTYPE ring
   FUUID      6242c1c7-f33f-078c-a973-8b61abf94e019824
   IODev      local_pybinding
   NAME       RingDoorBell
   NR         613
   PYTHONTYPE ring
   RINGDEVICE Haustür
   STATE      connected
   TYPE       PythonModule
   USERNAME   bla@bla.de
   .attraggr:
   .attrminint:
   READINGS:
     2022-03-29 10:22:54   battery_life    29
     2022-03-29 10:22:54   connection_status online
     2022-03-29 10:22:54   device_id       343ea419147b
     2022-03-29 10:22:54   existing_doorbell_type Not Present
     2022-03-29 10:22:54   family          doorbots
     2022-03-29 10:22:54   firmware        Up to Date
     2022-03-29 10:22:54   has_subscription 0
     2022-03-29 14:49:12   history_1_answered 0
     2022-03-30 06:55:44   history_1_created_at 2022-03-30 04:48:15
     2022-03-30 06:55:44   history_1_id    7080750493752016004
     2022-03-29 14:49:12   history_1_kind  motion
     2022-03-29 16:09:38   history_2_answered 0
     2022-03-30 06:55:44   history_2_created_at 2022-03-30 04:45:49
     2022-03-30 06:55:44   history_2_id    7080749866686790788
     2022-03-29 16:09:38   history_2_kind  motion
     2022-03-29 16:29:45   history_3_answered 0
     2022-03-30 06:55:44   history_3_created_at 2022-03-30 04:28:50
     2022-03-30 06:55:44   history_3_id    7080745490115116164
     2022-03-29 16:29:45   history_3_kind  motion
     2022-03-29 17:50:11   history_4_answered 0
     2022-03-30 06:55:44   history_4_created_at 2022-03-30 04:26:48
     2022-03-30 06:55:44   history_4_id    7080744966129106052
     2022-03-29 17:50:11   history_4_kind  motion
     2022-03-29 10:22:57   history_5_answered 0
     2022-03-30 06:55:44   history_5_created_at 2022-03-30 04:18:23
     2022-03-30 06:55:44   history_5_id    7080742797170621572
     2022-03-29 10:22:57   history_5_kind  motion
     2022-03-29 10:22:54   id              54705284
     2022-03-29 10:22:54   kind            cocoa_doorbell
     2022-03-30 06:55:43   last_recording_id 7080750493752016004
     2022-03-29 13:28:46   last_recording_url 0
     2022-03-29 10:22:54   latitude        50.94678
     2022-03-29 10:22:54   longitude       9.46318
     2022-03-29 10:22:54   model           Doorbell
     2022-03-29 10:22:54   name            Haustür
     2022-03-29 10:22:40   password        DEF

     2022-03-29 13:28:40   state           connected
     2022-03-29 10:22:54   subscribed      1
     2022-03-29 10:22:54   subscribed_motion 1
     2022-03-29 10:22:54   timezone        Europe/Berlin
     2022-03-30 07:35:55   token           ABC

     2022-03-29 11:23:36   volume          4
     2022-03-29 13:28:46   wifi_name       EM WLAN
     2022-03-30 06:55:43   wifi_signal_category good
     2022-03-30 06:55:43   wifi_signal_strength -58.0
   args:
     RingDoorBell
     PythonModule
     ring
     marco@hartung-besse.de
     Haustür
   argsh:
   helper:
     bm:
       PythonModule_Get:
         cnt        1
         dmx        -1000
         dtot       0
         dtotcnt    0
         mTS        30.03. 07:57:13
         max        0.00430488586425781
         tot        0.00430488586425781
         mAr:
           HASH(0x558358623018)
           ARRAY(0x55835eccf2f8)
           HASH(0x558360286ae0)
       PythonModule_Set:
         cnt        354
         dmx        -1000
         dtot       0
         dtotcnt    0
         mTS        30.03. 06:05:24
         max        0.0123710632324219
         tot        1.77647113800049
         mAr:
           HASH(0x558358623018)
           ARRAY(0x5583607f0df0)
           HASH(0x55835c2a9158)
Attributes:
   deviceUpdateInterval 600
   dingPollInterval 600
   group      ring
   room       fhempy

MiKn

ich habe auch kein Abo, weiß aber auch nicht mehr ob es mit Abo besser lief.

Naja, ich habe mir jetzt mit einer Routine unter der Amazon Alexa App erstellt die bei Bewegungserkennung vom Ring Device ein FHEM Dummy auslöst, so dass eine Nachricht auf den Fernseher angezeigt wird und über Telegram eine Nachricht geschickt wird. Workaround geht  :)

brain666

mir geht es um den battery_state für die anzeige des Akku zustands natürlich mist wenn das reading sich nicht aktualisiert :/