• Recent
  • Tags
  • Unsolved
  • Solved
  • MagicMirror² Repository
  • Documentation
  • 3rd-Party-Modules
  • Donate
  • Discord
  • Register
  • Login
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.

Connecting Modules to Each Other

Scheduled Pinned Locked Moved Solved Troubleshooting
16 Posts 3 Posters 3.0k 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
    sdetweil @tonkxy
    last edited by Oct 7, 2021, 7:18 PM

    @tonkxy maybe the payload in the notification doesn’t have ‘type’

    u can debug the code in the developers window, ctrl-shift-i, select the source tab,
    and navigate to your module and select the js file

    then the source will appear on the right…

    to stop at an instruction

    click the line number in the left edge of the source display, it should turn blue

    then fresh the page (f5)

    and code will stop there, you can examine and change the variables/data and step thru the code (the dot with the curved arrow over it, is step one instruction at a time. )

    to resume, hit run (blue arrow) and if the debugger is still up, it will stop there again at the next time
    (if u stopped on a weather notification for example)

    Sam

    How to add modules

    learning how to use browser developers window for css changes

    T 1 Reply Last reply Oct 7, 2021, 7:29 PM Reply Quote 0
    • M Offline
      MMRIZE @tonkxy
      last edited by Oct 7, 2021, 7:28 PM

      @tonkxy
      Hmmmm… I cannot understand the setCurrentWeatherType.

      Anyway, I recommend you this module; https://github.com/BrianHepler/MMM-WeatherBackground
      You need to study how MM module works, at least to train how to use.

      You don’t need to pull weather info from an external weather API like Darksky. Already there are many modules showing weather info on MM screen and spitting that info out through notification.

      For example, default weather module also emit notifications of weather info periodically. All you need to do is catching that notification and consume them in your module.

      default weather module would emit CURRENTWEATHER_TYPE notification.
      You can catch that notification like this.

      
      notificationReceived: function (notification, payload, sender) {
        if (notification === 'CURRENTWEATHER_TYPE') {
           console.log(payload) // manipulate payload then extract data what you need.
           // do your job
        }
      }
      

      Anyway, Study the above module. That has almost all features you are trying. (except the image source)

      1 Reply Last reply Reply Quote 0
      • T Offline
        tonkxy @sdetweil
        last edited by Oct 7, 2021, 7:29 PM

        @sdetweil great callout! I did not know I could debug. I do get a type back. I did the break trick on where its in an if statement and the type is still undefined in setImage

        S 1 Reply Last reply Oct 7, 2021, 8:04 PM Reply Quote 0
        • S Offline
          sdetweil @tonkxy
          last edited by Oct 7, 2021, 8:04 PM

          @tonkxy well

          setImage: function () {
            let rand = Math.floor(Math.random() * 4)+1; //randomn number to pick gif
          	var day = new Date();
          	var hour = day.getHours();
          	var type = this.currentWeatherTemperature;   // < ----
          

          notification

          //From data currentweather set weather type
          	setCurrentWeatherType: function(type){
          	this.currentWeatherType = type;    // < ----
          },
          
          notificationReceived: function (notification, payload, sender) {
          	  if (notification === 'DOM_OBJECTS_CREATED') {
          	    this.job()
          	  }
          //weather dom
          	if(notification === "CURRENTWEATHER_TYPE"){
          		this.setCurrentWeatherType(payload.type);
          	}
          },
          

          this.currentWeatherTemperature is NOT this.currentWeatherType

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          T 1 Reply Last reply Oct 7, 2021, 9:32 PM Reply Quote 1
          • T Offline
            tonkxy @sdetweil
            last edited by Oct 7, 2021, 9:32 PM

            @sdetweil that definitely was part of it.

            I am able to successfully see the payload in notifications. Just working a way to retain it and be able to use in setImage. Thank you!

            S 1 Reply Last reply Oct 7, 2021, 9:37 PM Reply Quote 0
            • S Offline
              sdetweil @tonkxy
              last edited by sdetweil Oct 7, 2021, 9:40 PM Oct 7, 2021, 9:37 PM

              @tonkxy should be able to save the payload pointer and then use that day later. I do it all the time

              this.weatherInfo = payload

              for example

              remember your module could get called at getDom() long before the other module sends the notification, so u need to check if it has arrived yet.

              Sam

              How to add modules

              learning how to use browser developers window for css changes

              T 1 Reply Last reply Oct 7, 2021, 9:39 PM Reply Quote 0
              • T Offline
                tonkxy @sdetweil
                last edited by Oct 7, 2021, 9:39 PM

                @sdetweil funny you say that. Ive been reading and you offered the solution on someone using compliments + weather. My issue is when i step through to set image, the type is back to undefined and not carried from the notification. Im wondering if its in my order as to why its going back to undefined

                S 1 Reply Last reply Oct 7, 2021, 9:50 PM Reply Quote 0
                • S Offline
                  sdetweil @tonkxy
                  last edited by Oct 7, 2021, 9:50 PM

                  @tonkxy I would put a stop everywhere u set it.

                  make sure the this. pointer is pointing to the same place set vs use

                  Sam

                  How to add modules

                  learning how to use browser developers window for css changes

                  T 1 Reply Last reply Oct 7, 2021, 9:53 PM Reply Quote 0
                  • T Offline
                    tonkxy @sdetweil
                    last edited by Oct 7, 2021, 9:53 PM

                    @sdetweil when you say stop you mean in my debug to see where im losing the value?

                    S 1 Reply Last reply Oct 7, 2021, 10:20 PM Reply Quote 0
                    • S Offline
                      sdetweil @tonkxy
                      last edited by Oct 7, 2021, 10:20 PM

                      @tonkxy correct

                      Sam

                      How to add modules

                      learning how to use browser developers window for css changes

                      T 1 Reply Last reply Oct 7, 2021, 10:55 PM Reply Quote 1
                      • 1
                      • 2
                      • 1 / 2
                      1 / 2
                      • First post
                        9/16
                        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