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.

    Electricity Bill Module Development

    Scheduled Pinned Locked Moved Utilities
    19 Posts 3 Posters 4.7k Views 3 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.
    • S Offline
      SopaMaruchan @SopaMaruchan
      last edited by

      Does it help if I tell you that I got everything on my onstart function of the node_helper file?

      S S 2 Replies Last reply Reply Quote 0
      • S Offline
        sdetweil @SopaMaruchan
        last edited by

        @SopaMaruchan never done it in start.

        I usually wait til the module sends it’s 1st request

        Sam

        How to add modules

        learning how to use browser developers window for css changes

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

          @SopaMaruchan I’m realizing that my my receiveSocketNotification is not being triggered on my MM-Module file:
          f111ce89-0276-4196-a41b-2ad73b016eaa-image.png
          I logged some text after calling receiveSocketNotification function but there’s no output on console.

          node_helper:
          74f933d7-53b1-483c-b0a3-0abfe6827b34-image.png

          S mumblebajM 4 Replies Last reply Reply Quote 0
          • S Offline
            sdetweil @SopaMaruchan
            last edited by

            @SopaMaruchan if the send fails like that, not sent

            Sam

            How to add modules

            learning how to use browser developers window for css changes

            1 Reply Last reply Reply Quote 0
            • S Offline
              sdetweil @SopaMaruchan
              last edited by

              @SopaMaruchan
              let self=this

              has to be inside the getBill() function
              otherwise it could be set wrong…

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              1 Reply Last reply Reply Quote 0
              • S Offline
                sdetweil @SopaMaruchan
                last edited by sdetweil

                @SopaMaruchan maybe for debug

                inside the request() callback function,

                do a

                console.log(JSON.stringify(self, null,2))

                to see what ‘this’ was pointing to

                Sam

                How to add modules

                learning how to use browser developers window for css changes

                S 1 Reply Last reply Reply Quote 0
                • S Offline
                  SopaMaruchan @sdetweil
                  last edited by

                  @sdetweil it’s indeed pointing to my module. Here’s the output: 55021cd9-1c10-46c3-8a9d-5de1e97674a1-image.png
                  and the huge LOG ends with the last 2 arguments: null & 2 e2503443-14c0-45ad-9614-37a9392997c0-image.png

                  S 1 Reply Last reply Reply Quote 0
                  • S Offline
                    sdetweil @SopaMaruchan
                    last edited by

                    @SopaMaruchan

                    problem is that the sockets are not connected at start time. so the sendSocketNotification is a no-op.

                    u need wait til the module sends a socket message

                    the module config is not visible to the node_helper, so the module has to send it over/down…

                    Sam

                    How to add modules

                    learning how to use browser developers window for css changes

                    1 Reply Last reply Reply Quote 0
                    • mumblebajM Online
                      mumblebaj Module Developer @SopaMaruchan
                      last edited by

                      @SopaMaruchan Maybe the below example would help or serve as a guide to see if you may have the send call in the wrong place.

                      module.exports = NodeHelper.create ({
                          start: function() {
                              console.log('Starting node_helper for module: ' + this.name)
                          },
                      
                          getLights: async function(payload) {
                              var url = "http://" + payload.bridgeip + "/api/" + payload.userid + "/" + payload.lightsOrGroups;
                              
                              var response = await fetch(url)
                              if (!response.status == 200) {
                                  console.error(`Error retrieving data: ${response.statusCode} ${response.statusText}`)
                                  return;
                              }
                      
                              var result = await response.json()
                              
                              this.sendSocketNotification("lightsorgroups", result)
                          },````

                      Check out my modules at: https://github.com/mumblebaj?tab=repositories
                      Check my blog-post: https://mumblebaj.xyz/
                      Check my MM Container: https://hub.docker.com/repository/docker/mumblebaj/magicmirror/general

                      S 1 Reply Last reply Reply Quote 0
                      • S Offline
                        sdetweil @mumblebaj
                        last edited by

                        @mumblebaj he is calling from start:

                        but sockets not setup yet.

                        he really needs to wait til the module sends the 1st notification down ( what we use to send config info from module to helper)

                        Sam

                        How to add modules

                        learning how to use browser developers window for css changes

                        mumblebajM 1 Reply Last reply Reply Quote 0
                        • mumblebajM Online
                          mumblebaj Module Developer @sdetweil
                          last edited by

                          @sdetweil Ah, hopefully he caught that and changes it.

                          Check out my modules at: https://github.com/mumblebaj?tab=repositories
                          Check my blog-post: https://mumblebaj.xyz/
                          Check my MM Container: https://hub.docker.com/repository/docker/mumblebaj/magicmirror/general

                          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 / 1
                          • 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