fhempy: Tuya Cloud

Begonnen von dominik, 30 Juli 2021, 21:36:48

Vorheriges Thema - Nächstes Thema

xypzo

#390
Hi Dominik,

I did a clean install of bullseye, things are actually running and showing up now, but my fhemserver starts and then stops quickly.

2021-11-29 14:41:38,679 - INFO     - fhempy.lib.fhem_pythonbinding: Starting fhempy...
2021-11-29 14:41:38,713 - INFO     - fhempy.lib.fhem_pythonbinding: Waiting for FHEM connection
2021-11-29 14:41:38,826 - WARNING  - asyncio: Executing <Task pending name='Task-1' coro=<async_main() running at /opt/fhem/.local/lib/python3.9/site-packages/fhempy/lib/fhem_pythonbinding.py:530> wait_for=<_GatheringFuture pending cb=[<TaskWakeupMethWrapper object at 0x75235dd8>()] created at /usr/lib/python3.9/asyncio/tasks.py:704> cb=[_run_until_complete_cb() at /usr/lib/python3.9/asyncio/base_events.py:184] created at /usr/lib/python3.9/asyncio/base_events.py:621> took 0.147 seconds
Traceback (most recent call last):
  File "/opt/fhem/FHEM/bindings/python/bin/fhempy", line 113, in <module>
    fpb.run()
  File "/opt/fhem/.local/lib/python3.9/site-packages/fhempy/lib/fhem_pythonbinding.py", line 538, in run
    asyncio.get_event_loop().run_until_complete(async_main())
  File "/usr/lib/python3.9/asyncio/base_events.py", line 642, in run_until_complete
    return future.result()
  File "/opt/fhem/.local/lib/python3.9/site-packages/fhempy/lib/fhem_pythonbinding.py", line 530, in async_main
    await websockets.serve(
  File "/opt/fhem/.local/lib/python3.9/site-packages/websockets/legacy/server.py", line 1042, in __await_impl__
    server = await self._create_server()
  File "/usr/lib/python3.9/asyncio/base_events.py", line 1494, in create_server
    raise OSError(err.errno, 'error while attempting '
OSError: [Errno 98] error while attempting to bind on address ('0.0.0.0', 15733): address already in use
Sentry is attempting to send 2 pending error messages
Waiting up to 2 seconds
Press Ctrl-C to quit


what to do?

Edit: Oh damn i think i installed the systemd_fhempy.sh option. Sry bad reader... Can i uninstall that?

dominik

Could it be that you did this step:
https://github.com/dominikkarall/fhempy#installation-short

There is a fhempy instance already running on your host ("15733 port already in use").
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

xypzo

yes i did that step, i didn't read. FML.
I will try a new install again and come back in an hour, thnx

juergen012

Läuft bei mir wieder unter Python 3.7
Fhem unter Proxmox

bewa58

Upgrade auf Bullseye mit einigen Hindernissen erledigt.
Läuft !

Anscheinend läuft auch die Tuya-Cloud wieder.
Schaltungen werden sofort angezeigt!

bitte mal testen.

Dann kann Dominik
ZitatIch habe gerade einen Workaround eingebaut, dass alle 15min der aktuelle Status von Tuya via API (statt MQTT) bezogen wird. Funktioniert zwar auch nicht 100%, aber hilft ein bisschen. Sobald es bei Tuya wieder läuft, werde ich das entfernen.
den Workaround wieder entfernen.

dominik

Ja, scheint wieder zu laufen. Workaround ist in 0.1.181 wieder entfernt :)

Die Tuya Devs haben mitgeteilt, dass es "im Laufe der Woche" behoben sein sollte. Also wenn es die nächsten Tage noch "ruckelig" ist, sollte man sich nicht wundern.
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

carlos

Hallo,
So, ich habe mir jetzt mal das gateway, die Steckdosenleiste und die Türklingel zu gelegt.
Funktioniert soweit ganz gut, jedoch bei der Steckdosenleiste fehlt mir der Ausschalter für alle 3 dosen, den gibt es in der smartlife app.
Die 1. Dose ist dann auch auf state gemappt, die 2. auf  switch_2, die 3. auf switch_3.
Finde ich nicht so ganz intuitive.
Internals:
   DEF        tuya_cloud tuya_cloud_connector bf30d34283b00ae207ikft
   DEVICEID   bf30d34283b00ae207ikft
   FHEMPYTYPE tuya_cloud
   FUUID      61a2bfba-f33f-b077-29fe-ead4c8a6c62b800c
   IODev      local_pybinding
   NAME       Steckdosenleiste_bf30d34283b00ae207ikft
   NR         257
   PYTHONTYPE tuya_cloud
   STATE      on
   TYPE       PythonModule
   READINGS:
     2021-11-29 16:51:53   active_time     1637967723
     2021-11-29 16:51:53   biz_type        18
     2021-11-29 16:51:53   category        cz
     2021-11-29 18:23:59   countdown_1     0.0
     2021-11-29 18:23:59   countdown_2     0.0
     2021-11-29 18:23:59   countdown_3     0.0
     2021-11-29 16:51:53   create_time     1637967723
     2021-11-29 16:51:53   icon            https://images.tuyaeu.com/smart/icon/ay15084906260158s3Dr/1a1039c464e4370e237f5564672869c1.png
     2021-11-29 16:51:53   id              bf30d34283b00ae207ikft
     2021-11-29 16:51:53   ip             
     2021-11-29 16:51:53   lat             49.2530
     2021-11-29 16:51:53   local_key       6a439d7be42975d1
     2021-11-29 16:51:53   lon             9.1277
     2021-11-29 16:51:53   model           Three-way smart socket (EU)
     2021-11-29 16:51:53   name            Steckdosenleiste
     2021-11-29 16:51:53   node_id         bc33acfffed841f9
     2021-11-29 16:51:53   online          off
     2021-11-29 16:51:53   owner_id        43011480
     2021-11-29 16:51:53   product_id      1obwwnmq
     2021-11-29 16:51:53   product_name    Power Strip
     2021-11-29 18:23:59   state           on
     2021-11-29 16:51:53   sub             on
     2021-11-29 18:23:59   switch_2        on
     2021-11-29 18:23:59   switch_3        on
     2021-11-29 16:51:53   time_zone       +01:00
     2021-11-29 16:51:53   uid             eu1637961043703mVBOO
     2021-11-29 16:51:53   update_time     1638056786
     2021-11-29 16:51:53   uuid            bc33acfffed841f9
   args:
     Steckdosenleiste_bf30d34283b00ae207ikft
     PythonModule
     tuya_cloud
     tuya_cloud_connector
     bf30d34283b00ae207ikft
   argsh:
Attributes:
   alias      Steckdosenleiste
   group      tuya_cloud
   room       fhempy


Die Türklingel sieht in FHEM so aus:
Internals:
   DEF        tuya_cloud tuya_cloud_connector bf7d83cc0888d028cdouzy
   DEVICEID   bf7d83cc0888d028cdouzy
   FHEMPYTYPE tuya_cloud
   FUUID      61a2bfbb-f33f-b077-ef60-eb4ced9a03b88cfa
   IODev      local_pybinding
   NAME       Tuerklingel_bf7d83cc0888d028cdouzy
   NR         258
   PYTHONTYPE tuya_cloud
   STATE      open
   TYPE       PythonModule
   READINGS:
     2021-11-29 16:51:53   active_time     1637965512
     2021-11-29 18:18:18   battery_percentage 100.0
     2021-11-29 16:51:53   biz_type        18
     2021-11-29 16:51:53   category        mcs
     2021-11-29 16:51:53   create_time     1637965512
     2021-11-29 16:51:53   icon            https://images.tuyaeu.com/smart/icon/ay1559701439060fw6BY/84e150cd3935aa21975a5f28b9927753.png
     2021-11-29 16:51:53   id              bf7d83cc0888d028cdouzy
     2021-11-29 16:51:53   ip             
     2021-11-29 16:51:53   lat             49.2530
     2021-11-29 16:51:53   local_key       6a439d7be42975d1
     2021-11-29 16:51:53   lon             9.1277
     2021-11-29 16:51:53   model           
     2021-11-29 16:51:53   name            Türklingel
     2021-11-29 16:51:53   node_id         842e14fffef81989
     2021-11-29 16:51:53   online          on
     2021-11-29 16:51:53   owner_id        43011480
     2021-11-29 16:51:53   product_id      ladpngdx
     2021-11-29 16:51:53   product_name    Doorbell
     2021-11-29 18:18:18   state           open
     2021-11-29 16:51:53   sub             on
     2021-11-29 18:18:18   temper_alarm    on
     2021-11-29 16:51:53   time_zone       +01:00
     2021-11-29 16:51:53   uid             eu1637961043703mVBOO
     2021-11-29 16:51:53   update_time     1638178932
     2021-11-29 16:51:53   uuid            842e14fffef81989
   args:
     Tuerklingel_bf7d83cc0888d028cdouzy
     PythonModule
     tuya_cloud
     tuya_cloud_connector
     bf7d83cc0888d028cdouzy
   argsh:
Attributes:
   alias      Türklingel
   group      tuya_cloud
   room       fhempy


Der state bleibt hier immer auf open nur die readings zeit ändert sich.
Ist auch nicht so ganz einsichtig, oder?

Gruß

Carlos
FHEM svn auf Intel NUC mit proxmox,1 UDOO, 3 Raspberry Pi, signalduino, nanoCUL, div. Homematic Komponenten, toom Baumarkt Funksteckdosen, einige sonoffs, hue, shelly

dominik

Hi,

das mit switch_1, usw. ist leider nicht optimal, ich habe nur noch keine bessere Lösung gefunden.
Hintergrund:
Wenn man einen Zwischenstecker hat, der nur switch_1 kann, ist es umständlich immer switch_1 on/off zu machen und der Gesamtstatus des Devices ist dann auch unbekannt. Bei den meisten Steckdosenleisten ist _1 dann auch für alle, so habe ich es bis jetzt verstanden. In SmartLife dürfte die Gesamtschaltung ein "fake" sein. Da musst du dir wahrscheinlich ein DOIF oder so basteln welches alle schaltet.

Falls es eine bessere Idee für die Handhabung gibt, gerne melden :)

