fhempy: tuya (lokal)

Begonnen von dominik, 26 April 2022, 19:12:25

Vorheriges Thema - Nächstes Thema

Gisbert

Hallo zusammen,

seit dem 19. Juni bekomme ich im fhempy-log folgende Einträge:
2023-06-19 09:56:33,436 - ERROR    - __main__: Failed to load fhempy
Traceback (most recent call last):
  File "/opt/fhem/FHEM/bindings/python/bin/fhempy", line 139, in <module>
    import fhempy.lib.fhem_pythonbinding as fpb
ModuleNotFoundError: No module named 'fhempy'
2023-06-19 09:56:33,462 - INFO     - __main__: Attempting install of fhempy>=0.1.462
2023-06-19 09:56:40,680 - ERROR    - __main__: Unable to install package fhempy>=0.1.462: error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
   
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
   
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
   
    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.


Wenn ich versuche, phython auf dem Server upzudaten, gelingt dies nicht.
pip3 install --upgrade fhempy
error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.

    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.

    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.

    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.

Woran kann das denn liegen und was kann ich tun?

Viele Grüße
Gisbert
Aktuelles FHEM | PROXMOX | Fujitsu Futro S740 | Debian 12 | UniFi | Homematic, VCCU, HMUART | ESP8266 | ATtiny85 | Wasser-, Stromzähler | tuya local | Wlan-Kamera | SIGNALduino, Flamingo Rauchmelder FA21/22RF | RHASSPY | DEYE | JK-BMS | ESPHome

Stefan6183

Hi Gisbert,

ich hatte die Fehlermeldung mit "externally-managed-environment" zwar selbst noch nicht, aber die möglichen Lösungswege stehen ja schon in der Fehlermeldung:
Installation über ein virtual Environment, pipx benutzen oder den Sicherheitsmechanismus mit --break-system-packages aushebeln (vorher Backup deines Servers machen!).

Ich habe zu dem Problem folgendes gefunden:
https://pythonspeed.com/articles/externally-managed-environment-pep-668/
https://stackoverflow.com/questions/75608323/how-do-i-solve-error-externally-managed-environment-everytime-i-use-pip3

Und wenn du die kompletten Hintergründe verstehen willst:
https://peps.python.org/pep-0668/

Viele Grüße
Stefan

Gisbert

Hallo Stefan,

ich hab auf Debian 12 umgestellt - damit dürfte die Ursache für das Problem halbwegs klar sein.
Vielen Dank für die Anleitungen, die für mich harter Stoff sind. Ich kann denen schon im Prinzip folgen, aber ich weiß nie, ob die vorgeschlagenen Befehle nur Beispiele oder Lösungen für das dortige Problem oder ob ich genau das, was dort steht bei mir ausführen muss - oder aber wie auch immer auf mein Problem ändern muss. Mir fehlen zuviele Grundlagen, um das jeweilig zu entscheiden.

Im Moment bleibt mir nichts anderes übrig, darauf zu hoffen, dass es einen größeren Bedarf für eine Lösung gibt, so dass ich mich an die Sache heranwage. Es sei denn du kannst mich mit dem richtigen Extrakt an Befehlszeilen der verlinkten Seiten füttern.

Viele Grüße Gisbert
Aktuelles FHEM | PROXMOX | Fujitsu Futro S740 | Debian 12 | UniFi | Homematic, VCCU, HMUART | ESP8266 | ATtiny85 | Wasser-, Stromzähler | tuya local | Wlan-Kamera | SIGNALduino, Flamingo Rauchmelder FA21/22RF | RHASSPY | DEYE | JK-BMS | ESPHome

carlos

Hallo,
Es werden ja auch updates von fhempy gemacht, die nicht funktionieren:
2023-06-22 11:47:10,174 - INFO     - fhempy.lib.fhem_pythonbinding: Starting fhempy 0.1.656...
2023-06-22 11:47:10,176 - INFO     - fhempy.lib.pkg_installer: Attempting install of async-upnp-client==0.31.2
2023-06-22 11:47:10,428 - ERROR    - fhempy.lib.pkg_installer: Unable to install package async-upnp-client==0.31.2: error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
   
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
   
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
   
    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
