Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. Summe/differenz berechnen +/-

    NEWS

    • Wir empfehlen: Node.js 22.x

    • Neuer Blog: Fotos und Eindrücke aus Solingen

    • ioBroker goes Matter ... Matter Adapter in Stable

    Summe/differenz berechnen +/-

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

      Hallo,

      ich würde gerne die Summe bzw. die Differenz von mehr als 2 DP berechnen. Habe es gerade mit 2 DP probiert, aber er rechnet da nicht:

      hab ich da einen Gedanken Fehler noch? und wie bekomme ich mehr als 2DP zum berechnen rein? Gibts da auch eine Funktion?

      Bildschirmfoto 2024-01-10 um 09.42.34.png Bildschirmfoto 2024-01-10 um 09.42.50.png Bildschirmfoto 2024-01-10 um 09.43.15.png Bildschirmfoto 2024-01-10 um 09.43.22.png

      <xml xmlns="https://developers.google.com/blockly/xml">
        <variables>
          <variable id="Cd+*b$:me4#bwh{Dnt4Z">gestern</variable>
        </variables>
        <block type="schedule" id="Q6=3Vy}02DbNJ`*:8umP" x="63" y="163">
          <field name="SCHEDULE">*/60 * * * * *</field>
          <statement name="STATEMENT">
            <block type="variables_set" id="#7G|_Fo?,?cFbc#p..w@">
              <field name="VAR" id="Cd+*b$:me4#bwh{Dnt4Z">gestern</field>
              <value name="VALUE">
                <block type="math_arithmetic" id="bL0:_SCnfTFom`qx#dm5">
                  <field name="OP">ADD</field>
                  <value name="A">
                    <shadow type="math_number" id="lEHSJu]e{OzGn^}fBI4z">
                      <field name="NUM">1</field>
                    </shadow>
                    <block type="get_value" id="oL=AfT7A3uu`m9CuL.+s">
                      <field name="ATTR">val</field>
                      <field name="OID">0_userdata.0.Aktien.1.Aktie_01_Differenz</field>
                    </block>
                  </value>
                  <value name="B">
                    <shadow type="math_number" id="%b))?+PyGkJrMlkIRp):">
                      <field name="NUM">1</field>
                    </shadow>
                    <block type="get_value" id="BawPx9dMMPOi[U7]g/u`">
                      <field name="ATTR">val</field>
                      <field name="OID">0_userdata.0.Aktien.2.Aktie_02_Differenz</field>
                    </block>
                  </value>
                </block>
              </value>
              <next>
                <block type="update" id="xX6VFF6~4RO?mDh)ez;3">
                  <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                  <field name="OID">0_userdata.0.gesamtgesternaktie</field>
                  <field name="WITH_DELAY">FALSE</field>
                  <value name="VALUE">
                    <block type="variables_get" id="GTB8*50S*]K5BqsQ6W{R">
                      <field name="VAR" id="Cd+*b$:me4#bwh{Dnt4Z">gestern</field>
                    </block>
                  </value>
                </block>
              </next>
            </block>
          </statement>
        </block>
      </xml>
      
      Meister Mopper haus-automatisierung 2 Replies Last reply Reply Quote 0
      • Meister Mopper
        Meister Mopper @Olli_M last edited by

        @olli_m

        Welchen Datentyp haben die 2 DP? Wenn es nicht number ist, wird es nichts mit dem Berechnen.

        1 Reply Last reply Reply Quote 0
        • haus-automatisierung
          haus-automatisierung Developer Most Active @Olli_M last edited by

          @olli_m Scheinbar sind deine Datenpunkte vom Typ "Zeichenkette" (string). Das solltest Du auf "Zahl" (number) ändern.

          Ansonsten kannst Du auch "nach Zahl" aus den Konvertierungsfunktionen dazwischen packen (vor beide "Wert vom Objekt ID..."). Aber das ist ein unschöner Workaround.

          1 Reply Last reply Reply Quote 0
          • Olli_M
            Olli_M last edited by Olli_M

            @haus-automatisierung
            @Meister-Mopper

            Ja habe ich jetzt auch gemacht, aber das blockly schickt immer noch einen string los:

            2024-01-10 09:55:00.003	warn	You are assigning a string to the state "0_userdata.0.gesamtgesternaktie" which expects a number. Please fix your code to use a number or change the state type to string. This warning might become an error in future versions.
            

            und an sich habe ich noch mehrere DP als die zwei, wie bekommt man das im Blockly hin?

            Er meckert auch im JS:

            10.1.2024, 09:53:00.004	[warn ]: javascript.0 (190)     at Object.<anonymous> (script.js.common.Wohnzimmer.AktienWerteBilanz:6:3)
            10.1.2024, 09:53:58.564	[info ]: javascript.0 (190) Stop script script.js.common.Wohnzimmer.AktienWerteBilanz
            10.1.2024, 09:53:58.610	[info ]: javascript.0 (190) Start javascript script.js.common.Wohnzimmer.AktienWerteBilanz
            10.1.2024, 09:53:58.612	[info ]: javascript.0 (190) script.js.common.Wohnzimmer.AktienWerteBilanz: registered 0 subscriptions, 1 schedule, 0 messages, 0 logs and 0 file subscriptions
            10.1.2024, 09:54:00.003	[warn ]: javascript.0 (190)     at Object.<anonymous> (script.js.common.Wohnzimmer.AktienWerteBilanz:6:3)
            10.1.2024, 09:54:04.401	[info ]: javascript.0 (190) Stop script script.js.common.Wohnzimmer.AktienWerteBilanz
            10.1.2024, 09:54:31.598	[info ]: javascript.0 (190) Start javascript script.js.common.Wohnzimmer.AktienWerteBilanz
            10.1.2024, 09:54:31.601	[info ]: javascript.0 (190) script.js.common.Wohnzimmer.AktienWerteBilanz: registered 0 subscriptions, 1 schedule, 0 messages, 0 logs and 0 file subscriptions
            10.1.2024, 09:54:33.501	[info ]: javascript.0 (190) Stop script script.js.common.Wohnzimmer.AktienWerteBilanz
            10.1.2024, 09:54:34.249	[info ]: javascript.0 (190) Start javascript script.js.common.Wohnzimmer.AktienWerteBilanz
            10.1.2024, 09:54:34.253	[info ]: javascript.0 (190) script.js.common.Wohnzimmer.AktienWerteBilanz: registered 0 subscriptions, 1 schedule, 0 messages, 0 logs and 0 file subscriptions
            10.1.2024, 09:55:00.003	[warn ]: javascript.0 (190)     at Object.<anonymous> (script.js.common.Wohnzimmer.AktienWerteBilanz:6:3)
            10.1.2024, 09:56:00.004	[warn ]: javascript.0 (190)     at Object.<anonymous> (script.js.common.Wohnzimmer.AktienWerteBilanz:6:3)
            

            Bildschirmfoto 2024-01-10 um 09.57.31.png

            Meister Mopper 1 Reply Last reply Reply Quote 0
            • Meister Mopper
              Meister Mopper @Olli_M last edited by

              @olli_m sagte in Summe/differenz berechnen +/-:

              wie bekommt man das im Blockly hin?

              Muss konvertiert werden:

              889eb8fc-0015-4dc1-bb49-4333658661a9-grafik.png

              Olli_M 1 Reply Last reply Reply Quote 0
              • Olli_M
                Olli_M @Meister Mopper last edited by

                @meister-mopper

                sieht gut aus 🙂

                Wie mache ich das jetzt am einfachsten hab so 15 DP die ich da berechnen mag....

                haus-automatisierung 1 Reply Last reply Reply Quote 0
                • haus-automatisierung
                  haus-automatisierung Developer Most Active @Olli_M last edited by

                  @olli_m Alle auf den richtigen Datentyp (number) stellen und dann kannst Du z.B. mit dem $-Selektor über alle Datenpunkte gehen und diese dann in einer Schleife addieren.

                  "nach Zahl" braucht man eigentlich nie, wenn die Datentypen überall stimmen.

                  Olli_M 1 Reply Last reply Reply Quote 0
                  • Olli_M
                    Olli_M @haus-automatisierung last edited by

                    @haus-automatisierung
                    okay probier ich mal aus... danke Euch zwei

                    1 Reply Last reply Reply Quote 0
                    • Olli_M
                      Olli_M last edited by

                      @haus-automatisierung

                      Also ich muss ja erst ne Function anlegen und die DP dann reinziehen und dann zusätzlich den DP auch noch ändern oder?

                      Bildschirmfoto 2024-01-10 um 21.44.03.png Bildschirmfoto 2024-01-10 um 21.44.30.png

                      nur was muss ich dann hier reinschreiben?

                      Bildschirmfoto 2024-01-10 um 21.46.46.png

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post

                      Support us

                      ioBroker
                      Community Adapters
                      Donate

                      633
                      Online

                      32.0k
                      Users

                      80.4k
                      Topics

                      1.3m
                      Posts

                      3
                      9
                      278
                      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