fhempy: tuya (lokal)

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

Vorheriges Thema - Nächstes Thema

satprofi

Zitat von: Gisbert am 25 November 2025, 13:56:45Hallo Xsantos,

ich betreibe 3 Tuya-Geräte (2x schaltbare Steckdosen mit Leistungsmessung, 1x Luftentfeuchter) ausschließlich mit lokaler Cloud. Die Geräte hatten genau einmal Zugang zum Internet zur Einrichtung

Viele Grüße Gisbert



wie stellst du das an ? bei mir geht nichts mehr über lokale anbindung. nur mehr mit tuya-connector.
gruss
-----------------------------------------------------------------------
beelink miniPC - Fhem 6.x CUL 868, FS20, NetIO230 CUL 433
HMLAN, HM-CC-RT-DN,Homematic Actoren,LD382A,Telegram

Gisbert

Zitat von: satprofi am 10 Dezember 2025, 11:31:42wie stellst du das an ? bei mir geht nichts mehr über lokale anbindung. nur mehr mit tuya-connector.

Das ist jetzt schon länger her, ca. 2.5 ~ 3 Jahre. Damals funktionierte es so, dass man einen Entwickler-Account haben musste und man das jeweilige Gerät einmalig in der Cloud anmelden musste. Danach hab ich die Geräte ohne Internet-Anschluss in der lokalen Cloud betrieben. Das funktioniert bis jetzt reibungslos.

Viele Grüße Gisbert
Proxmox | UniFi | Homematic, VCCU, HMUART | ESP8266 | ATtiny85 | Wasser-, Stromzähler | tuya local | Wlan-Kamera | SIGNALduino, Rauchmelder FA21/22RF | RHASSPY | DEYE | JK-BMS | ESPHome | Panasonic Heishamon

satprofi

Zitat von: Gisbert am 10 Dezember 2025, 13:49:04
Zitat von: satprofi am 10 Dezember 2025, 11:31:42wie stellst du das an ? bei mir geht nichts mehr über lokale anbindung. nur mehr mit tuya-connector.

Das ist jetzt schon länger her, ca. 2.5 ~ 3 Jahre.  Das funktioniert bis jetzt reibungslos.

Viele Grüße Gisbert

also seitdem ich zugang zur cloud verloren hatte, klappts nur mehr über smartlife. alle befehle zu tuya_local werden nicht ausgeführt, weil "initialing"
gruss
-----------------------------------------------------------------------
beelink miniPC - Fhem 6.x CUL 868, FS20, NetIO230 CUL 433
HMLAN, HM-CC-RT-DN,Homematic Actoren,LD382A,Telegram

frank_41

Hallo fhem Leute,
habe mich auch mal an tuya probiert. Ich habe einen Wifi Thermostat von Blitzwolf BW-TRV16. Der läuft auch mit der Tuya App und ich habe
mir eine Tuya Developer Account eingerichtet. fhempy scheint die Daten auch korrekt von der Cloud zu holen.
Wenn ich den Thermostat aber anlege (mit korrekter IP) bekomme ich immer:

ERROR OPENING SOCKET!!!192.168.178.63

Mir scheint fhempy kriegt keinen Zugriff ?? Woran kann das liegen ?


