fhempy: tuya (lokal)

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

Vorheriges Thema - Nächstes Thema

Maista

#795
@dominik

Ich bin immer noch verwirrt mit den vielen Keys....
Wo finde ich den eine Info an welcher Stelle und wo man diese alle findet?

Zitat- API_KEY: From tuya developer portal
  Unter Cloud>Overview
- API_SECRET: From tuya developer portal
  Unter Cloud>Overview
- DEVICE_ID: From SmartLife app, doesn't matter which device, we just need one to retrieve the proper uid from it
  Unter Cloud>Devices
  Was soll nun die "uid" sein? Im Tuya-IoT-Log hat meine App eine "uid" bekommen und unter Cloud > "Link Tuya App Account" wird eine angezeigt
- PRODUCT_ID: Set to "api" if APIKEY and APISECRET are provided, otherwise use the proper product id
  Wo sollte man diese finden können?
- LOCAL_KEY: Take that one from the tuyasystem device you created
  Noch ein Key....Ist das der Project code unter Cloud?
- VERSION: Take that one from the tuyasystem device you created (default 3.3)
  Ist das einfach 3.3 oder sollte man das bei Tuya IOT irgendwo finden können?



Dominik, in der Hilfe zu fhempy_local ist die Hilfe durch viele Leehrzeilen sehr gestreckt.
Ist das so absicht?
In Bereich der Hilfe steht z.B. "APIKEY" (das KEY ist bei mir Kursiv).
Im Define heisst es aber "API_KEY".
Das gleiche bei "APISECRET", "PRODUCTID" und "LOCALKEY".
"IP" ist wie auch manche Folgetexte ebenfalls Kursiv. Ist vermutlich so nicht gewollt ?!

PS: FHEMSync funktioniert immer noch bestens!

Danke und Gruss
Gerd

dominik

Zitat von: Maista am 14 April 2023, 12:19:552023-04-14 09:32:37   python          v3.7.3
3.7.3 ist etwas alt. Buster hat 3.9 an Bord. Mach bitte ein Python Update mit apt-get. In fhempy habe ich den Support für <3.9 eingestellt, da viele Libraries 3.9 erfordern.
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

dominik

Zitat von: SouzA am 14 April 2023, 09:09:16
Zitat von: dominik am 14 April 2023, 08:38:48Machst du in der Nacht einen Reboot oder irgendwelche Restarts? Wenn bei einem Restart gassistant vor fhempy fertig wird, dann fehlen noch die Commands im Device.
Alle paar Nächte mach ich nen automatisches Backup des Raspi.
Der startet danach aber eigentlich normal wieder fhem.

Das bedeutet aber eigentlich, dass das bei jedem normalem Restart von fhem passieren kann, oder?
Kann man da an irgendwelchen Einstellungen was drehen?

Thx & bis denn
SouzA

Als Abhilfe kannst du ein DOIF schreiben, welches auf fhempy opened reagiert und dann 60s danach ein reload bei gassistant macht.
define greload DOIF ([fhempy_local] eq "opened") (set gassistant reload)
attr greload wait 60
(ungetestet)
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

dominik

Zitat von: Maista am 14 April 2023, 14:41:41@dominik

Ich bin immer noch verwirrt mit den vielen Keys....
Wo finde ich den eine Info an welcher Stelle und wo man diese alle findet?

Zitat- API_KEY: From tuya developer portal
  Unter Cloud>Overview
- API_SECRET: From tuya developer portal
  Unter Cloud>Overview
- DEVICE_ID: From SmartLife app, doesn't matter which device, we just need one to retrieve the proper uid from it
  Unter Cloud>Devices
  Was soll nun die "uid" sein? Im Tuya-IoT-Log hat meine App eine "uid" bekommen und unter Cloud > "Link Tuya App Account" wird eine angezeigt
- PRODUCT_ID: Set to "api" if APIKEY and APISECRET are provided, otherwise use the proper product id
  Wo sollte man diese finden können?