Geht der Status beim debuggen auf tuyaiot von False auf True?
Das ist der Code aktuell
        # door window sensor
        elif code == "doorcontact_state":
            if value is True:
                return "open"
            return "closed"

Ist eigenartig, dass das auf open hängen bleibt. Kann nur sein, wenn tuya das nicht als bool sondern als Text liefert.
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

juergen012

Hallo,
nachdem tuya mit python 3.7 wieder lief, habe ich ein update gemacht.. Leider bekomme ich jetzt folgende Fehlermeldung:

Failed to load module tuya_cloud: Traceback (most recent call last):
  File "/opt/fhem/.local/lib/python3.7/site-packages/fhempy/lib/fhem_pythonbinding.py", line 301, in _onMessage
    functools.partial(importlib.import_module, pymodule)
  File "/opt/fhem/.local/lib/python3.7/site-packages/fhempy/lib/utils.py", line 33, in run_blocking
    return await asyncio.get_event_loop().run_in_executor(pool, function)
  File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
  File "<frozen importlib._bootstrap>", line 983, in _find_and_load
  File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/opt/fhem/.local/lib/python3.7/site-packages/fhempy/lib/tuya_cloud/tuya_cloud.py", line 5, in <module>
    from fhempy.lib.tuya_cloud.tuya_cloud_device import tuya_cloud_device
  File "/opt/fhem/.local/lib/python3.7/site-packages/fhempy/lib/tuya_cloud/tuya_cloud_device.py", line 5, in <module>
    from tuya_iot.device import TuyaDevice
  File "/opt/fhem/.local/lib/python3.7/site-packages/tuya_iot/__init__.py", line 2, in <module>
    from .device import TuyaDevice, TuyaDeviceListener, TuyaDeviceManager
  File "/opt/fhem/.local/lib/python3.7/site-packages/tuya_iot/device.py", line 7, in <module>
    from typing import Any, Literal, Optional