Internals:
   DEF        tuya mdkqafv3dxxxxxxx bfbf2383b160xxxxxxxxx 192.168.178.63 3.3 v4dtfyxxxxxxxxxxxxxx c3864d2523xxxxxxxxxxxxxxxxxxxxxx
   DEVICEID   bfbf2383b160xxxxxxxxx
   FHEMPYTYPE tuya
   FUUID      693b1748-f33f-8841-098c-7f90c22766f73f34
   IODev      fhempy_local
   NAME       tuya_local_bfbf2383b160xxxxxxxxx
   NR         611
   PYTHONTYPE tuya
   STATE      Initializing...
   TYPE       fhempy
   eventCount 1
   READINGS:
     2025-12-11 20:11:42   active_time     1765376439
     2025-12-11 20:11:42   biz_type        0
     2025-12-11 20:11:42   category        wk
     2025-12-11 20:11:42   create_time     1765361816
     2025-12-11 20:11:42   icon            smart/icon/ay1506337792739cXrIR/a8d8220d497fc5f4d06fcd5d79c639b8.jpg
     2025-12-11 20:11:42   id              bfbf2383b160xxxxxxxxx
     2025-12-11 20:11:42   ip              77.23.71.231
     2025-12-11 20:11:42   lat             52.28
     2025-12-11 20:11:42   local_key       x*UHZYxxxxxxxxxx
     2025-12-11 20:11:42   lon             10.54
     2025-12-11 20:11:42   model           BW-TRV16
     2025-12-11 20:11:42   name            WiFi Thermostat Radiator Vavle 2
     2025-12-11 20:11:45   online          0
     2025-12-11 20:11:42   owner_id        260067294
     2025-12-11 20:11:42   product_id      mdkqafv3dxxxxxxx
     2025-12-11 20:11:42   product_name    WiFi Thermostat Radiator Vavle
     2025-12-11 21:27:51   state           Initializing...
     2025-12-11 20:11:42   sub             0
     2025-12-11 20:11:42   time_zone       +01:00
     2025-12-11 20:11:42   uid             eu176235xxxxxxxxxxxx
     2025-12-11 20:11:42   update_time     1765455575
     2025-12-11 20:11:42   uuid            305e2d23187bd145
   args:
     tuya_local_bfbf2383b160xxxxxxxxx
     fhempy
     tuya
     mdkqafv3dxxxxxxx
     bfbf2383b160xxxxxxxxx
     192.168.178.63
     3.3
     v4dtfyxxxxxxxxxxxxxx
     c3864d2523xxxxxxxxxxxxxxxxxxxxxx
   argsh:
Attributes:
   alias      WiFi Thermostat Radiator Vavle 2
   group      tuya
   localkey   x*UHZYxxxxxxxxxx
   room       fhempy
   tuya_spec_functions [{'code': 'switch', 'dp_id': 1, 'type': 'Boolean', 'values': {}, 'desc': 'switch'}, {'code': 'mode', 'dp_id': 2, 'type': 'Enum', 'values': {'range': ['auto']}, 'desc': 'mode'}, {'code': 'temp_set', 'dp_id': 3, 'type': 'Integer', 'values': {'unit': '℃', 'min': 50, 'max': 350, 'scale': 1, 'step': 5}, 'desc': 'temp set'}, {'code': 'temp_correction', 'dp_id': 7, 'type': 'Integer', 'values': {'unit': '℃', 'min': -99, 'max': 99, 'scale': 1, 'step': 1}, 'desc': 'temp correction'}, {'code': 'upper_temp', 'dp_id': 10, 'type': 'Integer', 'values': {'unit': '℃', 'min': 150, 'max': 350, 'scale': 1, 'step': 5}, 'desc': 'upper temp'}, {'code': 'lower_temp', 'dp_id': 11, 'type': 'Integer', 'values': {'unit': '℃', 'min': 50, 'max': 140, 'scale': 1, 'step': 5}, 'desc': 'lower temp'}, {'code': 'child_lock', 'dp_id': 17, 'type': 'Boolean', 'values': {}, 'desc': 'child lock'}, {'code': 'frost', 'dp_id': 20, 'type': 'Boolean', 'values': {}, 'desc': 'frost'}, {'code': 'factory_reset', 'dp_id': 103, 'type': 'Boolean', 'values': {}, 'desc': 'factory reset'}, {'code': 'work_days', 'dp_id': 104, 'type': 'Enum', 'values': {'range': ['5_2', '6_1', '7']}, 'desc': 'work days'}]
   tuya_spec_status [{'code': 'switch', 'dp_id': 1, 'type': 'Boolean', 'values': {}}, {'code': 'mode', 'dp_id': 2, 'type': 'Enum', 'values': {'range': ['auto']}}, {'code': 'temp_set', 'dp_id': 3, 'type': 'Integer', 'values': {'unit': '℃', 'min': 50, 'max': 350, 'scale': 1, 'step': 5}}, {'code': 'temp_current', 'dp_id': 4, 'type': 'Integer', 'values': {'unit': '℃', 'min': 0, 'max': 800, 'scale': 1, 'step': 1}}, {'code': 'temp_correction', 'dp_id': 7, 'type': 'Integer', 'values': {'unit': '℃', 'min': -99, 'max': 99, 'scale': 1, 'step': 1}}, {'code': 'fault', 'dp_id': 9, 'type': 'Bitmap', 'values': {'label': ['battery_temp_fault']}}, {'code': 'upper_temp', 'dp_id': 10, 'type': 'Integer', 'values': {'unit': '℃', 'min': 150, 'max': 350, 'scale': 1, 'step': 5}}, {'code': 'lower_temp', 'dp_id': 11, 'type': 'Integer', 'values': {'unit': '℃', 'min': 50, 'max': 140, 'scale': 1, 'step': 5}}, {'code': 'battery_percentage', 'dp_id': 16, 'type': 'Integer', 'values': {'unit': '%', 'min': 0, 'max': 100, 'scale': 0, 'step': 1}}, {'code': 'child_lock', 'dp_id': 17, 'type': 'Boolean', 'values': {}}, {'code': 'frost', 'dp_id': 20, 'type': 'Boolean', 'values': {}}, {'code': 'factory_reset', 'dp_id': 103, 'type': 'Boolean', 'values': {}}, {'code': 'work_days', 'dp_id': 104, 'type': 'Enum', 'values': {'range': ['5_2', '6_1', '7']}}]
   verbose    5