- LOCAL_KEY: Take that one from the tuyasystem device you created
  Noch ein Key....Ist das der Project code unter Cloud?
- VERSION: Take that one from the tuyasystem device you created (default 3.3)
  Ist das einfach 3.3 oder sollte man das bei Tuya IOT irgendwo finden können?



Dominik, in der Hilfe zu fhempy_local ist die Hilfe durch viele Leehrzeilen sehr gestreckt.
Ist das so absicht?
In Bereich der Hilfe steht z.B. "APIKEY" (das KEY ist bei mir Kursiv).
Im Define heisst es aber "API_KEY".
Das gleiche bei "APISECRET", "PRODUCTID" und "LOCALKEY".
"IP" ist wie auch manche Folgetexte ebenfalls Kursiv. Ist vermutlich so nicht gewollt ?!

PS: FHEMSync funktioniert immer noch bestens!

Danke und Gruss
Gerd

Die falsche Schreibweise entsteht im Moment leider durch den "markdown to html" Konverter.

Mach bitte kein manuelles Setup, einfach automatic Setup machen, dann brauchst du nur API_KEY/SECRET und eine DeviceId. DeviceId braucht man um die uid zu erhalten. Die uid wird also sowieso automatisch bezogen und muss nicht angegeben werden.
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

Maista

Zitat von: dominik am 14 April 2023, 17:45:48
Zitat von: Maista am 14 April 2023, 12:19:552023-04-14 09:32:37   python          v3.7.3
3.7.3 ist etwas alt. Buster hat 3.9 an Bord. Mach bitte ein Python Update mit apt-get. In fhempy habe ich den Support für <3.9 eingestellt, da viele Libraries 3.9 erfordern.
Hallo Dominik.
Schau ich mir eventuell heute Abend an.
Hatte die Installation nach Anleitung durchgeführt.

Gruß Gerd

dominik

Mach mal ein
sudo apt update
sudo apt install python3

Eigentlich sollte da Python 3.9 installiert werden und nicht 3.7.
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

Maista

#801
Hallo Dominik,

ne eben nicht. Ich bin aber so weit das 3.9 (3.9.16) installiert ist.

https://raspberrytips.com/install-latest-python-raspberry-pi/

Bin gerade dran. Die 3.7 gehört da wohl noch dazu.
Ich melde mich wieder

Maista

So,

FHEM shutdown restart / reboot Pi gemacht.

Keine Änderung. Im Log steht:
Zitat2023.04.15 19:42:55 1: fhempy_local: Can't connect to ws:127.0.0.1:15733: Operation now in progress
2023.04.15 19:42:55 1: fhempy_local: Can't connect to ws:127.0.0.1:15733: 127.0.0.1: Verbindungsaufbau abgelehnt (111)
2023.04.15 19:42:55 1: BindingsIo (fhempy_local): ERROR during connection setup: 127.0.0.1: Verbindungsaufbau abgelehnt (111)
.
.
2023.04.15 19:43:08 1: ws:127.0.0.1:15733 reappeared (fhempy_local)

Internals:
   BindingType fhempy
   DEF        fhempy
   DeviceName ws:127.0.0.1:15733
   FD         103
   FUUID      64380f8b-f33f-adfe-9ff4-48b4b5051fcedade
   FVERSION   10_BindingsIo.pm:0.182830/2019-01-16
   IP         127.0.0.1
   NAME       fhempy_local
   NR         1605
   NTFY_ORDER 50-fhempy_local
   PARTIAL   
   PORT       15733
   STATE      opened
   TYPE       BindingsIo
   WEBSOCKET  1
   binary     1
   connecttime 1681580587.9812
   devioLoglevel 0
   eventCount 10
   installing 0
   localBinding 1
   nextOpenDelay 10
   prev_error 127.0.0.1: Verbindungsaufbau abgelehnt (111)
   READINGS:
     2023-04-15 19:43:08   hostname        rpi00
     2023-04-15 19:43:08   os              posix
     2023-04-15 19:43:08   python          3.9.16
     2023-04-15 19:43:08   release         5.10.103-v7l+
     2023-04-15 19:43:07   state           opened
     2023-04-15 19:43:08   system          Linux
     2023-04-15 19:43:08   version         0.1.646
     2023-04-15 19:43:08   version_available 0.1.646
     2023-04-15 19:43:08   version_release_notes <html><a href="https://github.com/fhempy/fhempy/releases" target="_blank">Release Notes</a></html>
   args:
     fhempy_local
     BindingsIo
     fhempy
   messages:
     0:
     tuya_system:
     z2m:
Attributes:
   devStateIcon {      my $attr_ver = "1.1.0";;      my $status_img = "10px-kreis-gruen";;      my $status_txt = "connected";;      my $ver = ReadingsVal($name, "version", "-");;      my $ver_available = ReadingsVal($name, "version_available", $ver);;      my $update_icon = "";;      my $refresh_img = "refresh";;      my $refresh_txt = "Update fhempy";;      if ($ver_available ne $ver) {        $refresh_img = "refresh\@orange";;        $refresh_txt = "Version ".$ver_available." available for update";;      }      if (ReadingsVal($name, "state", "disconnected") eq "disconnected") {        $status_img = "10px-kreis-rot";;        $status_txt = "disconnected";;      }      $update_icon = "<a  href=\"/fhem?cmd.dummy=set $name update&XHR=1\" title=\"Start ".$ver_available." update\">".FW_makeImage($refresh_img, $refresh_txt)."</a>";;      my $restart_icon = "<a  href=\"/fhem?cmd.dummy=set $name restart&XHR=1\" title=\"Restart fhempy\">".FW_makeImage("control_reboot")."</a>";;      "<div><a>".FW_makeImage($status_img, $status_txt)."</a><a> ".$ver." </a>".$update_icon.$restart_icon."</div>"    }
   group      fhempy
   icon       file_json-ld2
   room       fhempy
   verbose    1

Internals:
   DEF        0
   FD         95
   FUUID      64380f8b-f33f-adfe-5359-e68e35041a68342c
   FVERSION   10_fhempyServer.pm:0.182830/2019-01-16
   LAST_START 2023-04-15 19:42:50
   NAME       fhempyserver_15733
   NR         1606
   NTFY_ORDER 50-fhempyserver_15733
   PID        910
   STARTS     1
   STATE      ???
   TYPE       fhempyServer
   currentlogfile ./log/fhempy-2023-04-15.log
   eventCount 2
   logfile    ./log/fhempy-%Y-%m-%d.log
   CoProcess:
     cmdFn      fhempyServer_getCmd
     name       fhempy
     state      running FHEM/bindings/python/bin/fhempy
   READINGS:
     2023-04-15 19:42:50   fhempy          running FHEM/bindings/python/bin/fhempy
     2023-04-15 19:42:50   python          v3.9.16
Attributes:
   devStateIcon {      my $status_img = "10px-kreis-gruen";;      my $status_txt = "running";;      if (substr(ReadingsVal($name, "fhempy", "running"),0,7) ne "running") {        $status_img = "10px-kreis-rot";;        $status_txt = "stopped";;      }      "<div><a>".FW_makeImage($status_img, $status_txt)."</a><a  href=\"/fhem?cmd.dummy=set $name restart&XHR=1\" title=\"Kill and restart\">".FW_makeImage("audio_repeat")."</a></div>"      }
   group      fhempy
   icon       python
   logfile    ./log/fhempy-%Y-%m-%d.log
   nrarchive  10
   room       fhempy
   verbose    1

