fhempy websocket geht nicht

Begonnen von mcbastian, 21 Mai 2023, 20:29:48

Vorheriges Thema - Nächstes Thema

mcbastian

Hallo,

ich versuche derzeit fhempy zu installieren. FHEM ist in der aktuellen Version, alle Perl-module sind installiert, auch das libprotocol-websocket-perl.

fhempy wird auch gestartet

1470 ?        S      0:01 python3 FHEM/bindings/python/bin/fhempy --local

jedoch erscheint im log:

2023.05.21 11:56:48 1: fhempy_local: Can't connect to ws:127.0.0.1:15733: http://ws:127.0.0.1:15733/: malformed or unsupported URL
2023.05.21 11:56:48 1: BindingsIo (fhempy_local): ERROR during connection setup: http://ws:127.0.0.1:15733/: malformed or unsupported URL

Der Fehler kommt aus der HttpUtils.pm HttpUtils_Connect-Methode. Ursache scheint die DevIo_OpenDev zu sein, die dem String ein http:// oder ein https:// voranstellt und ein / anfügt.
Ändere ich den Code in der DevIo.pm (Zeile 375) so:
   if($callback) { # reuse the nonblocking connect from HttpUtils.
      use HttpUtils;
      my $err = HttpUtils_Connect({     # Nonblocking
        timeout => $timeout,
        url     => $hash->{SSL} ? "https://$dev/" : "$dev/",
        NAME    => $hash->{NAME},
        sslargs => $hash->{sslargs} ? $hash->{sslargs} : {},
        noConn2 => 1,
        callback=> sub() {
          my ($h, $err, undef) = @_;
          &$doTcpTail($err ? undef : $h->{conn});
          return &$doCb($err ? $err : &$doTailWork());
        }
      });

und füge ein |ws in die RegEx in der Httputils.pm sehe ich mit netstat, dass eine TCP-verbindung aufgebaut wird.
2023.05.21 19:46:56 3: Opening fhempy_local device ws://127.0.0.1:15733
2023.05.21 19:46:56 3: fhempy_local device opened
Aber im fhempy-log steht nichts dazu ("server listening on..." ist der letzte Eintrag)

Der Funktionsaufruf (ein Tuya-Device einbinden) bringt dann:
2023.05.21 19:48:34 3: fhempy v1.0.0 (tuya: tuya_system)
2023.05.21 19:49:04 1: BindingsIo (fhempy_local): ERROR: Timeout while waiting for function to finish (id: 36107733)
2023.05.21 19:49:04 1:   args =>  ARRAY(0x53ef390)
2023.05.21 19:49:04 1:   defargs =>  ARRAY(0x53ef390)
2023.05.21 19:49:04 1:   NAME =>  tuya_system
2023.05.21 19:49:04 1:   FHEMPYTYPE =>  tuya
2023.05.21 19:49:04 1:   argsh =>  HASH(0x53efd20)
2023.05.21 19:49:04 1:   function =>  Define
2023.05.21 19:49:04 1:   defargsh =>  HASH(0x53efd20)
2023.05.21 19:49:04 1:   id =>  36107733
2023.05.21 19:49:04 1:   msgtype =>  function
2023.05.21 19:49:04 1:   PYTHONTYPE =>  tuya
und absolute Ruhe im fhempy log.

mcbastian

Ok, habe das Problem gerade gelöst. Manchmal ist es hilfreich jemanden zu fragen und die Antwort kommt einem selbst.
Das Update will nicht so, wie ich mir das vorgestellt habe. Habe nun alle Dateien aus der 6.2 nochmal über meine FHEM-Installation aus der .tgz drübergeschoben und schon gehts :-)