2025-12-11 22:06:24,335 - DEBUG    - fhempy.lib.fhem: <<< 30576647: {'awaitId': 30576647, 'NAME': 'tuya_local_bfbfxxxxxxxxxxxxx7ckrf', 'msgtype': 'command', 'command': "AttrVal('tuya_local_bfbfxxxxxxxxxxxxx7ckrf', 'tuya_spec_status', '[]')"}
2025-12-11 22:06:24,336 - DEBUG    - fhempy.lib.fhem: >>> 30576647 1.30ms: {'result': "[{'code': 'switch', 'dp_id': 1, 'type': 'Boolean', 'values': {}}, {'code': 'mode', 'dp_id': 2, 'type': 'Enum', 'values': {'range': ['auto']}}, {'code': 'temp_set', 'dp_id': 3, 'type': 'Integer', 'values': {'unit': '℃', 'min': 50, 'max': 350, 'scale': 1, 'step': 5}}, {'code': 'temp_current', 'dp_id': 4, 'type': 'Integer', 'values': {'unit': '℃', 'min': 0, 'max': 800, 'scale': 1, 'step': 1}}, {'code': 'temp_correction', 'dp_id': 7, 'type': 'Integer', 'values': {'unit': '℃', 'min': -99, 'max': 99, 'scale': 1, 'step': 1}}, {'code': 'fault', 'dp_id': 9, 'type': 'Bitmap', 'values': {'label': ['battery_temp_fault']}}, {'code': 'upper_temp', 'dp_id': 10, 'type': 'Integer', 'values': {'unit': '℃', 'min': 150, 'max': 350, 'scale': 1, 'step': 5}}, {'code': 'lower_temp', 'dp_id': 11, 'type': 'Integer', 'values': {'unit': '℃', 'min': 50, 'max': 140, 'scale': 1, 'step': 5}}, {'code': 'battery_percentage', 'dp_id': 16, 'type': 'Integer', 'values': {'unit': '%', 'min': 0, 'max': 100, 'scale': 0, 'step': 1}}, {'code': 'child_lock', 'dp_id': 17, 'type': 'Boolean', 'values': {}}, {'code': 'frost', 'dp_id': 20, 'type': 'Boolean', 'values': {}}, {'code': 'factory_reset', 'dp_id': 103, 'type': 'Boolean', 'values': {}}, {'code': 'work_days', 'dp_id': 104, 'type': 'Enum', 'values': {'range': ['5_2', '6_1', '7']}}]", 'error': 0, 'awaitId': 30576647}
2025-12-11 22:06:24,338 - DEBUG    - fhempy.lib.fhem: <<< 21070368: {'awaitId': 21070368, 'NAME': 'tuya_local_bfbfxxxxxxxxxxxxx7ckrf', 'msgtype': 'command', 'command': "ReadingsVal('tuya_local_bfbfxxxxxxxxxxxxx7ckrf', 'category', '')"}
2025-12-11 22:06:24,339 - DEBUG    - fhempy.lib.fhem: >>> 21070368 1.09ms: {'error': 0, 'result': 'wk', 'awaitId': 21070368}
2025-12-11 22:06:27,414 - DEBUG    - aiotinytuya.core: [bfbfxxxxxxxxxxxxx7ckrf] ERROR OPENING SOCKET!!!192.168.178.63
2025-12-11 22:06:27,415 - DEBUG    - fhempy.lib.fhem: <<< 13193717: {'awaitId': 13193717, 'NAME': 'tuya_local_bfbfxxxxxxxxxxxxx7ckrf', 'msgtype': 'command', 'command': "readingsBeginUpdate($defs{'tuya_local_bfbfxxxxxxxxxxxxx7ckrf'});;readingsBulkUpdateIfChanged($defs{'tuya_local_bfbfxxxxxxxxxxxxx7ckrf'},'online','0');;readingsEndUpdate($defs{'tuya_local_bfbfxxxxxxxxxxxxx7ckrf'},1);;"}
2025-12-11 22:06:27,417 - DEBUG    - fhempy.lib.fhem: >>> 13193717 1.82ms: {'result': None, 'error': 0, 'awaitId': 13193717}
2025-12-11 22:06:27,418 - ERROR    - tuya_local_bfbfxxxxxxxxxxxxx7ckrf: Failed to connect to device
Traceback (most recent call last):
  File "/opt/fhem/.fhempy/fhempy_venv/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/.fhempy/fhempy_venv/lib/python3.11/site-packages/aiotinytuya/__init__.py", line 206, in connect
    await device.start_socket()
  File "/opt/fhem/.fhempy/fhempy_venv/lib/python3.11/site-packages/aiotinytuya/core.py", line 917, in start_socket
    raise ex
  File "/opt/fhem/.fhempy/fhempy_venv/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.63', 6668)