Internals:
   BindingType fhempy
   DEF        fhempy
   DeviceName ws:127.0.0.1:15733
   FD         103
   FUUID      64380f8b-f33f-adfe-9ff4-48b4b5051fcedade
   FVERSION   10_BindingsIo.pm:0.182830/2019-01-16
   IP         127.0.0.1
   NAME       fhempy_local
   NR         1605
   NTFY_ORDER 50-fhempy_local
   PARTIAL   
   PORT       15733
   STATE      opened
   TYPE       BindingsIo
   WEBSOCKET  1
   binary     1
   connecttime 1681580587.9812
   devioLoglevel 0
   eventCount 10
   installing 0
   localBinding 1
   nextOpenDelay 10
   prev_error 127.0.0.1: Verbindungsaufbau abgelehnt (111)
   READINGS:
     2023-04-15 19:43:08   hostname        rpi00
     2023-04-15 19:43:08   os              posix
     2023-04-15 19:43:08   python          3.9.16
     2023-04-15 19:43:08   release         5.10.103-v7l+
     2023-04-15 19:43:07   state           opened
     2023-04-15 19:43:08   system          Linux
     2023-04-15 19:43:08   version         0.1.646
     2023-04-15 19:43:08   version_available 0.1.646
     2023-04-15 19:43:08   version_release_notes <html><a href="https://github.com/fhempy/fhempy/releases" target="_blank">Release Notes</a></html>
   args:
     fhempy_local
     BindingsIo
     fhempy
   messages:
     0:
     tuya_system:
     z2m:
Attributes:
   devStateIcon {      my $attr_ver = "1.1.0";;      my $status_img = "10px-kreis-gruen";;      my $status_txt = "connected";;      my $ver = ReadingsVal($name, "version", "-");;      my $ver_available = ReadingsVal($name, "version_available", $ver);;      my $update_icon = "";;      my $refresh_img = "refresh";;      my $refresh_txt = "Update fhempy";;      if ($ver_available ne $ver) {        $refresh_img = "refresh\@orange";;        $refresh_txt = "Version ".$ver_available." available for update";;      }      if (ReadingsVal($name, "state", "disconnected") eq "disconnected") {        $status_img = "10px-kreis-rot";;        $status_txt = "disconnected";;      }      $update_icon = "<a  href=\"/fhem?cmd.dummy=set $name update&XHR=1\" title=\"Start ".$ver_available." update\">".FW_makeImage($refresh_img, $refresh_txt)."</a>";;      my $restart_icon = "<a  href=\"/fhem?cmd.dummy=set $name restart&XHR=1\" title=\"Restart fhempy\">".FW_makeImage("control_reboot")."</a>";;      "<div><a>".FW_makeImage($status_img, $status_txt)."</a><a> ".$ver." </a>".$update_icon.$restart_icon."</div>"    }
   group      fhempy
   icon       file_json-ld2
   room       fhempy
   verbose    1

Passen hier irgend welche Rechte nicht oder wird das Blockiert?
Im Device "WEB" hab ich die 127.0.0.0 als allowed eingetragen.

@dominik irgend eine Idee?


dominik

Sorry, es war mein Fehler. Buster ist noch 3.7, Bullseye ist 3.9. Da solltest du irgendwann ein Upgrade machen.

Sieht eigentlich alles gut aus, was genau funktioniert nun nicht?
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

Maista

Ich dachte eigentlich ich bin mit dem Pi4 auf dem aktuellen Stand gewesen ;)

Er findet keine Tuya und wie im Log zu sehen ist kann er keine Verbindung aufbauen.

Zitat2023.04.15 19:42:55 1: fhempy_local: Can't connect to ws:127.0.0.1:15733: Operation now in progress
2023.04.15 19:42:55 1: fhempy_local: Can't connect to ws:127.0.0.1:15733: 127.0.0.1: Verbindungsaufbau abgelehnt (111)
2023.04.15 19:42:55 1: BindingsIo (fhempy_local): ERROR during connection setup: 127.0.0.1: Verbindungsaufbau abgelehnt (111)
.
.
2023.04.15 19:43:08 1: ws:127.0.0.1:15733 reappeared (fhempy_local)