2023-06-22 11:47:10,429 - INFO     - fhempy.lib.pkg_installer: Attempting install of async-upnp-client==0.31.2
2023-06-22 11:47:10,677 - ERROR    - fhempy.lib.pkg_installer: Unable to install package async-upnp-client==0.31.2: error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
   
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
   
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
   
    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
2023-06-22 11:47:10,678 - INFO     - fhempy.lib.pkg_installer: Attempting install of async-upnp-client==0.31.2
2023-06-22 11:47:10,941 - ERROR    - fhempy.lib.pkg_installer: Unable to install package async-upnp-client==0.31.2: error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
   
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
   
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
   
    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
2023-06-22 11:47:10,941 - INFO     - fhempy.lib.fhem_pythonbinding: Waiting for FHEM connection
2023-06-22 11:47:10,950 - INFO     - websockets.server: server listening on 0.0.0.0:15733
2023-06-22 11:48:16,909 - INFO     - websockets.server: connection open
2023-06-22 11:48:16,909 - INFO     - fhempy.lib.fhem_pythonbinding: Incoming FHEM connection: 127.0.0.1
2023-06-22 11:48:18,871 - INFO     - fhempy.lib.pkg_installer: Attempting install of git+https://github.com/fhempy/aiotinytuya#aiotinytuya==1.12.3
2023-06-22 11:48:19,154 - ERROR    - fhempy.lib.pkg_installer: Unable to install package git+https://github.com/fhempy/aiotinytuya#aiotinytuya==1.12.3: error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
   
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
   
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
   
    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
2023-06-22 11:48:19,155 - INFO     - fhempy.lib.pkg_installer: Attempting install of git+https://github.com/fhempy/aiotinytuya#aiotinytuya==1.12.3
2023-06-22 11:48:19,412 - ERROR    - fhempy.lib.pkg_installer: Unable to install package git+https://github.com/fhempy/aiotinytuya#aiotinytuya==1.12.3: error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
   
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
   
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
   
    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
2023-06-22 11:48:19,413 - INFO     - fhempy.lib.pkg_installer: Attempting install of git+https://github.com/fhempy/aiotinytuya#aiotinytuya==1.12.3
2023-06-22 11:48:19,663 - ERROR    - fhempy.lib.pkg_installer: Unable to install package git+https://github.com/fhempy/aiotinytuya#aiotinytuya==1.12.3: error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
   
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
   
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
   
    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
2023-06-22 11:48:19,666 - INFO     - fhempy.lib.pkg_installer: Attempting install of git+https://github.com/fhempy/aiotinytuya#aiotinytuya==1.12.3
2023-06-22 11:48:19,920 - ERROR    - fhempy.lib.pkg_installer: Unable to install package git+https://github.com/fhempy/aiotinytuya#aiotinytuya==1.12.3: error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
   
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
   
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
   
    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
2023-06-22 11:48:19,921 - INFO     - fhempy.lib.pkg_installer: Attempting install of git+https://github.com/fhempy/aiotinytuya#aiotinytuya==1.12.3
2023-06-22 11:48:20,170 - ERROR    - fhempy.lib.pkg_installer: Unable to install package git+https://github.com/fhempy/aiotinytuya#aiotinytuya==1.12.3: error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
   
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
   
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
   
    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
2023-06-22 11:48:20,171 - INFO     - fhempy.lib.pkg_installer: Attempting install of git+https://github.com/fhempy/aiotinytuya#aiotinytuya==1.12.3
2023-06-22 11:48:20,461 - ERROR    - fhempy.lib.pkg_installer: Unable to install package git+https://github.com/fhempy/aiotinytuya#aiotinytuya==1.12.3: error: externally-managed-environment

× This environment is externally managed
╰─> To install Python packages system-wide, try apt install
    python3-xyz, where xyz is the package you are trying to
    install.
   
    If you wish to install a non-Debian-packaged Python package,
    create a virtual environment using python3 -m venv path/to/venv.
    Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make
    sure you have python3-full installed.
   
    If you wish to install a non-Debian packaged Python application,
    it may be easiest to use pipx install xyz, which will manage a
    virtual environment for you. Make sure you have pipx installed.
   
    See /usr/share/doc/python3.11/README.venv for more information.

