Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Node-Red
    5. Function Node , Variable auf 2 Stellen runden

    NEWS

    • ioBroker@Smart Living Forum Solingen, 14.06. - Agenda added

    • ioBroker goes Matter ... Matter Adapter in Stable

    • Monatsrückblick - April 2025

    Function Node , Variable auf 2 Stellen runden

    This topic has been deleted. Only users with topic management privileges can see it.
    • S
      spok last edited by

      Weis jemand wie das Ergebnis der Variablen f_zaehler vor der Ausgabe auf 2 Stellen hinter Komma gerundet werden kann?

      var f_zaehler = flow.get('f_zaehler') || 0;
      f_zaehler = f_zaehler * 10.2/36.7347*3600/1000;
      msg.payload = f_zaehler;
      return msg;

      mickym 1 Reply Last reply Reply Quote 0
      • mickym
        mickym Most Active @spok last edited by

        @spok

        
        msg.payload = Math.round(f_zaehler*100)/100;
        
        
        S 2 Replies Last reply Reply Quote 0
        • S
          spok @mickym last edited by

          @mickym Danke!

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

            @mickym aber er zeigt keine Kommastellen an.

            mickym 1 Reply Last reply Reply Quote 0
            • mickym
              mickym Most Active @spok last edited by

              @spok Versteh ich nicht - Zeigt doch Komma Stellen an:

              30115a91-f611-4f44-b73c-306f4ac551ce-image.png

              oder meinst Du - Du willst in jedem Fall keine Zahl sondern formatiert 2 Kommastellen haben?

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

                @mickym ja hat sich erledigt ! Danke!

                mickym 1 Reply Last reply Reply Quote 0
                • mickym
                  mickym Most Active @spok last edited by

                  @spok sagte in Function Node , Variable auf 2 Stellen runden:

                  @mickym ja hat sich erledigt ! Danke!

                  Verstehe ich zwar gerade nicht, wenn Du als String unbedingt 2 Nachkommastellen haben willst, dann nutze toFixed(2)

                  2d7a3f51-77fb-4125-b57e-3cbeaa8e2bbd-image.png

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

                    @mickym ok . (Kenne mich nur wenig aus)

                    1 Reply Last reply Reply Quote 0
                    • mickym
                      mickym Most Active last edited by

                      Und wenn Du für solche einfachen Berechnungen keinen JS Code schreiben möchtest, dann nimmst Du eine Change Node. 😉

                      2da67466-c9ea-423c-890d-1553f2fe9e08-image.png

                      948811dc-ef90-47b9-8f89-181d2d8b3ac1-image.png

                      $round($exists($flowContext('f_zaehler')) ? $flowContext('f_zaehler') * 10.2/36.7347*3600/1000 : 0,2)
                      
                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post

                      Support us

                      ioBroker
                      Community Adapters
                      Donate

                      1.1k
                      Online

                      31.7k
                      Users

                      79.7k
                      Topics

                      1.3m
                      Posts

                      2
                      9
                      8844
                      Loading More Posts
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes
                      Reply
                      • Reply as topic
                      Log in to reply
                      Community
                      Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen
                      The ioBroker Community 2014-2023
                      logo