Wenn ich in meinem Netzwerk den PI auf Ports scanne wird der Port 15733 gefunden.
Wie ich das Log verstehe die Verbindung aber abgelehnt.

Zumindest verstehe ich das so. Wer die Meldung nun erzeugt kannst Du sicher eher einschätzen.

Hatte wohl vorhin das falsche Device eingefügt für "tuya_system"
Internals:
   API_KEY    s7rrxxxxxxxxxxxxxxxx
   API_SECRET 2822ff4bc11xxxxxxxxxxxxxxxx
   DEF        tuya setup s7rrxxxxxxxxxxxxxxxx 2822ff4bc11xxxxxxxxxxxxxxxx 132344xxxxxxxxx
   DEVICEID   0
   FHEMPYTYPE tuya
   FUUID      643ae647-f33f-adfe-cc84-b67bb1538ed9d582
   FVERSION   10_fhempy.pm:0.182830/2019-01-16
   IODev      fhempy_local
   NAME       tuya_system
   NR         1610
   PYTHONTYPE tuya
   REGION     eu
   STATE      found 0 devices, start local scan...
   TYPE       fhempy
   eventCount 6
   READINGS:
     2023-04-15 22:59:44   state           found 0 devices, start local scan...
   args:
     tuya_system
     fhempy
     tuya
     setup
     s7rrxxxxxxxxxxxxxxxx
     2822ff4bc11xxxxxxxxxxxxxxxx
     132344xxxxxxxxx
   argsh:
Attributes:
   group      tuya
   icon       rc_SETUP
   room       fhempy

Stimmt den meine definition des Devices ? Wenn ja dann muss es ja irgendwo noch beim Verbindungsaufbau
in FHEM hacken wenn ich das Log so verstehen kann?

ZigBee2MQTT hab ich zum laufen gebracht.

dominik

Die Verbindung ist da, das ist alles gut. Der Fehler um 19:43:55 ist, weil zu dem Zeitpunkt fhempy nicht gelaufen ist. Um 19:43:08 ist die Verbindung wieder aufgebaut worden und fhempy_local hat wahrscheinlich auch eine grüne Bubble.

Prüfe mal folgende Sachen:
 - iot Cloud ist mit QR Code mit SmartLife verbunden?
 - Du siehst in der iot Cloud die Devices?
 - iot Cloud ist auf Central Europe eingestellt?
 - Poste bitte auch das fhempy Log beim Scan.
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

Maista

ZitatPrüfe mal folgende Sachen:
 - iot Cloud ist mit QR Code mit SmartLife verbunden? JA. Kann die Steckdosen per APP schalten
 - Du siehst in der iot Cloud die Devices? JA. kann sie via Tuya IOT schalten
 - iot Cloud ist auf Central Europe eingestellt?  JA

Zitat- Poste bitte auch das fhempy Log beim Scan.
Mit verbose 5 in diesem Device?

dominik

Ja, verbose 5 in tuya_system.

Poste bitte einen Screenshot von den Device in tuya iot Cloud.
fhempy -  https://github.com/fhempy/fhempy: GoogleCast, Tuya, UPnP, Ring, EQ3BT, Nespresso, Xiaomi, Spotify, Object Detection, ...
Kaffeespende: https://paypal.me/todominik

Maista

Hier erst mal die Geräte bei Tuya

Um die NX-4491 gehts. Sind von Pearl.

Maista

Im fhem-log finde ich gar nix bei Verbose 5.

Nur das hier im fhempy.log
Zitat2023-04-15 23:19:51,034 - DEBUG    - tuya_system: Device Listing
2023-04-15 23:19:51,034 - DEBUG    - tuya_system: []
2023-04-15 23:19:51,041 - DEBUG    - tuya_system: Scan local devices...
2023-04-15 23:20:11,090 - DEBUG    - tuya_system: Polling local devices...

Allerdings finde ich das
Zitatprev_error 127.0.0.1: Verbindungsaufbau abgelehnt (111)
nicht mehr in den fhempy_local?