2025-12-11 22:06:31,474 - DEBUG    - aiotinytuya.core: [bfbfxxxxxxxxxxxxx7ckrf] ERROR OPENING SOCKET!!!192.168.178.63


Raspberry Pi 3
RFXCOM_RFXtrx433
V 1.62 nanoCUL433
Jeelink LaCrosse
Jeelink PCA301.CUL_HM,Conbee, deCONZ

Prof. Dr. Peter Henning

So, ich habe zwar noch kein richtiges Erfolgserlebnis, aber immerhin so eine Art "na ja, wenigstens etwas ...".

Hier steht seit ein paar Tagen ein Katzenklo mit Internet-Verbindung zur Tuya-Cloud. Nach dem Hinweis von Gisbert auf den tuya-Konnektor in fhempy habe ich das Zeug installiert. Anleitung in Github: geht so, etwas besser als die der Chinesen. Das Device wird auch erzeugt:
Internals:
   DEF        tuya xx xx 192.168.0.50 3.3 xx
   DEVICEID   xx
   FHEMPYTYPE tuya
   FUUID      6974c5eb-f33f-8771-ebe9-3da36e05351ece92
   IODev      fhempy_local
   NAME       tuya_local_bf984ab5d1501b6f13xecf
   NR         319
   PYTHONTYPE tuya
   STATE      ready
   TYPE       fhempy
   eventCount 12
   READINGS:
     2026-01-24 14:24:41   active_time     1768993958
     2026-01-24 14:24:41   biz_type        18
     2026-01-24 14:24:41   category        msp
     2026-01-24 14:24:41   create_time     1768993958
     2026-01-24 14:24:41   icon            smart/icon/bay1627386467137Cb6K/08bca26e14c7f1ebd8e5ea27ed656783.png
     2026-01-24 14:24:41   id              xx
     2026-01-24 14:24:41   ip              109.250.28.239
     2026-01-24 14:24:41   lat             49.0664
     2026-01-24 14:24:41   local_key       xxx
     2026-01-24 14:24:41   lon             8.5154
     2026-01-24 14:24:41   name            Smart Cat Litter Box
     2026-01-24 14:35:04   online          1
     2026-01-24 14:24:41   owner_id        xx
     2026-01-24 14:24:41   product_id      xx
     2026-01-24 14:24:41   product_name    Smart Cat Litter Box
     2026-01-24 14:35:04   state           ready
     2026-01-24 14:24:41   sub             0
     2026-01-24 14:24:41   time_zone       +01:00
     2026-01-24 14:24:41   uid             xx
     2026-01-24 14:24:41   update_time     1769256876
     2026-01-24 14:24:41   uuid            e45f2dfe61e4c30b
   args:
     tuya_local_xxx
     fhempy
     tuya
     xx
     3.3
     xx
   argsh:
Attributes:
   alias      KatzenKlo
   dp_06      cat_weight
   dp_07      excretion_times_day
   dp_08      excretion_time_day
   dp_17      deodorization
   dp_22      fault
   group      tuya
   localkey   xx
   room       fhempy
   tuya_spec_functions [{'code': 'deodorization', 'dp_id': 17, 'type': 'Boolean', 'values': {}, 'desc': 'deodorization'}]
   tuya_spec_status [{'code': 'dp1', 'dp_id': 1, 'type': 'Integer', 'values': {'unit': 'x', 'min': 0, 'max': 10000, 'scale': 0, 'step': 1}},{'code': 'dp2', 'dp_id': 2, 'type': 'Integer', 'values': {'unit': 'x', 'min': 0, 'max': 10000, 'scale': 0, 'step': 1}},{'code': 'dp3', 'dp_id': 3, 'type': 'Integer', 'values': {'unit': 'x', 'min': 0, 'max': 10000, 'scale': 0, 'step': 1}},{'code': 'dp4', 'dp_id': 4, 'type': 'Integer', 'values': {'unit': 'x', 'min': 0, 'max': 10000, 'scale': 0, 'step': 1}},{'code': dp5', 'dp_id': 5, 'type': 'Integer', 'values': {'unit': 'x', 'min': 0, 'max': 10000, 'scale': 0, 'step': 1}},{'code': 'cat_weight', 'dp_id': 6, 'type': 'Integer', 'values': {'unit': 'g', 'min': 600, 'max': 10000, 'scale': 0, 'step': 1}}, {'code': 'excretion_times_day', 'dp_id': 7, 'type': 'Integer', 'values': {'unit': 'times', 'min': 0, 'max': 60, 'scale': 0, 'step': 1}}, {'code': 'excretion_time_day', 'dp_id': 8, 'type': 'Integer', 'values': {'unit': 's', 'min': 0, 'max': 1800, 'scale': 0, 'step': 1}}, {'code': 'deodorization', 'dp_id': 17, 'type': 'Boolean', 'values': {}}, {'code': 'fault', 'dp_id': 22, 'type': 'Bitmap', 'values': {'label': ['motor_fault', 'program_fault', 'g_sensor_fault']}}]


Jetzt zum ABER.

Bei der automatischen Erzeugung wird nur ein set-Befehl für die Geruchsbeseitigung erzeugt (dp 17). Alle anderen "setzbaren" Dinge und Kommandos fehlen, so z.B. der manuelle Start eines Reinigungszyklus. Und auch eine ganze Menge an Statusangaben aus der App sind hier nicht vorhanden

==> Frage 1: Wie kann man herausfinden, welche Datenpunkte vorhanden sind - sowohl spec_functions, als auch spec_status sind bisher unvollständig? Wie man oben sieht, habe ich unter spec_status einfach mal auf gut Glück Datenpunkte hinzugefügt. Nutzt aber nichts
 
==> Frage 2: Wie kann man die Kiste dazu bringen, ein Statusupdate zu senden?

LG

pah

Nobbynews


Prof. Dr. Peter Henning

#1116
Danke, hat geholfen. Datenpunkte, IDs und Beschreibungen habe ich jetzt alle.
Wenn ich jetzt das Attribut spec_functions
[{'code': 'deodorization', 'dp_id': 17, 'type': 'Boolean', 'values': {}, 'desc': 'deodorization'}]setze auf
[{'code': 'deodorization', 'dp_id': 17, 'type': 'Boolean', 'values': {}, 'desc': 'deodorization'},{'code': 'clean', 'dp_id': 101, 'type': 'Boolean', 'values': {}, 'desc': 'clean'}] sowie
{'code': 'clean', 'dp_id': 101, 'type': 'Boolean', 'values': {}}in das Attribut spec_status einfüge
und die Seite neu lade, sollte doch eigentlich der set-Befehl "set clean on/off" auftauchen. Da tut sich aber nichts.

Ich kann auch kein Attribut dp_101 auf den Wert "clean" setzen, das verweigert in dem Fall FHEM.

LG

pah