MagicMirror Forum
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • 3rd-Party-Modules
    • Donate
    • Discord
    • Register
    • Login
    A New Chapter for MagicMirror: The Community Takes the Lead
    Read the statement by Michael Teeuw here.

    MMM-Netatmo does not load

    Scheduled Pinned Locked Moved Utilities
    33 Posts 13 Posters 14.7k Views 14 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T Offline
      tommys
      last edited by

      I’m running nodejs v20.8.1 on Ubuntu 22.04 and most MagicMirror modules run fine, except for MMM-Netatmo. It seems to get stuck when fetch-ing the oauth2/token-request, though it receives a response with status 200, but then nothing seems to happen!?
      When I manually post the same request using curl from the command line, it works great and I get my access token, which I successfully can use using curl to get my api/getstationdata.
      The last thing I’m able to debug into is in the node-fetch’s worker.js file:

      process.stdin.on('end', function () {
        const input = JSON.parse(chunks.join(''))
        const request = shared.deserializeRequest(fetch, ...input)
      
        fetch(request)
          .then(response => response.buffer()
            .then(buffer => respond([
              buffer.toString('base64'),
              shared.serializeResponse(response)
            ]))
      
      

      I can see that shared is updated with at response-header, however, I cannot see the response-body data that is supposed to contain the access-token among other things. And, for me, not being a nodejs/javascript programmer, the app seems to hang with the only thing being shown in the MMM-Netatmo widget is “Loading” forever.

      What could be causing my problems?

      Of course, I have triple checked that my config settings are correct:

      {
          module: 'netatmo',
          position: 'top_center', 
          header: 'Netatmo',
          config: {
              clientId: 'xxx',
              clientSecret: 'yyy', 
              refresh_token: 'zzz', 
              moduleOrder: ["Inomhus","Utomhus"]
          }
      }
      

      Regards,
      /Tommy

      T 1 Reply Last reply Reply Quote 0
      • T Offline
        tommys @tommys
        last edited by

        @tommys
        Replying to myself since I finally have solved the problem! Netatmo is now loading fine on the latest versions of MM and MMM-Netatmo.
        The problem was actually caused by two independent problems: the module reordering algorithm and the sync-fetch library.
        The workaround I did to solve the first problem was simply to not set the moduleOrder config property, easy as that.
        The second workaround was a bit more involved, I completely removed the usage of the sync-fetch library in netatmo.js in favor of the default async version . That is, simply remove the line: const fetch = require(‘sync-fetch’), make the authenticate, loadData and socketNotificationReceived functions async, handle the promise object returned by fetch appropriately as well as the call to json().

        S CFennerC C LusbuebL 4 Replies Last reply Reply Quote 2
        • S Offline
          sdetweil @tommys
          last edited by sdetweil

          @tommys the reason for this is fetch is built in in the node 20.8 version used by the node helper.

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          1 Reply Last reply Reply Quote 0
          • CFennerC Offline
            CFenner @tommys
            last edited by

            @tommys great that you solved the issue! Would you mind contributing that back into the repository?

            T 1 Reply Last reply Reply Quote 0
            • T Offline
              tommys @CFenner
              last edited by

              @CFenner normally I would say: Yes, absolutely! But… I’m not a javascript-developer and know very little about it and node.js.
              This is the first time I dipped my toe in this world (I’ve been working for 30 years as a C++ developer :grinning_face_with_sweat: ) so I just tried things until I got it working. I have probably done something non-idiomatic or worse, so I think it is better that someone more knowledgable do a proper fix. But I’m happy to answer questions if more info than I already provided is needed.
              Btw, a big thank you for your great Netatmo-module @CFenner! :folded_hands:

              1 Reply Last reply Reply Quote 0
              • W Offline
                wwats
                last edited by

                Hello everybody, I have the same problem. Because I’m not an IT professional, I’m having trouble solving the problem with your instructions.
                The second workaround in particular is difficult:
                …I completely removed the usage of the sync-fetch library in netatmo.js in favor of the default async version . That is, simply remove the line: const fetch = require(‘sync-fetch’), make the authenticate, loadData and socketNotificationReceived functions async, handle the promise object returned by fetch appropriately as well as the call to json().

                • I can’t find the “const fetch” line in the netatmo.js file
                • how can I make functions asynchronous
                • the sentence “handle the promise object returned by fetch appropriately as well as the call to json().” I don’t really understand either

                Is it possible to make the instructions a bit more detailed? Or what is the best way to ensure that the great module works for me again?

                Thank you very much for your effort!

                1 Reply Last reply Reply Quote 0
                • C Offline
                  cgillinger @tommys
                  last edited by

                  @tommys I have the same problem, but while I can follow instructions and edit files, your description is a bit to advanced for me.

                  Could you break it down, I would really like to get the module working again!

                  CFennerC 1 Reply Last reply Reply Quote 0
                  • CFennerC Offline
                    CFenner @cgillinger
                    last edited by

                    @cgillinger I merged a PR from @ottolote to replace the sync-fetch. Please try if that fixes the issue for you. It work for me now, but also did before that change using mm v2.26.

                    C L 2 Replies Last reply Reply Quote 2
                    • C Offline
                      cgillinger @CFenner
                      last edited by

                      @CFenner And just to report back here as well: Now the module works for me again! Thnx!

                      1 Reply Last reply Reply Quote 1
                      • L Offline
                        Laz @CFenner
                        last edited by

                        @CFenner
                        Have you updated your module? Does it need to be reinstated or how to update it?

                        1 Reply Last reply Reply Quote 0
                        • L Offline
                          Laz
                          last edited by

                          I have reinstalled the entire module. And everything finally worked!) Thanks to the author of the module. I really like this module.
                          A huge only request to the author - add a pressure recalculation in mm Hg…!!!)))

                          CFennerC 1 Reply Last reply Reply Quote 0
                          • CFennerC Offline
                            CFenner @Laz
                            last edited by

                            @Laz great that it works again. Sorry that is took so long. What about the RU translations, everything good?
                            Will try to find some time for the transformation.

                            L 3 Replies Last reply Reply Quote 0
                            • L Offline
                              Laz @CFenner
                              last edited by

                              @CFenner Unfortunately, I now work remotely through VNC with a mirror, the resolution is not very high and all small details are not always clear. I will check the translation in April, as I will be in that city.
                              Thank you, I am waiting for a recount to other pressure units.!)

                              1 Reply Last reply Reply Quote 0
                              • L Offline
                                Laz
                                last edited by

                                I noticed that the module displays the wrong wind values ​ ​ from the wind sensor on the mirror. The display of speed, wind gust and wind direction is not correct… ((The display of data on the mirror from the wind sensor does not match the data in the Netatmo application and in the Netatmo personal account.

                                1 Reply Last reply Reply Quote 0
                                • L Offline
                                  Laz @CFenner
                                  last edited by

                                  @CFenner
                                  I noticed that the module displays the wrong wind values ​ ​ from the wind sensor on the mirror. The display of speed, wind gust and wind direction is not correct… ((The display of data on the mirror from the wind sensor does not match the data in the Netatmo application and in the Netatmo personal account.

                                  1 Reply Last reply Reply Quote 0
                                  • S Offline
                                    sil3ntstorm
                                    last edited by

                                    I first used another Netatmo module, but it hasn’t been updated for 4 years. I now want to use this one, but I don’t know exactly how to create the netatmo refresh token?
                                    Are there instructions for this?

                                    Can someone show the module settings here so that the data is displayed exactly like this:

                                    preview.bubbles.png

                                    CFennerC 1 Reply Last reply Reply Quote 0
                                    • CFennerC Offline
                                      CFenner @sil3ntstorm
                                      last edited by

                                      @sil3ntstorm you get the token now directly from the developer portal, see https://github.com/CFenner/MMM-Netatmo?tab=readme-ov-file#connection-to-netatmo-service-api

                                      S 1 Reply Last reply Reply Quote 1
                                      • S Offline
                                        sil3ntstorm @CFenner
                                        last edited by sil3ntstorm

                                        @CFenner

                                        Thanks, it seems to be working now, but I can’t find this setting so that the rooms are displayed one below the other. These are displayed one below the other, even if I enter false for horizontal:

                                        1c6f6fd4-40b2-4a5e-b109-4969f9394ba4-grafik.png

                                        {
                                        
                                          module: 'netatmo',
                                        
                                          position: 'bottom_left', // the location where the module should be displayed
                                        
                                          header: 'Netatmo', // a header if you like one
                                        
                                          config: {
                                        
                                            clientId: 'secret123', // your app id
                                        
                                            clientSecret: 'secret123', // your app secret
                                        
                                            refresh_token: 'secret123', // your generated refresh token   
                                        
                                            refreshInterval: '3',  
                                        
                                            dataOrder: ["Noise","Pressure","CO2","Humidity","Temperature","Rain"],
                                        
                                            design: 'bubbles',
                                        
                                            horizontal: 'true',
                                        
                                            showBattery: 'true',
                                        
                                            showWiFi: 'true',   
                                        
                                            showTrend: 'true',
                                        
                                            showMeasurementIcon: 'true',
                                        
                                            showStationName: 'true',
                                        
                                            showModuleNameOnTop: 'false',
                                        
                                            fontClassModuleName: 'xsmall',
                                        
                                            fontClassPrimary: 'xsmall',
                                        
                                            fontClassSecondary: 'xsmall',
                                        
                                            fontClassMeasurement: 'xsmall',
                                        
                                            thresholdCO2Average: '1200',
                                        
                                            thresholdCO2Bad: '1800',
                                        
                                         
                                          }
                                        
                                        },
                                        
                                        
                                        L 1 Reply Last reply Reply Quote 0
                                        • L Offline
                                          Laz @sil3ntstorm
                                          last edited by

                                          @sil3ntstorm

                                          Screenshot_42.png Screenshot_41.png

                                          1 Reply Last reply Reply Quote 0
                                          • S Offline
                                            sil3ntstorm
                                            last edited by sil3ntstorm

                                            This post is deleted!
                                            1 Reply Last reply Reply Quote 0

                                            Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                                            Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                                            With your input, this post could be even better 💗

                                            Register Login
                                            • 1
                                            • 2
                                            • 1 / 2
                                            • First post
                                              Last post
                                            Enjoying MagicMirror? Please consider a donation!
                                            MagicMirror created by Michael Teeuw.
                                            Forum managed by Sam, technical setup by Karsten.
                                            This forum is using NodeBB as its core | Contributors
                                            Contact | Privacy Policy