note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages.
hint: See PEP 668 for the detailed specification.
2023-06-22 11:48:26,300 - ERROR    - mybackup: Failed to get https://api.github.com/repos/hubecker/fhempy_backup/contents/fhem_backup/fhem.cfg with HTTP error 401
2023-06-22 11:48:28,129 - ERROR    - tuya_cloud_connector: Please activate OpenPulsar: https://developer.tuya.com/en/docs/iot/subscribe-mq?id=Kavqcrvckbh9h
2023-06-22 11:48:29,476 - ERROR    - mybackup: Failed to put https://api.github.com/repos/hubecker/fhempy_backup/contents/fhem_backup/fhem.cfg with HTTP error 401
2023-06-22 11:48:30,070 - ERROR    - mybackup: Failed to upload file fhem.cfg
Traceback (most recent call last):
  File "/opt/fhem/.local/lib/python3.11/site-packages/fhempy/lib/github_backup/github_backup.py", line 164, in upload_file
    raise Exception(f"Failed to upload file {filename}")
Exception: Failed to upload file fhem.cfg
2023-06-22 11:48:31,952 - ERROR    - mybackup: Failed to get https://api.github.com/repos/hubecker/fhempy_backup/contents/fhem_backup/log/fhem.save with HTTP error 401
2023-06-22 11:48:33,714 - ERROR    - ZigBee_Gateway_bf2688b4ee33caf1921f1n: 'result'
Traceback (most recent call last):
  File "/opt/fhem/.local/lib/python3.11/site-packages/fhempy/lib/tuya_cloud/tuya_cloud_device.py", line 45, in _init_device
    await self._setup_device()
  File "/opt/fhem/.local/lib/python3.11/site-packages/fhempy/lib/tuya_cloud/tuya_cloud_device.py", line 74, in _setup_device
    self._t_info = await utils.run_blocking(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/fhem/.local/lib/python3.11/site-packages/fhempy/lib/utils.py", line 72, in run_blocking
    return await asyncio.get_event_loop().run_in_executor(pool, function)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/fhem/.local/lib/python3.11/site-packages/tuya_iot/device.py", line 332, in get_device_info
    return self.device_manage.get_device_info(device_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/fhem/.local/lib/python3.11/site-packages/tuya_iot/device.py", line 580, in get_device_info
    response["result"].pop("status")
    ~~~~~~~~^^^^^^^^^^
KeyError: 'result'
2023-06-22 11:48:34,993 - ERROR    - ZX7226_plug: Failed to connect to device
Traceback (most recent call last):
  File "/opt/fhem/.local/lib/python3.11/site-packages/fhempy/lib/tuya/tuya.py", line 563, in setup_connection
    self._connected_device = await asyncio.wait_for(connect_fct, timeout=15)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/tasks.py", line 479, in wait_for
    return fut.result()
           ^^^^^^^^^^^^
  File "/opt/fhem/.local/lib/python3.11/site-packages/aiotinytuya/__init__.py", line 206, in connect
    await device.start_socket()
  File "/opt/fhem/.local/lib/python3.11/site-packages/aiotinytuya/core.py", line 917, in start_socket
    raise ex
  File "/opt/fhem/.local/lib/python3.11/site-packages/aiotinytuya/core.py", line 894, in start_socket
    self.reader, self.writer = await asyncio.open_connection(
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/streams.py", line 48, in open_connection
    transport, _ = await loop.create_connection(
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 1085, in create_connection
    raise exceptions[0]
  File "/usr/lib/python3.11/asyncio/base_events.py", line 1069, in create_connection
    sock = await self._connect_sock(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/base_events.py", line 973, in _connect_sock
    await self.sock_connect(sock, address)
  File "/usr/lib/python3.11/asyncio/selector_events.py", line 634, in sock_connect
    return await fut
           ^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/selector_events.py", line 674, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
OSError: [Errno 113] Connect call failed ('192.168.178.105', 6668)
2023-06-22 11:48:35,387 - ERROR    - mybackup: Failed to put https://api.github.com/repos/hubecker/fhempy_backup/contents/fhem_backup/log/fhem.save with HTTP error 401
2023-06-22 11:48:35,390 - ERROR    - mybackup: Failed to upload file log/fhem.save
Traceback (most recent call last):
  File "/opt/fhem/.local/lib/python3.11/site-packages/fhempy/lib/github_backup/github_backup.py", line 164, in upload_file
    raise Exception(f"Failed to upload file {filename}")
Exception: Failed to upload file log/fhem.save

Diese sind aber, wenn man sie von Hand macht schon erfüllt.
pip3 install async-upnp-client  --break-system-packages
Defaulting to user installation because normal site-packages is not writeable
Requirement already satisfied: async-upnp-client in /opt/fhem/.local/lib/python3.11/site-packages (0.33.2)
Requirement already satisfied: aiohttp>=3.7.4 in /opt/fhem/.local/lib/python3.11/site-packages (from async-upnp-client) (3.8.4)
Requirement already satisfied: async-timeout<5.0,>=3.0 in /usr/lib/python3/dist-packages (from async-upnp-client) (4.0.2)
Requirement already satisfied: defusedxml>=0.6.0 in /opt/fhem/.local/lib/python3.11/site-packages (from async-upnp-client) (0.7.1)
Requirement already satisfied: python-didl-lite~=1.3.2 in /opt/fhem/.local/lib/python3.11/site-packages (from async-upnp-client) (1.3.2)
Requirement already satisfied: voluptuous>=0.12.1 in /opt/fhem/.local/lib/python3.11/site-packages (from async-upnp-client) (0.13.1)
Requirement already satisfied: attrs>=17.3.0 in /usr/lib/python3/dist-packages (from aiohttp>=3.7.4->async-upnp-client) (22.2.0)
Requirement already satisfied: charset-normalizer<4.0,>=2.0 in /usr/lib/python3/dist-packages (from aiohttp>=3.7.4->async-upnp-client) (3.0.1)
Requirement already satisfied: multidict<7.0,>=4.5 in /opt/fhem/.local/lib/python3.11/site-packages (from aiohttp>=3.7.4->async-upnp-client) (6.0.4)
Requirement already satisfied: yarl<2.0,>=1.0 in /opt/fhem/.local/lib/python3.11/site-packages (from aiohttp>=3.7.4->async-upnp-client) (1.9.2)
Requirement already satisfied: frozenlist>=1.1.1 in /opt/fhem/.local/lib/python3.11/site-packages (from aiohttp>=3.7.4->async-upnp-client) (1.3.3)
Requirement already satisfied: aiosignal>=1.1.2 in /opt/fhem/.local/lib/python3.11/site-packages (from aiohttp>=3.7.4->async-upnp-client) (1.3.1)
Requirement already satisfied: idna>=2.0 in /usr/lib/python3/dist-packages (from yarl<2.0,>=1.0->aiohttp>=3.7.4->async-upnp-client) (3.3)

Ich denke da muss eine generelle Lösung her.
Ich blicke leider auch noch nicht ganz durch, aber vielleicht sollte man das mit der venv Geschichte verfolgen und das alles von fhempy aus machen lassen, wenn das möglich ist.

Wie gesagt, ich kann es leider nicht beurteilen.

FHEM svn auf Intel NUC mit proxmox, 3 Raspberry Pi, signalduino, nanoCUL,  toom Baumarkt Funksteckdosen, einige sonoffs, hue, shelly

Gisbert

Hallo Stefan,

ich hab mich mal an eine Lösung (nennen wir es mal so, ich weiß aber nicht, ob es wirklich eine ist) gewagt.
Meine Voraussetzungen:
  • Ich hatte ein Backup.
  • Ich möchte mein Produktivsystem ohnehin kurzfristig auf einen neuen Proxmox-Server umziehen.
Insofern war mein Risiko begrenzt.

Ich habe diese Quellen benutzt:
https://stackoverflow.com/questions/75608323/how-do-i-solve-error-externally-managed-environment-everytime-i-use-pip3
https://www.youtube.com/watch?v=oTTb6iUuBWQ
Insbesondere das Youtube-Video war hilfreich, dem ich im wesentlichen gefolgt bin.
Es fehlte mir aber noch eine Datei 'requirements.txt'. Diese erhält man durch fogenden Befehl:pip freeze > requirements.txtIch habe dann python3 -m pip install -r requirements.txtausgeführt und schließlich noch:
pip3 install --upgrade fhempyund abschließend die Datei 'EXTERNALLY-MANAGED' im Ordner /usr/lib/python3.11/config-3.11-x86_64-linux-gnu gelöscht.
Danach habe ich Fhem neu gestartet (shutdown restart in der Konsole), und dann lief fhempy wieder.
Ich übernehme keine Gewähr, dafür dass es bei irgendjemand anderem funktioniert und keine Schäden anrichtet. Genauso wenig weiß ich, was von dem, was ich ausgeführt habe, wirklich notwendig war.

Viele Grüße Gisbert
Aktuelles FHEM | PROXMOX | Fujitsu Futro S740 | Debian 12 | UniFi | Homematic, VCCU, HMUART | ESP8266 | ATtiny85 | Wasser-, Stromzähler | tuya local | Wlan-Kamera | SIGNALduino, Flamingo Rauchmelder FA21/22RF | RHASSPY | DEYE | JK-BMS | ESPHome

Gisbert

Hallo zusammen,

diesmal melde ich mich, weil ich Fhem auf einen neuen Server auf Proxmox umgezogen habe. Im Wesentlichen habe ich ein Backup der gesamten Fhem-Installation auf dem neuen Server entpackt.

Ich habe die notwendigen Perlpakete für Debian 11 Bullseye installiert und folgende Definition erstellt (sie fehlte gegenüber der auf dem alten Rechner):
define fhempy_local BindingsIo fhempyNach ein paar Minuten des Wartens habe ich Fhem neu gestartet.
Jetzt nach weiteren langen Minuten des Wartens passiert noch nichts, bzw. außer das:
state Installing fhempy (15min)...
Was habe ich vergessen?
Viele Grüße
Gisbert
Aktuelles FHEM | PROXMOX | Fujitsu Futro S740 | Debian 12 | UniFi | Homematic, VCCU, HMUART | ESP8266 | ATtiny85 | Wasser-, Stromzähler | tuya local | Wlan-Kamera | SIGNALduino, Flamingo Rauchmelder FA21/22RF | RHASSPY | DEYE | JK-BMS | ESPHome

Gisbert

Hallo zusammen,

geholfen hat:
pip3 install --upgrade fhempyund ein anschließender Neustart von Fhem.

fhempy: tuya (lokal) läuft wieder - Freude :)

Viele Grüße
Gisbert
Aktuelles FHEM | PROXMOX | Fujitsu Futro S740 | Debian 12 | UniFi | Homematic, VCCU, HMUART | ESP8266 | ATtiny85 | Wasser-, Stromzähler | tuya local | Wlan-Kamera | SIGNALduino, Flamingo Rauchmelder FA21/22RF | RHASSPY | DEYE | JK-BMS | ESPHome

TheTrumpeter

Ich habe eine Frage zu den angezeigten Werten...

Habe zwei Steckdosen mit Verbrauchsmessung verbunden, aber die "energy"-Werte zwischen App und FHEM unterscheiden sich.
Steckdose 1: FHEM: 9.116, App: 13.21
Steckdose 2: FHEM: 4.868, App: 5.86

Zeigt FHEM nur die Werte an, die seit dem Einbinden/Verbinden der Steckdosen verbraucht wurden oder sollten die Werte mit der App übereinstimmen?
FHEM auf RPi3, THZ (LWZ404SOL), RPII2C & I2C_MCP342x (ADCPiZero), PowerMap, CustomReadings, RPI_GPIO, Twilight, nanoCUL (WMBus für Diehl Wasserzähler & Regenerationszähler für BWT AqaSmart), ESPEasy, TPLinkHS110

Stefan6183

#878
Vermutlich hast du dasselbe Problem wie ich, dass fhempy_local Werte-Updates der Tuya Geräte teilweise nicht mitbekommt.

Scheinbar passiert das immer, nachdem ein Tuya Gerät Offline war und kurz vor dem Senden der Werte-Updates wieder Online geht.
Ich kann das sehr gut mit meinem Kontaktsensor reproduzieren: Wenn dieser einige Minuten ohne Bewegung auf dem Tisch liegt, geht er offline. Wenn ich dann den Kontakt entferne, geht er Online und sendet ein Update des Kontaktstatus. Das ist im tuya.com Log des Geräts zu sehen, fhempy_local zeigt aber keine Veränderung (immer noch Reading doorcontact_state=on). Erst wenn ich den Kontakt innerhalb kurzer Zeit wieder dran mache und wieder weg, also wenn das Gerät erneut Werte-Updates sendet, bekommt das fhempy_local mit (Reading  doorcontact_state=off).

tuya.com Gerätelog:
2023-06-28 21:16:48    Device restart    Device restart    power off reboot    device itself   
2023-06-28 21:16:47    Report    Door Sensor    ON    device itself   
2023-06-28 21:16:44    Report    Door Sensor    off    device itself     ==> fhempy_local: erfolgreiches Update des doorcontact_state
2023-06-28 21:16:40    Report    Door Sensor    ON    device itself   
2023-06-28 21:16:39    Report    Door Sensor    off    device itself     ==> fhempy_local: kein Update des doorcontact_state
2023-06-28 21:16:39    Online    Online        device itself   
2023-06-28 21:12:18    Offline    Offline    keepalive_timeout    device itself   

Der Tuya Kontaktsensor ist in FHEM folgendermaßen definiert:

Internals:
DEF tuya <geheim><geheime IP> 3.3 <geheim> <geheim>
DEVICEID <geheim>
FHEMPYTYPE tuya
FUUID <geheim>
IODev fhempy_local
NAME tuya_local_<geheim>
NR 629
PYTHONTYPE tuya
STATE <b>Türkontakt: on<br/>Batterie: 24.0%
TYPE fhempy
eventCount 85
READINGS:
2023-06-26 11:40:51 active_time 1687772310
2023-06-28 09:53:01 battery_percentage 24.0
2023-06-26 11:40:51 biz_type 18
2023-06-26 11:40:51 category mcs
2023-06-26 11:40:51 create_time 1687185701
2023-06-28 21:16:47 doorcontact_state on
2023-06-26 11:40:51 icon smart/icon/bay1624869296421wDFy/36fa2717304f55b8a2999f5b8a469109.png
2023-06-26 11:40:51 id <geheim>
2023-06-26 11:40:51 ip <geheim>
2023-06-26 11:40:51 lat 49.3100
2023-06-26 11:40:51 local_key <geheim>
2023-06-26 11:40:51 lon 8.8300
2023-06-26 11:40:51 name Contact Sensor 3
2023-06-27 17:53:33 online 1
2023-06-26 11:40:51 owner_id <geheim>
2023-06-26 11:40:51 product_id qxu3flpqjsc1kqu3
2023-06-26 11:40:51 product_name Contact Sensor
2023-06-27 17:53:39 state ready
2023-06-26 11:40:51 sub 0
2023-06-26 11:40:51 time_zone +02:00
2023-06-26 11:40:51 uid <geheim>
2023-06-26 11:40:51 update_time 1687772388
2023-06-26 11:40:51 uuid <geheim>
args:
tuya_local_<geheim>
fhempy
tuya
<geheim>
<geheim>
<geheime IP>
3.3
<geheim>
<geheim>
argsh:
Attributes:
alias Contact Sensor 3
dp_01 doorcontact_state
dp_02 battery_percentage
group tuya
localkey <geheim>
room fhempy
stateFormat <b>Türkontakt: doorcontact_state<br/>Batterie: battery_percentage%
tuya_spec_functions []
tuya_spec_status [{'code': 'doorcontact_state', 'dp_id': 1, 'type': 'Boolean', 'values': {}}, {'code': 'battery_percentage', 'dp_id': 2, 'type': 'Integer', 'values': {'unit': '%', 'min': 0, 'max': 100, 'scale': 0, 'step': 1}}]

denis.robel

#879
Wie kann das Problem gelöst werden? Es scheint kein Push vom Tuya Device nach fhempy zu geben.
Wie kann man es synchronisieren oder triggern, dass fhempy das device lokal abfragt, wenn es online ist?

Die Zeit, die so ein Sensor online ist, ist ja auch minimal. Oder geht das nur mit tuya cloud?

Es scheint ja ein generelles Problem mit vielen passiven Sensoren zu sein.

EDIT: mein Rauchmelder funktioniert lokal nur, wenn das fhempy das Ding zu einem günstigen Zeitpunkt abfragt. Leider ist die Fehlerquote sehr hoch, was für den Rauchmelder natülich ein Ausschlußkriterium ist.
Man kann da nur Abhilfe durch eine andere Firmware schaffen (TASMOTA / OpenBeken), die dann aktiv die veränderten Werte via MQTT versendet.

EDIT2: ich hab dem RM nochmals getestet. Es muss nur lange genug rauchen, dann wird auch gepusht ... Die Smartlife App ist immer etwas zügiger als FHEM. FHEM braucht ca. 30s länger, aber  ich habe jetzt 5x hintereinander getestet und es funktioniert.
VG

Denis

Stefan6183

Hi Denis,

dass irgendwann dann doch ein Werte-Update bei fhempy_local ankommt, passt zu meinem Problem:
Wahrscheinlich geht der Rauchmelder Online, nachdem er das erste Mal Rauch bemerkt und sendet direkt ein Werte Update, das fhempy_local nicht mitbekommt, die Tuya Cloud aber schon. Dann bleibt der Rauchmelder wohl online, solange er noch Rauch bemerkt und sendet regelmäßig weitere Werte-Updates, die fhempy_local dann mitbekommt.

Kannst du mal versuchen, das tuya.com Log des Geräts mit dem Verhalten in fhempy_local zu vergleichen?
Also direkt unter https://eu.iot.tuya.com/cloud/device/detail und nicht über die Smartlife App. Die Smartlife App am Besten einfrieren und nicht starten, damit sie fhempy_local nicht die lokale Verbindung zum Tuya Gerät klaut.

Gruß
Stefan

Stefan6183

Ich habe zu den verlorenen Werte-Updates der Tuya Geräte nach Offline-Online Wechsel mal einen Github Issue aufgemacht:
https://github.com/fhempy/fhempy/issues/167

Gisbert

Hallo Stefan,

gibt es in Bezug auf fhempy irgendetwas zu bedenken bei einem Wechsel von Debian Bullseye zu Bookworm?

Wie hast du es gemacht, bzw. was ist deine Empfehlung?

Viele Grüße Gisbert
Aktuelles FHEM | PROXMOX | Fujitsu Futro S740 | Debian 12 | UniFi | Homematic, VCCU, HMUART | ESP8266 | ATtiny85 | Wasser-, Stromzähler | tuya local | Wlan-Kamera | SIGNALduino, Flamingo Rauchmelder FA21/22RF | RHASSPY | DEYE | JK-BMS | ESPHome

xeenon

Hallo,

Ich habe direkt im ersten Anlauf erfolgreich mein w2839 eingebunden. Spuckt eine Menge readings aus, aber die die ich brauche konnte ich schnell identifizieren.

Ich habe aber eine Frage. Ich verstehe das System nicht so ganz. Wie greift jetzt Fhem die Daten ab? Im Opening steht ja, dass die Cloud nur einmalig kontaktiert wird.

Viele Grüße und danke für die super Arbeit.

satprofi

ganz einfach, direkt vom Gerät selbst. den es funkt ja seine daten über deinen router in die cloud, und die fängt fhempy ab.
gruss
-----------------------------------------------------------------------
beelink miniPC - Fhem 6.x CUL 868, FS20, NetIO230 CUL 433
HMLAN, HM-CC-RT-DN,Homematic Actoren,LD382A,Telegram