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.

    Can I round Precipitation Units

    Scheduled Pinned Locked Moved Solved Troubleshooting
    5 Posts 4 Posters 1.1k Views 5 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.
    • A Offline
      amarko87
      last edited by

      Hey all,

      Just curious if I’m able to round the showPrecipitationAmount units like I can with Temp units. I feel like there’s a way, but without a specific line in the documentation I didn’t want to start poking around since I know so little about coding in general. I’m a woodworker so this is all pretty new to me.

      Thanks

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

        I figured it out. I wanted to round it off too. No decimal places.
        You have to edit the template files. look for the showPrecipitationAmount if statement. I altered the output a little bit… see below for what I did.

        in forecast.njk

                        {% if config.showPrecipitationAmount %}
                            {% if f.precipitationUnits %}
                                <td class="align-right bright precipitation">
                                    {{ f.precipitation }}{{ f.precipitationUnits }}
                                </td>
        		                {% else %}
                                {% if f.pop %}
                                    <td class="align-right precipitation">
                                        {{(f.pop * 100).toFixed(0)}}%
                                    </td>
                                {% endif %}
                                <td class="align-right bright precipitation">
                                    {{ f.precipitation | unit("precip") }}
                                </td>
                            {% endif %}
                        {% endif %}
        

        I found info on the templates by googling nunchucks templates.

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

          @amarko87 what module are you talking about ?

          Sam

          How to add modules

          learning how to use browser developers window for css changes

          A 1 Reply Last reply Reply Quote 0
          • A Offline
            amarko87 @sdetweil
            last edited by

            @sdetweil I probably should’ve mentioned that in the post. Just the default Weather module.

            crazylegsC 1 Reply Last reply Reply Quote 0
            • crazylegsC Offline
              crazylegs @amarko87
              last edited by

              @amarko87 There’s currently no option to round precipitation amount in the default Weather module, although I think this should be possible. I’m just curious:

              • Which weather provider are you using?

              • Are you looking for rounding in the ‘forecast’ and/or ‘hourly’ feature of the Weather module?

              1 Reply Last reply Reply Quote 0
              • kayakbabeK Offline
                kayakbabe
                last edited by kayakbabe

                I figured it out. I wanted to round it off too. No decimal places.
                You have to edit the template files. look for the showPrecipitationAmount if statement. I altered the output a little bit… see below for what I did.

                in forecast.njk

                                {% if config.showPrecipitationAmount %}
                                    {% if f.precipitationUnits %}
                                        <td class="align-right bright precipitation">
                                            {{ f.precipitation }}{{ f.precipitationUnits }}
                                        </td>
                		                {% else %}
                                        {% if f.pop %}
                                            <td class="align-right precipitation">
                                                {{(f.pop * 100).toFixed(0)}}%
                                            </td>
                                        {% endif %}
                                        <td class="align-right bright precipitation">
                                            {{ f.precipitation | unit("precip") }}
                                        </td>
                                    {% endif %}
                                {% endif %}
                

                I found info on the templates by googling nunchucks templates.

                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