MagicMirror Forum

    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unsolved
    • Solved
    • MagicMirror² Repository
    • Documentation
    • Donate
    • Discord

    MMM-BM-OW when 'no rain' for forecast undefined message received.

    Troubleshooting
    3
    14
    436
    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
      scumbelly last edited by

      Hi,
      I added + forecast.daily[0].rain + “/mm Rain” to the MMM-BM-OW module and if there is rain the amount is returned. If there is no rain I receive “undefined”. I would like to show " 0 " (zero) or at least something, but I haven’t been able to as yet figure out how to do it. Anyone have some pointers?

      Cheers.

      cowboysdude 1 Reply Last reply Reply Quote 0
      • cowboysdude
        cowboysdude Module Developer @scumbelly last edited by

        @scumbelly said in MMM-BM-OW when 'no rain' for forecast undefined message received.:

        MMM-BM-OW

        I can take a look at it if you’d like.

        1 Reply Last reply Reply Quote 0
        • S
          scumbelly last edited by

          Sure, thanks.

          I tried a bunch of things and was just thinking about “null” being returned and how to handle it. If rain worked completely then I could try snow and that would cover everything ( I think) I’d want the module to do.

          Mykle1 1 Reply Last reply Reply Quote 0
          • Mykle1
            Mykle1 Project Sponsor Module Developer @scumbelly last edited by

            @scumbelly

            Just to be clear, the module works but not after you modified it?

            Create a working config
            How to add modules

            1 Reply Last reply Reply Quote 0
            • S
              scumbelly last edited by

              Hi,

              The module works just fine. It’s only when you do not receive a forecasted rain amount . So if Tuesday has 2 returned ( for mm of rain) and Wednesday has no rain then Wednesday displays undefined as a value.

              The code is …

              moment.unix(forecast.daily[X].sunrise).local().format(‘ddd’) + " &nbsp" + “<img class = image src=./modules/MMM-BMW-OW/icons/” + forecast.daily[X].weather[0].main + “.png>” + " &nbsp" + Math.round(forecast.daily[X].temp.max) + “/” + Math.round(forecast.daily[X].temp.min) + " &nbsp &nbsp &nbsp &nbsp &nbsp" + forecast.daily[X].rain + “/mm Rain” + “&nbsp &nbsp &nbsp &nbsp &nbsp”+ until 6 terminates with no + but with ;

              Hope that helps.

              is 0 to 6.

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

                That check mark is supposed to be X for 0 to 6.

                1 Reply Last reply Reply Quote 0
                • S
                  scumbelly last edited by

                  Hi,

                  I changed the string a bit. I added Math.round to forecast.daily[X].rain + “/mm Rain”

                  Math.round (forecast.daily[X].rain) + “/mm Rain”

                  and instead of undefind/mm Rain I now receive NaN/mm Rain.

                  Cool.

                  cowboysdude 1 Reply Last reply Reply Quote 0
                  • cowboysdude
                    cowboysdude Module Developer @scumbelly last edited by cowboysdude

                    @scumbelly this needs some css help but… is this what you’re after?
                    Capture.PNG

                    S 1 Reply Last reply Reply Quote 1
                    • S
                      scumbelly @cowboysdude last edited by

                      @cowboysdude

                      Exceptional. That’s it! What’s the solution? I started to go down an isNAN() rabbit hole but as yet haven’t been successful.

                      Great job.

                      cowboysdude 1 Reply Last reply Reply Quote 0
                      • cowboysdude
                        cowboysdude Module Developer @scumbelly last edited by

                        @scumbelly It takes rewriting parts of the entire module to make it work…

                        Mykle1 1 Reply Last reply Reply Quote 0
                        • 1
                        • 2
                        • 1 / 2
                        • First post
                          Last post
                        Enjoying MagicMirror? Please consider a donation!
                        MagicMirror created by Michael Teeuw.
                        Forum managed by Paul-Vincent Roll and Rodrigo Ramírez Norambuena.
                        This forum is using NodeBB as its core | Contributors
                        Contact | Privacy Policy