Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Fehler im Script "node_ssh is not a constructor"

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Fehler im Script "node_ssh is not a constructor"

    This topic has been deleted. Only users with topic management privileges can see it.
    • Chaot
      Chaot last edited by Chaot

      Kann mir jemand weiterhelfen.
      Seit heute funktioniert mein Script nicht mehr mit dem ich meinen Monitor abschalte:

      on({id: 'javascript.0.Vis.MonitorAus', val: true}, function (obj) {
       var value = obj.state.val;
       var oldValue = obj.oldState.val;
       
      node_ssh = require('node-ssh');
      
      ssh = new node_ssh();
      ssh.connect({
       host: '192.168.8.**',
       username: '**',
       password: '****'
      }).then(() => {
       ssh.execCommand("vcgencmd display_power 1");
      })
      });
      on({id: 'javascript.0.Vis.MonitorAus', val: false}, function (obj) {
       var value = obj.state.val;
       var oldValue = obj.oldState.val;
       
      node_ssh = require('node-ssh');
      
      ssh = new node_ssh();
      ssh.connect({
       host: '192.168.8.15',
       username: 'pi',
       password: '3008'
      }).then(() => {
       ssh.execCommand("vcgencmd display_power 0");
      })
      });
      

      Ich bekomme die Fehlermeldung:

      avascript.0	2020-08-20 00:12:14.499	error	(28514) at processImmediate (internal/timers.js:456:21)
      javascript.0	2020-08-20 00:12:14.499	error	(28514) at Immediate._onImmediate (/opt/iobroker/node_modules/iobroker.js-controller/lib/adapter.js:5384:37)
      javascript.0	2020-08-20 00:12:14.498	error	(28514) at Object.stateChange (/opt/iobroker/node_modules/iobroker.javascript/main.js:472:25)
      javascript.0	2020-08-20 00:12:14.498	error	(28514) at Object.callback (/opt/iobroker/node_modules/iobroker.javascript/lib/sandbox.js:1042:38)
      javascript.0	2020-08-20 00:12:14.497	error	(28514) at Object.<anonymous> (script.js.Wandtablet.Touchscreen_Ein:7:7)
      javascript.0	2020-08-20 00:12:14.474	error	(28514) Error in callback: TypeError: node_ssh is not a constructor
      

      Irgendwie bin ich mit meiner Suche recht erfolglos gewesen was den Fehler wohl auslöst.
      Wie muss ich das Script umstellen oder was benötige ich das das wieder läuft?

      Jey Cee paul53 liv-in-sky 3 Replies Last reply Reply Quote 0
      • Jey Cee
        Jey Cee Developer @Chaot last edited by

        @Chaot der Fehler liegt in der Zeile

        ssh = new node_ssh();
        

        Entferne das new und es sollt wieder laufen.

        Der Hintergrund ist das man in der Vergangenheit mit dem Wort new aus einer funktion eine Pseudo Klasse gemacht hat.
        Heute gibt es in js richtige klassen und das Paket node-ssh wurde vermutlich aktualisiert und nutzt das jetzt.

        AlCalzone 1 Reply Last reply Reply Quote 1
        • paul53
          paul53 @Chaot last edited by

          @Chaot sagte:

          Wie muss ich das Script umstellen oder was benötige ich das das wieder läuft?

          Siehe hier.

          1 Reply Last reply Reply Quote 1
          • AlCalzone
            AlCalzone Developer @Jey Cee last edited by

            @Jey-Cee sagte in Fehler im Script "node_ssh is not a constructor":

            Der Hintergrund ist das man in der Vergangenheit mit dem Wort new aus einer funktion eine Pseudo Klasse gemacht hat.

            Auch "richtige" Klassen benötigen new.

            1 Reply Last reply Reply Quote 0
            • liv-in-sky
              liv-in-sky @Chaot last edited by

              @Chaot
              nebenbei:
              geht auch mit dem neuen linux-control adapter

              https://forum.iobroker.net/topic/35870/test-adapter-linux-control-v0-x-x

              dort kann man die befehle, die man haben möchte einfach angeben und bekommt einen button als datenpunkt

              Image 13.png

              Image 15.png

              in vis:

              Image 14.png

              Chaot von.cartman 2 Replies Last reply Reply Quote 1
              • Chaot
                Chaot @liv-in-sky last edited by

                @liv-in-sky Geilomat!

                Ich wusste bisher noch nicht das ich das brauche, aber das gebe ich nicht mehr her! 👏 👏 👍

                1 Reply Last reply Reply Quote 0
                • von.cartman
                  von.cartman @liv-in-sky last edited by

                  @liv-in-sky

                  hi, wie lautet der Befehl für Monitor An/Aus?

                  liv-in-sky 2 Replies Last reply Reply Quote 0
                  • liv-in-sky
                    liv-in-sky @von.cartman last edited by

                    @von-cartman

                    Image 213.png

                    1 Reply Last reply Reply Quote 0
                    • liv-in-sky
                      liv-in-sky @von.cartman last edited by

                      @von-cartman

                      für monitor aus wird ein tool gebraucht - muss installiert werden - es simuliert einen mouseclick

                      https://linuxhint.com/xdotool_stimulate_mouse_clicks_and_keystrokes/

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post

                      Support us

                      ioBroker
                      Community Adapters
                      Donate

                      766
                      Online

                      31.7k
                      Users

                      79.8k
                      Topics

                      1.3m
                      Posts

                      javascript
                      6
                      9
                      1048
                      Loading More Posts
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes
                      Reply
                      • Reply as topic
                      Log in to reply
                      Community
                      Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                      The ioBroker Community 2014-2023
                      logo