Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. English
    3. Scripting / Logic
    4. JavaScript
    5. using iobroker.socket-client in a NodeJs project

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    using iobroker.socket-client in a NodeJs project

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

      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.

      AlCalzone 1 Reply Last reply Reply Quote 0
      • AlCalzone
        AlCalzone Developer @Taragorm last edited by

        @taragorm That library is meant for the browser.

        T 1 Reply Last reply Reply Quote 0
        • T
          Taragorm @AlCalzone last edited by

          @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...

          Bluefox 1 Reply Last reply Reply Quote 0
          • Bluefox
            Bluefox @Taragorm last edited by

            @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 Replies Last reply Reply Quote 0
            • T
              Taragorm @Bluefox last edited by

              @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 Reply Last reply Reply Quote 0
              • T
                Taragorm @Bluefox last edited by

                @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 Reply Last reply Reply Quote 0
                • First post
                  Last post

                Support us

                ioBroker
                Community Adapters
                Donate

                904
                Online

                31.8k
                Users

                80.0k
                Topics

                1.3m
                Posts

                3
                6
                610
                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