Weiter zum Inhalt
  • Home
  • Aktuell
  • 0 Ungelesen 0
  • Kategorien
  • Unreplied
  • Beliebt
  • GitHub
  • Docu
  • Hilfe
Skins
  • Hell
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dunkel
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Standard: (Kein Skin)
  • Kein Skin
Einklappen
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. English
  3. Scripting / Logic
  4. JavaScript
  5. using iobroker.socket-client in a NodeJs project

NEWS

  • Neue Adresse: die ioBroker-Webseite liegt jetzt auf iobroker.com
    BluefoxB
    Bluefox
    3
    1
    133

  • Die neue ioBroker Webseite ist online!
    BluefoxB
    Bluefox
    10
    1
    171

  • Information zum Kontoabgleich und zur Namensänderung
    BluefoxB
    Bluefox
    11
    1
    489

using iobroker.socket-client in a NodeJs project

Geplant Angeheftet Gesperrt Verschoben JavaScript
6 Beiträge 3 Kommentatoren 1.9k Aufrufe 3 Beobachtet
  • Älteste zuerst
  • Neuste zuerst
  • Meiste Stimmen
Antworten
  • In einem neuen Thema antworten
Anmelden zum Antworten
Dieses Thema wurde gelöscht. Nur Nutzer mit entsprechenden Rechten können es sehen.
  • T
    T
    Taragorm
    schrieb am zuletzt editiert von
    #1

    Hi, I'm in the process of writng a NodeJs project that will talk to IOBroker.

    According to npm:

    @iobroker/socket-client@1.1.14

    when I try to create a connection, I get:

    ReferenceError: window is not defined
        at P:\Projects\Vue\logik\logik-backend\node_modules\@iobroker\socket-client\dist\cjs\Connection.js:123:7
        at new Promise (<anonymous>)
        at Connection.waitForSocketLib (P:\Projects\Vue\logik\logik-backend\node_modules\@iobroker\socket-client\dist\cjs\Connection.js:122:34)
        at new Connection (P:\Projects\Vue\logik\logik-backend\node_modules\@iobroker\socket-client\dist\cjs\Connection.js:87:10)
    

    As I understand it, this happens because "window" is not defined in NodeJS projects [I am by no means an expert JS programmer, btw]

    So.

    Is this the right library for the job?
    Does it in fact support Node?
    Am I missing some bit of initialisation to create a suitable "window" object under node.

    Hints appreciated.

    AlCalzoneA 1 Antwort Letzte Antwort
    0
    • T Taragorm

      Hi, I'm in the process of writng a NodeJs project that will talk to IOBroker.

      According to npm:

      @iobroker/socket-client@1.1.14

      when I try to create a connection, I get:

      ReferenceError: window is not defined
          at P:\Projects\Vue\logik\logik-backend\node_modules\@iobroker\socket-client\dist\cjs\Connection.js:123:7
          at new Promise (<anonymous>)
          at Connection.waitForSocketLib (P:\Projects\Vue\logik\logik-backend\node_modules\@iobroker\socket-client\dist\cjs\Connection.js:122:34)
          at new Connection (P:\Projects\Vue\logik\logik-backend\node_modules\@iobroker\socket-client\dist\cjs\Connection.js:87:10)
      

      As I understand it, this happens because "window" is not defined in NodeJS projects [I am by no means an expert JS programmer, btw]

      So.

      Is this the right library for the job?
      Does it in fact support Node?
      Am I missing some bit of initialisation to create a suitable "window" object under node.

      Hints appreciated.

      AlCalzoneA
      AlCalzoneA
      AlCalzone
      Developer
      schrieb am zuletzt editiert von
      #2

      @taragorm That library is meant for the browser.

      Warum sudo böse ist: https://forum.iobroker.net/post/17109

      T 1 Antwort Letzte Antwort
      0
      • AlCalzoneA AlCalzone

        @taragorm That library is meant for the browser.

        T
        T
        Taragorm
        schrieb am zuletzt editiert von
        #3

        @alcalzone That was my assumption.

        Is there a NodeJs version?

        I can always use the basic REST interface, but it wouldn't be my first choice here...

        BluefoxB 1 Antwort Letzte Antwort
        0
        • T Taragorm

          @alcalzone That was my assumption.

          Is there a NodeJs version?

          I can always use the basic REST interface, but it wouldn't be my first choice here...

          BluefoxB
          BluefoxB
          Bluefox
          schrieb am zuletzt editiert von
          #4

          @taragorm if you will use normal "ws" library for node.js, it will be possible to communicate with ioBroker. But ioBroker.rest-api is very advanced and supports long polling and web hooks for events.

          T 2 Antworten Letzte Antwort
          0
          • BluefoxB Bluefox

            @taragorm if you will use normal "ws" library for node.js, it will be possible to communicate with ioBroker. But ioBroker.rest-api is very advanced and supports long polling and web hooks for events.

            T
            T
            Taragorm
            schrieb am zuletzt editiert von
            #5

            @bluefox So you suggest the REST interface? - I'll go with that then. The app will likely be running on the same machine as ioBroker, anyhow.

            1 Antwort Letzte Antwort
            0
            • BluefoxB Bluefox

              @taragorm if you will use normal "ws" library for node.js, it will be possible to communicate with ioBroker. But ioBroker.rest-api is very advanced and supports long polling and web hooks for events.

              T
              T
              Taragorm
              schrieb am zuletzt editiert von
              #6

              @bluefox The API seems straightforwards enough; a couple of questions though:

              • How do I unsubscribe? - I didn't see a command for that
              • Can I do a "Bulk" subscribe - i.e. ask for a list of states?
              1 Antwort Letzte Antwort
              0

              Hey! Du scheinst an dieser Unterhaltung interessiert zu sein, hast aber noch kein Konto.

              Hast du es satt, bei jedem Besuch durch die gleichen Beiträge zu scrollen? Wenn du dich für ein Konto anmeldest, kommst du immer genau dorthin zurück, wo du zuvor warst, und kannst dich über neue Antworten benachrichtigen lassen (entweder per E-Mail oder Push-Benachrichtigung). Du kannst auch Lesezeichen speichern und Beiträge positiv bewerten, um anderen Community-Mitgliedern deine Wertschätzung zu zeigen.

              Mit deinem Input könnte dieser Beitrag noch besser werden 💗

              Registrieren Anmelden
              Antworten
              • In einem neuen Thema antworten
              Anmelden zum Antworten
              • Älteste zuerst
              • Neuste zuerst
              • Meiste Stimmen


              Support us

              ioBroker
              Community Adapters
              Donate

              483

              Online

              33.1k

              Benutzende

              83.8k

              Themen

              1.4m

              Beiträge
              Community
              Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
              ioBroker Community 2014-2026
              logo
              • Anmelden

              • Du hast noch kein Konto? Registrieren

              • Anmelden oder registrieren, um zu suchen
              • Erster Beitrag
                Letzter Beitrag
              0
              • Home
              • Aktuell
              • Ungelesen 0
              • Kategorien
              • Unreplied
              • Beliebt
              • GitHub
              • Docu
              • Hilfe