ImportError: cannot import name 'Literal' from 'typing' (/usr/lib/python3.7/typing.py)


Kann ich das fixen, oder .. Fhem läuft ja in einem LXC. Wenn ich den Snapshot zurückspiele, läuft es wieder..

Gruß
Jürgen k.
Fhem unter Proxmox

morrpheus

Ich hab seit heute ein kleines Problemchen. Ich wollte ein neues Gerät anlernen und hab den Server neu gestartet. Seitdem hab ich als State bei allen Geräten folgendes stehen:
Failed to load module tuya_cloud: Traceback (most recent call last): File "/opt/fhem/.local/lib/python3.7/site-packages/fhempy/lib/fhem_pythonbinding.py", line 301, in _onMessage functools.partial(importlib.import_module, pymodule) File "/opt/fhem/.local/lib/python3.7/site-packages/fhempy/lib/utils.py", line 33, in run_blocking return await asyncio.get_event_loop().run_in_executor(pool, function) File "/usr/lib/python3.7/concurrent/futures/thread.py", line 57, in run result = self.fn(*self.args, **self.kwargs) File "/usr/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1006, in _gcd_import File "", line 983, in _find_and_load File "", line 967, in _find_and_load_unlocked File "", line 677, in _load_unlocked File "", line 728, in exec_module File "", line 219, in _call_with_frames_removed File "/opt/fhem/.local/lib/python3.7/site-packages/fhempy/lib/tuya_cloud/tuya_cloud.py", line 5, in from fhempy.lib.tuya_cloud.tuya_cloud_device import tuya_cloud_device File "/opt/fhem/.local/lib/python3.7/site-packages/fhempy/lib/tuya_cloud/tuya_cloud_device.py", line 5, in from tuya_iot.device import TuyaDevice File "/opt/fhem/.local/lib/python3.7/site-packages/tuya_iot/__init__.py", line 2, in from .device import TuyaDevice, TuyaDeviceListener, TuyaDeviceManager File "/opt/fhem/.local/lib/python3.7/site-packages/tuya_iot/device.py", line 7, in from typing import Any, Literal, Optional ImportError: cannot import name 'Literal' from 'typing' (/usr/lib/python3.7/typing.py)

Und das neue Gerät wird auch nicht erkannt.
Gibt's dafür schon eine Lösung?

dominik

0.1.182 ist released, damit geht auch Python 3.7 wieder und es wird die tuya Library in der Version 0.5.0 verwendet solange 0.6.x noch nicht Python 3.7 ready ist.
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

morrpheus

Die 0.1.182 läuft schon. Ändert aber nichts.

dominik

Yep, hatte vergessen, dass paar Änderungen auch schon bei 0.5.0 von tuya kamen. Mit 0.1.183 sollte es jetzt klappen.
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

morrpheus

Läuft wieder mit 0.1.183.
Danke.

juergen012

Jepp! löppt !!! Danke!!!
Fhem unter Proxmox