Skip to content
  • Home
  • Aktuell
  • Tags
  • 0 Ungelesen 0
  • Kategorien
  • Unreplied
  • Beliebt
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Standard: (Kein Skin)
  • Kein Skin
Einklappen
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Deutsch
  3. Skripten / Logik
  4. Blockly
  5. JS-Funktion mit Ergebnis: getObject() ohne Funktion

NEWS

  • Jahresrückblick 2025 – unser neuer Blogbeitrag ist online! ✨
    BluefoxB
    Bluefox
    16
    1
    1.1k

  • Neuer Blogbeitrag: Monatsrückblick - Dezember 2025 🎄
    BluefoxB
    Bluefox
    13
    1
    703

  • Weihnachtsangebot 2025! 🎄
    BluefoxB
    Bluefox
    25
    1
    2.0k

JS-Funktion mit Ergebnis: getObject() ohne Funktion

Geplant Angeheftet Gesperrt Verschoben Blockly
4 Beiträge 3 Kommentatoren 324 Aufrufe 3 Watching
  • Älteste zuerst
  • Neuste zuerst
  • Meiste Stimmen
Antworten
  • In einem neuen Thema antworten
Anmelden zum Antworten
Dieses Thema wurde gelöscht. Nur Nutzer mit entsprechenden Rechten können es sehen.
  • N Offline
    N Offline
    Nas007
    schrieb am zuletzt editiert von
    #1

    Hallo,

    ich versuche gerade den Namen eines Objektes vom Pingadapter zu extrahieren. Ich habe meine Blöcke mal angehängt. Grundsätzlich funktioniert es objekte mit der Funktion "VPN" zu finden durch den Block "IDs vom Selektor" und ich bekomme die Debug Ausgabe (grün markiert).
    b765ae52-1bb8-46be-adc0-5b57da8860f6-grafik.png
    Aber ich will auch den Namen bekommen. Darum habe ich (aus tutorials) die Funktion "JS-Funktion mit Ergebnis" eingesetzt. Diese enthält eine Variable "ObjectID" und der Inhalt der Funktion ist dann:

    return getObject(ObjectID).common.name;
    

    Und dort wird wohl das Problem liegen. Bei der Eingabe des Befahls wird mir nach .common. das name schon garnicht angebot.

    Aber beim Pingadapter gibt es den gewünschten Wert:
    ab1537d0-4276-4e2e-b292-5774675ba9d6-grafik.png

    Woran liegt das?
    Vielen Dank schon mal!

    <xml xmlns="https://developers.google.com/blockly/xml">
      <variables>
        <variable id="!XoK2X3%QK4onFM)wEfP">ObjectID</variable>
        <variable id="=-iCY8uX8Qrj8pW.D:On">VPN_Anzahl_aktiv</variable>
        <variable id="gg0N.q[bRjq%]`9=Z%Q-">VPN_Anzahl_inaktiv</variable>
        <variable id="!-C1G,Bt?w:QXfuK+JNF">VPN_id</variable>
        <variable id="z2tXOU!,`e.Tvs40S(2*">VPN_Namen</variable>
      </variables>
      <block type="on_ext" id="t^gV}/pCuT7|mxFw3Oa-" x="588" y="-712">
        <mutation xmlns="http://www.w3.org/1999/xhtml" items="1"></mutation>
        <field name="CONDITION">ne</field>
        <field name="ACK_CONDITION"></field>
        <value name="OID0">
          <shadow type="field_oid" id="]iFkFJcoVRQ4yYIY4=l|">
            <field name="oid">default</field>
          </shadow>
          <block type="selector" id="P_L%n8K[8SgkZ]^(KFh0">
            <field name="TEXT">state[id=*](functions=vpn)</field>
          </block>
        </value>
        <statement name="STATEMENT">
          <block type="variables_set" id="jA]jmQ$;;v,q-6koRHSg">
            <field name="VAR" id="=-iCY8uX8Qrj8pW.D:On">VPN_Anzahl_aktiv</field>
            <value name="VALUE">
              <block type="math_number" id="G|8nzNU?!a}!(-5IkX8d">
                <field name="NUM">0</field>
              </block>
            </value>
            <next>
              <block type="variables_set" id="_s+:Vs,7WT{b${+ha%DB">
                <field name="VAR" id="gg0N.q[bRjq%]`9=Z%Q-">VPN_Anzahl_inaktiv</field>
                <value name="VALUE">
                  <block type="math_number" id="%WYD(9O0UqT7:lEi]apy">
                    <field name="NUM">0</field>
                  </block>
                </value>
                <next>
                  <block type="controls_forEach" id="HKv{pDXA;Rz%/E5a;vwL">
                    <field name="VAR" id="!-C1G,Bt?w:QXfuK+JNF">VPN_id</field>
                    <value name="LIST">
                      <block type="selector" id="3;*XS;#ExXeLJqrFpLg]">
                        <field name="TEXT">state[id=*](functions=vpn)</field>
                      </block>
                    </value>
                    <statement name="DO">
                      <block type="controls_if" id="v$H.~?e/W=Z4oz4Ts6ix">
                        <mutation else="1"></mutation>
                        <value name="IF0">
                          <block type="logic_compare" id="DnwgQ^Gq#wfShZ0j2Nik">
                            <field name="OP">EQ</field>
                            <value name="A">
                              <block type="get_value_var" id="~-E[Y^v48!1U5xM!bl41">
                                <field name="ATTR">val</field>
                                <value name="OID">
                                  <shadow type="text">
                                    <field name="TEXT"></field>
                                  </shadow>
                                  <block type="variables_get" id="S$)@]U+%xUO_c)+@u$ie">
                                    <field name="VAR" id="!-C1G,Bt?w:QXfuK+JNF">VPN_id</field>
                                  </block>
                                </value>
                              </block>
                            </value>
                            <value name="B">
                              <block type="logic_boolean" id="u}qaC6,U_H=Wbj:)ayzY">
                                <field name="BOOL">TRUE</field>
                              </block>
                            </value>
                          </block>
                        </value>
                        <statement name="DO0">
                          <block type="math_change" id="}E1`to(eG`fNTM];1Xr.">
                            <field name="VAR" id="=-iCY8uX8Qrj8pW.D:On">VPN_Anzahl_aktiv</field>
                            <value name="DELTA">
                              <shadow type="math_number" id=";A55*ZS8j).HVLU[CCL^">
                                <field name="NUM">1</field>
                              </shadow>
                              <block type="math_number" id="t|p_4.JJLX/(BRo;Ohl8">
                                <field name="NUM">1</field>
                              </block>
                            </value>
                          </block>
                        </statement>
                        <statement name="ELSE">
                          <block type="math_change" id="L}@B-@1D6ET6c^#I6_Bl">
                            <field name="VAR" id="gg0N.q[bRjq%]`9=Z%Q-">VPN_Anzahl_inaktiv</field>
                            <value name="DELTA">
                              <shadow type="math_number" id="ANyO0JgW2X#AdnJOE/_@">
                                <field name="NUM">1</field>
                              </shadow>
                              <block type="math_number" id="?Bj~$k._*1$zwONi%|8h">
                                <field name="NUM">1</field>
                              </block>
                            </value>
                          </block>
                        </statement>
                      </block>
                    </statement>
                    <next>
                      <block type="controls_if" id="CVvFXN}*;_si4o(h%L6}">
                        <value name="IF0">
                          <block type="logic_compare" id="Z/F34fHZf]uMAWJmn.?%">
                            <field name="OP">NEQ</field>
                            <value name="A">
                              <block type="variables_get" id=")[ycF^4.{vo!dA5r=MAO">
                                <field name="VAR" id="=-iCY8uX8Qrj8pW.D:On">VPN_Anzahl_aktiv</field>
                              </block>
                            </value>
                            <value name="B">
                              <block type="math_number" id="W4_+PXD*^kQM-x1KR[?`">
                                <field name="NUM">0</field>
                              </block>
                            </value>
                          </block>
                        </value>
                        <statement name="DO0">
                          <block type="debug" id="Dr%rHk4y}.$Y{T8;DK5L">
                            <field name="Severity">warn</field>
                            <value name="TEXT">
                              <shadow type="text" id="9i@n/cb*J0dnE!}3}Z20">
                                <field name="TEXT">VPN aktiv</field>
                              </shadow>
                            </value>
                          </block>
                        </statement>
                        <next>
                          <block type="debug" id="Mu!,tzLL0-=1yq7LZ4FL">
                            <field name="Severity">warn</field>
                            <value name="TEXT">
                              <shadow type="text" id="uI2$9^3#AOim[!|!p(ze">
                                <field name="TEXT">Wert ist wahr.</field>
                              </shadow>
                              <block type="variables_get" id="UcNF=y58Ht2D;.o)8RM_">
                                <field name="VAR" id="=-iCY8uX8Qrj8pW.D:On">VPN_Anzahl_aktiv</field>
                              </block>
                            </value>
                            <next>
                              <block type="debug" id=",Z@6|;?$(BF3gzmhGpTE">
                                <field name="Severity">warn</field>
                                <value name="TEXT">
                                  <shadow type="text" id="8Ri)5yLq}6miI*!HoUqC">
                                    <field name="TEXT">Wert ist wahr.</field>
                                  </shadow>
                                  <block type="variables_get" id="?SUp_K%H0Cif=qtoeWcJ">
                                    <field name="VAR" id="gg0N.q[bRjq%]`9=Z%Q-">VPN_Anzahl_inaktiv</field>
                                  </block>
                                </value>
                                <next>
                                  <block type="controls_forEach" id="NrPng5r(ITe9[ljFbLuE">
                                    <field name="VAR" id="!-C1G,Bt?w:QXfuK+JNF">VPN_id</field>
                                    <value name="LIST">
                                      <block type="selector" id="O32R/F,?h3oKKiS7gB;i">
                                        <field name="TEXT">state[id=*](functions=vpn)</field>
                                      </block>
                                    </value>
                                    <statement name="DO">
                                      <block type="controls_if" id=";beU)@zJ6EigQVn_QC{p">
                                        <mutation else="1"></mutation>
                                        <value name="IF0">
                                          <block type="logic_compare" id="0m1JpI|W~ui_tq+(O2FC">
                                            <field name="OP">EQ</field>
                                            <value name="A">
                                              <block type="get_value_var" id="@@B^=?6:JfU}]u7v0dz/">
                                                <field name="ATTR">val</field>
                                                <value name="OID">
                                                  <shadow type="text">
                                                    <field name="TEXT"></field>
                                                  </shadow>
                                                  <block type="variables_get" id="igJF8Jhn*a1UX!SqzgZ%">
                                                    <field name="VAR" id="!-C1G,Bt?w:QXfuK+JNF">VPN_id</field>
                                                  </block>
                                                </value>
                                              </block>
                                            </value>
                                            <value name="B">
                                              <block type="logic_boolean" id="[ROfv3pA%WEW/[)lr#p}">
                                                <field name="BOOL">TRUE</field>
                                              </block>
                                            </value>
                                          </block>
                                        </value>
                                        <statement name="DO0">
                                          <block type="debug" id="$_eK`mj{^`S[HW(eN;*|">
                                            <field name="Severity">warn</field>
                                            <value name="TEXT">
                                              <shadow type="text" id="0StGrBs^4oWHycJ17t*1">
                                                <field name="TEXT">Wert ist wahr.</field>
                                              </shadow>
                                            </value>
                                            <next>
                                              <block type="debug" id="#$Y.1dHd_PE%;xJzupeM">
                                                <field name="Severity">debug</field>
                                                <value name="TEXT">
                                                  <shadow type="text" id="_ngDm8^)M_DudPg%TlRd">
                                                    <field name="TEXT">Wert ist wahr.</field>
                                                  </shadow>
                                                  <block type="procedures_callcustomreturn" id="O`7e2u+7h+sPmPk;$KOL">
                                                    <mutation name="etwas tun">
                                                      <arg name="ObjectID"></arg>
                                                    </mutation>
                                                    <value name="ARG0">
                                                      <block type="variables_get" id="?]9aV@EwT(LizcR!z%0U">
                                                        <field name="VAR" id="!-C1G,Bt?w:QXfuK+JNF">VPN_id</field>
                                                      </block>
                                                    </value>
                                                  </block>
                                                </value>
                                                <next>
                                                  <block type="variables_set" id="*}v}R$9qPggi%$yJXNeB">
                                                    <field name="VAR" id="z2tXOU!,`e.Tvs40S(2*">VPN_Namen</field>
                                                    <value name="VALUE">
                                                      <block type="procedures_callcustomreturn" id="j|VQN(1}XPcDaJk[Zae6">
                                                        <mutation name="etwas tun">
                                                          <arg name="ObjectID"></arg>
                                                        </mutation>
                                                        <value name="ARG0">
                                                          <block type="variables_get" id="?2Y(i;(|lekpGLZTh@Dr">
                                                            <field name="VAR" id="!-C1G,Bt?w:QXfuK+JNF">VPN_id</field>
                                                          </block>
                                                        </value>
                                                      </block>
                                                    </value>
                                                    <next>
                                                      <block type="debug" id="?NKb,F`W=c1B_q.j$EQc">
                                                        <field name="Severity">debug</field>
                                                        <value name="TEXT">
                                                          <shadow type="text" id="[MR#*oXE?!}?O-zS4(zJ">
                                                            <field name="TEXT">Wert ist wahr.</field>
                                                          </shadow>
                                                          <block type="variables_get" id="@~.)U#SEueoR;^]9,%Zm">
                                                            <field name="VAR" id="z2tXOU!,`e.Tvs40S(2*">VPN_Namen</field>
                                                          </block>
                                                        </value>
                                                      </block>
                                                    </next>
                                                  </block>
                                                </next>
                                              </block>
                                            </next>
                                          </block>
                                        </statement>
                                        <statement name="ELSE">
                                          <block type="debug" id="K^tzcunaFD75;y#APe6O">
                                            <field name="Severity">warn</field>
                                            <value name="TEXT">
                                              <shadow type="text" id="?M%CVVpR5,qk6S}OnNUg">
                                                <field name="TEXT">Wert ist nicht wahr.</field>
                                              </shadow>
                                            </value>
                                          </block>
                                        </statement>
                                      </block>
                                    </statement>
                                  </block>
                                </next>
                              </block>
                            </next>
                          </block>
                        </next>
                      </block>
                    </next>
                  </block>
                </next>
              </block>
            </next>
          </block>
        </statement>
      </block>
      <block type="procedures_defcustomreturn" id="@;-)7/5`2tfNSW6FR)HB" x="1188" y="-62">
        <mutation statements="false">
          <arg name="ObjectID" varid="!XoK2X3%QK4onFM)wEfP"></arg>
        </mutation>
        <field name="NAME">etwas tun</field>
        <field name="SCRIPT">cmV0dXJuIGdldE9iamVjdChPYmplY3RJRCkuY29tbW9uLm5hbWU7</field>
        <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
      </block>
    </xml>
    
    SchmakusS CodierknechtC 2 Antworten Letzte Antwort
    0
    • N Nas007

      Hallo,

      ich versuche gerade den Namen eines Objektes vom Pingadapter zu extrahieren. Ich habe meine Blöcke mal angehängt. Grundsätzlich funktioniert es objekte mit der Funktion "VPN" zu finden durch den Block "IDs vom Selektor" und ich bekomme die Debug Ausgabe (grün markiert).
      b765ae52-1bb8-46be-adc0-5b57da8860f6-grafik.png
      Aber ich will auch den Namen bekommen. Darum habe ich (aus tutorials) die Funktion "JS-Funktion mit Ergebnis" eingesetzt. Diese enthält eine Variable "ObjectID" und der Inhalt der Funktion ist dann:

      return getObject(ObjectID).common.name;
      

      Und dort wird wohl das Problem liegen. Bei der Eingabe des Befahls wird mir nach .common. das name schon garnicht angebot.

      Aber beim Pingadapter gibt es den gewünschten Wert:
      ab1537d0-4276-4e2e-b292-5774675ba9d6-grafik.png

      Woran liegt das?
      Vielen Dank schon mal!

      <xml xmlns="https://developers.google.com/blockly/xml">
        <variables>
          <variable id="!XoK2X3%QK4onFM)wEfP">ObjectID</variable>
          <variable id="=-iCY8uX8Qrj8pW.D:On">VPN_Anzahl_aktiv</variable>
          <variable id="gg0N.q[bRjq%]`9=Z%Q-">VPN_Anzahl_inaktiv</variable>
          <variable id="!-C1G,Bt?w:QXfuK+JNF">VPN_id</variable>
          <variable id="z2tXOU!,`e.Tvs40S(2*">VPN_Namen</variable>
        </variables>
        <block type="on_ext" id="t^gV}/pCuT7|mxFw3Oa-" x="588" y="-712">
          <mutation xmlns="http://www.w3.org/1999/xhtml" items="1"></mutation>
          <field name="CONDITION">ne</field>
          <field name="ACK_CONDITION"></field>
          <value name="OID0">
            <shadow type="field_oid" id="]iFkFJcoVRQ4yYIY4=l|">
              <field name="oid">default</field>
            </shadow>
            <block type="selector" id="P_L%n8K[8SgkZ]^(KFh0">
              <field name="TEXT">state[id=*](functions=vpn)</field>
            </block>
          </value>
          <statement name="STATEMENT">
            <block type="variables_set" id="jA]jmQ$;;v,q-6koRHSg">
              <field name="VAR" id="=-iCY8uX8Qrj8pW.D:On">VPN_Anzahl_aktiv</field>
              <value name="VALUE">
                <block type="math_number" id="G|8nzNU?!a}!(-5IkX8d">
                  <field name="NUM">0</field>
                </block>
              </value>
              <next>
                <block type="variables_set" id="_s+:Vs,7WT{b${+ha%DB">
                  <field name="VAR" id="gg0N.q[bRjq%]`9=Z%Q-">VPN_Anzahl_inaktiv</field>
                  <value name="VALUE">
                    <block type="math_number" id="%WYD(9O0UqT7:lEi]apy">
                      <field name="NUM">0</field>
                    </block>
                  </value>
                  <next>
                    <block type="controls_forEach" id="HKv{pDXA;Rz%/E5a;vwL">
                      <field name="VAR" id="!-C1G,Bt?w:QXfuK+JNF">VPN_id</field>
                      <value name="LIST">
                        <block type="selector" id="3;*XS;#ExXeLJqrFpLg]">
                          <field name="TEXT">state[id=*](functions=vpn)</field>
                        </block>
                      </value>
                      <statement name="DO">
                        <block type="controls_if" id="v$H.~?e/W=Z4oz4Ts6ix">
                          <mutation else="1"></mutation>
                          <value name="IF0">
                            <block type="logic_compare" id="DnwgQ^Gq#wfShZ0j2Nik">
                              <field name="OP">EQ</field>
                              <value name="A">
                                <block type="get_value_var" id="~-E[Y^v48!1U5xM!bl41">
                                  <field name="ATTR">val</field>
                                  <value name="OID">
                                    <shadow type="text">
                                      <field name="TEXT"></field>
                                    </shadow>
                                    <block type="variables_get" id="S$)@]U+%xUO_c)+@u$ie">
                                      <field name="VAR" id="!-C1G,Bt?w:QXfuK+JNF">VPN_id</field>
                                    </block>
                                  </value>
                                </block>
                              </value>
                              <value name="B">
                                <block type="logic_boolean" id="u}qaC6,U_H=Wbj:)ayzY">
                                  <field name="BOOL">TRUE</field>
                                </block>
                              </value>
                            </block>
                          </value>
                          <statement name="DO0">
                            <block type="math_change" id="}E1`to(eG`fNTM];1Xr.">
                              <field name="VAR" id="=-iCY8uX8Qrj8pW.D:On">VPN_Anzahl_aktiv</field>
                              <value name="DELTA">
                                <shadow type="math_number" id=";A55*ZS8j).HVLU[CCL^">
                                  <field name="NUM">1</field>
                                </shadow>
                                <block type="math_number" id="t|p_4.JJLX/(BRo;Ohl8">
                                  <field name="NUM">1</field>
                                </block>
                              </value>
                            </block>
                          </statement>
                          <statement name="ELSE">
                            <block type="math_change" id="L}@B-@1D6ET6c^#I6_Bl">
                              <field name="VAR" id="gg0N.q[bRjq%]`9=Z%Q-">VPN_Anzahl_inaktiv</field>
                              <value name="DELTA">
                                <shadow type="math_number" id="ANyO0JgW2X#AdnJOE/_@">
                                  <field name="NUM">1</field>
                                </shadow>
                                <block type="math_number" id="?Bj~$k._*1$zwONi%|8h">
                                  <field name="NUM">1</field>
                                </block>
                              </value>
                            </block>
                          </statement>
                        </block>
                      </statement>
                      <next>
                        <block type="controls_if" id="CVvFXN}*;_si4o(h%L6}">
                          <value name="IF0">
                            <block type="logic_compare" id="Z/F34fHZf]uMAWJmn.?%">
                              <field name="OP">NEQ</field>
                              <value name="A">
                                <block type="variables_get" id=")[ycF^4.{vo!dA5r=MAO">
                                  <field name="VAR" id="=-iCY8uX8Qrj8pW.D:On">VPN_Anzahl_aktiv</field>
                                </block>
                              </value>
                              <value name="B">
                                <block type="math_number" id="W4_+PXD*^kQM-x1KR[?`">
                                  <field name="NUM">0</field>
                                </block>
                              </value>
                            </block>
                          </value>
                          <statement name="DO0">
                            <block type="debug" id="Dr%rHk4y}.$Y{T8;DK5L">
                              <field name="Severity">warn</field>
                              <value name="TEXT">
                                <shadow type="text" id="9i@n/cb*J0dnE!}3}Z20">
                                  <field name="TEXT">VPN aktiv</field>
                                </shadow>
                              </value>
                            </block>
                          </statement>
                          <next>
                            <block type="debug" id="Mu!,tzLL0-=1yq7LZ4FL">
                              <field name="Severity">warn</field>
                              <value name="TEXT">
                                <shadow type="text" id="uI2$9^3#AOim[!|!p(ze">
                                  <field name="TEXT">Wert ist wahr.</field>
                                </shadow>
                                <block type="variables_get" id="UcNF=y58Ht2D;.o)8RM_">
                                  <field name="VAR" id="=-iCY8uX8Qrj8pW.D:On">VPN_Anzahl_aktiv</field>
                                </block>
                              </value>
                              <next>
                                <block type="debug" id=",Z@6|;?$(BF3gzmhGpTE">
                                  <field name="Severity">warn</field>
                                  <value name="TEXT">
                                    <shadow type="text" id="8Ri)5yLq}6miI*!HoUqC">
                                      <field name="TEXT">Wert ist wahr.</field>
                                    </shadow>
                                    <block type="variables_get" id="?SUp_K%H0Cif=qtoeWcJ">
                                      <field name="VAR" id="gg0N.q[bRjq%]`9=Z%Q-">VPN_Anzahl_inaktiv</field>
                                    </block>
                                  </value>
                                  <next>
                                    <block type="controls_forEach" id="NrPng5r(ITe9[ljFbLuE">
                                      <field name="VAR" id="!-C1G,Bt?w:QXfuK+JNF">VPN_id</field>
                                      <value name="LIST">
                                        <block type="selector" id="O32R/F,?h3oKKiS7gB;i">
                                          <field name="TEXT">state[id=*](functions=vpn)</field>
                                        </block>
                                      </value>
                                      <statement name="DO">
                                        <block type="controls_if" id=";beU)@zJ6EigQVn_QC{p">
                                          <mutation else="1"></mutation>
                                          <value name="IF0">
                                            <block type="logic_compare" id="0m1JpI|W~ui_tq+(O2FC">
                                              <field name="OP">EQ</field>
                                              <value name="A">
                                                <block type="get_value_var" id="@@B^=?6:JfU}]u7v0dz/">
                                                  <field name="ATTR">val</field>
                                                  <value name="OID">
                                                    <shadow type="text">
                                                      <field name="TEXT"></field>
                                                    </shadow>
                                                    <block type="variables_get" id="igJF8Jhn*a1UX!SqzgZ%">
                                                      <field name="VAR" id="!-C1G,Bt?w:QXfuK+JNF">VPN_id</field>
                                                    </block>
                                                  </value>
                                                </block>
                                              </value>
                                              <value name="B">
                                                <block type="logic_boolean" id="[ROfv3pA%WEW/[)lr#p}">
                                                  <field name="BOOL">TRUE</field>
                                                </block>
                                              </value>
                                            </block>
                                          </value>
                                          <statement name="DO0">
                                            <block type="debug" id="$_eK`mj{^`S[HW(eN;*|">
                                              <field name="Severity">warn</field>
                                              <value name="TEXT">
                                                <shadow type="text" id="0StGrBs^4oWHycJ17t*1">
                                                  <field name="TEXT">Wert ist wahr.</field>
                                                </shadow>
                                              </value>
                                              <next>
                                                <block type="debug" id="#$Y.1dHd_PE%;xJzupeM">
                                                  <field name="Severity">debug</field>
                                                  <value name="TEXT">
                                                    <shadow type="text" id="_ngDm8^)M_DudPg%TlRd">
                                                      <field name="TEXT">Wert ist wahr.</field>
                                                    </shadow>
                                                    <block type="procedures_callcustomreturn" id="O`7e2u+7h+sPmPk;$KOL">
                                                      <mutation name="etwas tun">
                                                        <arg name="ObjectID"></arg>
                                                      </mutation>
                                                      <value name="ARG0">
                                                        <block type="variables_get" id="?]9aV@EwT(LizcR!z%0U">
                                                          <field name="VAR" id="!-C1G,Bt?w:QXfuK+JNF">VPN_id</field>
                                                        </block>
                                                      </value>
                                                    </block>
                                                  </value>
                                                  <next>
                                                    <block type="variables_set" id="*}v}R$9qPggi%$yJXNeB">
                                                      <field name="VAR" id="z2tXOU!,`e.Tvs40S(2*">VPN_Namen</field>
                                                      <value name="VALUE">
                                                        <block type="procedures_callcustomreturn" id="j|VQN(1}XPcDaJk[Zae6">
                                                          <mutation name="etwas tun">
                                                            <arg name="ObjectID"></arg>
                                                          </mutation>
                                                          <value name="ARG0">
                                                            <block type="variables_get" id="?2Y(i;(|lekpGLZTh@Dr">
                                                              <field name="VAR" id="!-C1G,Bt?w:QXfuK+JNF">VPN_id</field>
                                                            </block>
                                                          </value>
                                                        </block>
                                                      </value>
                                                      <next>
                                                        <block type="debug" id="?NKb,F`W=c1B_q.j$EQc">
                                                          <field name="Severity">debug</field>
                                                          <value name="TEXT">
                                                            <shadow type="text" id="[MR#*oXE?!}?O-zS4(zJ">
                                                              <field name="TEXT">Wert ist wahr.</field>
                                                            </shadow>
                                                            <block type="variables_get" id="@~.)U#SEueoR;^]9,%Zm">
                                                              <field name="VAR" id="z2tXOU!,`e.Tvs40S(2*">VPN_Namen</field>
                                                            </block>
                                                          </value>
                                                        </block>
                                                      </next>
                                                    </block>
                                                  </next>
                                                </block>
                                              </next>
                                            </block>
                                          </statement>
                                          <statement name="ELSE">
                                            <block type="debug" id="K^tzcunaFD75;y#APe6O">
                                              <field name="Severity">warn</field>
                                              <value name="TEXT">
                                                <shadow type="text" id="?M%CVVpR5,qk6S}OnNUg">
                                                  <field name="TEXT">Wert ist nicht wahr.</field>
                                                </shadow>
                                              </value>
                                            </block>
                                          </statement>
                                        </block>
                                      </statement>
                                    </block>
                                  </next>
                                </block>
                              </next>
                            </block>
                          </next>
                        </block>
                      </next>
                    </block>
                  </next>
                </block>
              </next>
            </block>
          </statement>
        </block>
        <block type="procedures_defcustomreturn" id="@;-)7/5`2tfNSW6FR)HB" x="1188" y="-62">
          <mutation statements="false">
            <arg name="ObjectID" varid="!XoK2X3%QK4onFM)wEfP"></arg>
          </mutation>
          <field name="NAME">etwas tun</field>
          <field name="SCRIPT">cmV0dXJuIGdldE9iamVjdChPYmplY3RJRCkuY29tbW9uLm5hbWU7</field>
          <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
        </block>
      </xml>
      
      SchmakusS Offline
      SchmakusS Offline
      Schmakus
      Developer
      schrieb am zuletzt editiert von
      #2

      @nas007 setz mal deinen Debug-Block auf info oder warning und nicht debug, da "debug" nur kommt, wenn das logging vom js-adapter auf debug steht.

      Dev of LightControl Adapter, Contributor of HUE and DoorBird Adapter

      1 Antwort Letzte Antwort
      1
      • N Nas007

        Hallo,

        ich versuche gerade den Namen eines Objektes vom Pingadapter zu extrahieren. Ich habe meine Blöcke mal angehängt. Grundsätzlich funktioniert es objekte mit der Funktion "VPN" zu finden durch den Block "IDs vom Selektor" und ich bekomme die Debug Ausgabe (grün markiert).
        b765ae52-1bb8-46be-adc0-5b57da8860f6-grafik.png
        Aber ich will auch den Namen bekommen. Darum habe ich (aus tutorials) die Funktion "JS-Funktion mit Ergebnis" eingesetzt. Diese enthält eine Variable "ObjectID" und der Inhalt der Funktion ist dann:

        return getObject(ObjectID).common.name;
        

        Und dort wird wohl das Problem liegen. Bei der Eingabe des Befahls wird mir nach .common. das name schon garnicht angebot.

        Aber beim Pingadapter gibt es den gewünschten Wert:
        ab1537d0-4276-4e2e-b292-5774675ba9d6-grafik.png

        Woran liegt das?
        Vielen Dank schon mal!

        <xml xmlns="https://developers.google.com/blockly/xml">
          <variables>
            <variable id="!XoK2X3%QK4onFM)wEfP">ObjectID</variable>
            <variable id="=-iCY8uX8Qrj8pW.D:On">VPN_Anzahl_aktiv</variable>
            <variable id="gg0N.q[bRjq%]`9=Z%Q-">VPN_Anzahl_inaktiv</variable>
            <variable id="!-C1G,Bt?w:QXfuK+JNF">VPN_id</variable>
            <variable id="z2tXOU!,`e.Tvs40S(2*">VPN_Namen</variable>
          </variables>
          <block type="on_ext" id="t^gV}/pCuT7|mxFw3Oa-" x="588" y="-712">
            <mutation xmlns="http://www.w3.org/1999/xhtml" items="1"></mutation>
            <field name="CONDITION">ne</field>
            <field name="ACK_CONDITION"></field>
            <value name="OID0">
              <shadow type="field_oid" id="]iFkFJcoVRQ4yYIY4=l|">
                <field name="oid">default</field>
              </shadow>
              <block type="selector" id="P_L%n8K[8SgkZ]^(KFh0">
                <field name="TEXT">state[id=*](functions=vpn)</field>
              </block>
            </value>
            <statement name="STATEMENT">
              <block type="variables_set" id="jA]jmQ$;;v,q-6koRHSg">
                <field name="VAR" id="=-iCY8uX8Qrj8pW.D:On">VPN_Anzahl_aktiv</field>
                <value name="VALUE">
                  <block type="math_number" id="G|8nzNU?!a}!(-5IkX8d">
                    <field name="NUM">0</field>
                  </block>
                </value>
                <next>
                  <block type="variables_set" id="_s+:Vs,7WT{b${+ha%DB">
                    <field name="VAR" id="gg0N.q[bRjq%]`9=Z%Q-">VPN_Anzahl_inaktiv</field>
                    <value name="VALUE">
                      <block type="math_number" id="%WYD(9O0UqT7:lEi]apy">
                        <field name="NUM">0</field>
                      </block>
                    </value>
                    <next>
                      <block type="controls_forEach" id="HKv{pDXA;Rz%/E5a;vwL">
                        <field name="VAR" id="!-C1G,Bt?w:QXfuK+JNF">VPN_id</field>
                        <value name="LIST">
                          <block type="selector" id="3;*XS;#ExXeLJqrFpLg]">
                            <field name="TEXT">state[id=*](functions=vpn)</field>
                          </block>
                        </value>
                        <statement name="DO">
                          <block type="controls_if" id="v$H.~?e/W=Z4oz4Ts6ix">
                            <mutation else="1"></mutation>
                            <value name="IF0">
                              <block type="logic_compare" id="DnwgQ^Gq#wfShZ0j2Nik">
                                <field name="OP">EQ</field>
                                <value name="A">
                                  <block type="get_value_var" id="~-E[Y^v48!1U5xM!bl41">
                                    <field name="ATTR">val</field>
                                    <value name="OID">
                                      <shadow type="text">
                                        <field name="TEXT"></field>
                                      </shadow>
                                      <block type="variables_get" id="S$)@]U+%xUO_c)+@u$ie">
                                        <field name="VAR" id="!-C1G,Bt?w:QXfuK+JNF">VPN_id</field>
                                      </block>
                                    </value>
                                  </block>
                                </value>
                                <value name="B">
                                  <block type="logic_boolean" id="u}qaC6,U_H=Wbj:)ayzY">
                                    <field name="BOOL">TRUE</field>
                                  </block>
                                </value>
                              </block>
                            </value>
                            <statement name="DO0">
                              <block type="math_change" id="}E1`to(eG`fNTM];1Xr.">
                                <field name="VAR" id="=-iCY8uX8Qrj8pW.D:On">VPN_Anzahl_aktiv</field>
                                <value name="DELTA">
                                  <shadow type="math_number" id=";A55*ZS8j).HVLU[CCL^">
                                    <field name="NUM">1</field>
                                  </shadow>
                                  <block type="math_number" id="t|p_4.JJLX/(BRo;Ohl8">
                                    <field name="NUM">1</field>
                                  </block>
                                </value>
                              </block>
                            </statement>
                            <statement name="ELSE">
                              <block type="math_change" id="L}@B-@1D6ET6c^#I6_Bl">
                                <field name="VAR" id="gg0N.q[bRjq%]`9=Z%Q-">VPN_Anzahl_inaktiv</field>
                                <value name="DELTA">
                                  <shadow type="math_number" id="ANyO0JgW2X#AdnJOE/_@">
                                    <field name="NUM">1</field>
                                  </shadow>
                                  <block type="math_number" id="?Bj~$k._*1$zwONi%|8h">
                                    <field name="NUM">1</field>
                                  </block>
                                </value>
                              </block>
                            </statement>
                          </block>
                        </statement>
                        <next>
                          <block type="controls_if" id="CVvFXN}*;_si4o(h%L6}">
                            <value name="IF0">
                              <block type="logic_compare" id="Z/F34fHZf]uMAWJmn.?%">
                                <field name="OP">NEQ</field>
                                <value name="A">
                                  <block type="variables_get" id=")[ycF^4.{vo!dA5r=MAO">
                                    <field name="VAR" id="=-iCY8uX8Qrj8pW.D:On">VPN_Anzahl_aktiv</field>
                                  </block>
                                </value>
                                <value name="B">
                                  <block type="math_number" id="W4_+PXD*^kQM-x1KR[?`">
                                    <field name="NUM">0</field>
                                  </block>
                                </value>
                              </block>
                            </value>
                            <statement name="DO0">
                              <block type="debug" id="Dr%rHk4y}.$Y{T8;DK5L">
                                <field name="Severity">warn</field>
                                <value name="TEXT">
                                  <shadow type="text" id="9i@n/cb*J0dnE!}3}Z20">
                                    <field name="TEXT">VPN aktiv</field>
                                  </shadow>
                                </value>
                              </block>
                            </statement>
                            <next>
                              <block type="debug" id="Mu!,tzLL0-=1yq7LZ4FL">
                                <field name="Severity">warn</field>
                                <value name="TEXT">
                                  <shadow type="text" id="uI2$9^3#AOim[!|!p(ze">
                                    <field name="TEXT">Wert ist wahr.</field>
                                  </shadow>
                                  <block type="variables_get" id="UcNF=y58Ht2D;.o)8RM_">
                                    <field name="VAR" id="=-iCY8uX8Qrj8pW.D:On">VPN_Anzahl_aktiv</field>
                                  </block>
                                </value>
                                <next>
                                  <block type="debug" id=",Z@6|;?$(BF3gzmhGpTE">
                                    <field name="Severity">warn</field>
                                    <value name="TEXT">
                                      <shadow type="text" id="8Ri)5yLq}6miI*!HoUqC">
                                        <field name="TEXT">Wert ist wahr.</field>
                                      </shadow>
                                      <block type="variables_get" id="?SUp_K%H0Cif=qtoeWcJ">
                                        <field name="VAR" id="gg0N.q[bRjq%]`9=Z%Q-">VPN_Anzahl_inaktiv</field>
                                      </block>
                                    </value>
                                    <next>
                                      <block type="controls_forEach" id="NrPng5r(ITe9[ljFbLuE">
                                        <field name="VAR" id="!-C1G,Bt?w:QXfuK+JNF">VPN_id</field>
                                        <value name="LIST">
                                          <block type="selector" id="O32R/F,?h3oKKiS7gB;i">
                                            <field name="TEXT">state[id=*](functions=vpn)</field>
                                          </block>
                                        </value>
                                        <statement name="DO">
                                          <block type="controls_if" id=";beU)@zJ6EigQVn_QC{p">
                                            <mutation else="1"></mutation>
                                            <value name="IF0">
                                              <block type="logic_compare" id="0m1JpI|W~ui_tq+(O2FC">
                                                <field name="OP">EQ</field>
                                                <value name="A">
                                                  <block type="get_value_var" id="@@B^=?6:JfU}]u7v0dz/">
                                                    <field name="ATTR">val</field>
                                                    <value name="OID">
                                                      <shadow type="text">
                                                        <field name="TEXT"></field>
                                                      </shadow>
                                                      <block type="variables_get" id="igJF8Jhn*a1UX!SqzgZ%">
                                                        <field name="VAR" id="!-C1G,Bt?w:QXfuK+JNF">VPN_id</field>
                                                      </block>
                                                    </value>
                                                  </block>
                                                </value>
                                                <value name="B">
                                                  <block type="logic_boolean" id="[ROfv3pA%WEW/[)lr#p}">
                                                    <field name="BOOL">TRUE</field>
                                                  </block>
                                                </value>
                                              </block>
                                            </value>
                                            <statement name="DO0">
                                              <block type="debug" id="$_eK`mj{^`S[HW(eN;*|">
                                                <field name="Severity">warn</field>
                                                <value name="TEXT">
                                                  <shadow type="text" id="0StGrBs^4oWHycJ17t*1">
                                                    <field name="TEXT">Wert ist wahr.</field>
                                                  </shadow>
                                                </value>
                                                <next>
                                                  <block type="debug" id="#$Y.1dHd_PE%;xJzupeM">
                                                    <field name="Severity">debug</field>
                                                    <value name="TEXT">
                                                      <shadow type="text" id="_ngDm8^)M_DudPg%TlRd">
                                                        <field name="TEXT">Wert ist wahr.</field>
                                                      </shadow>
                                                      <block type="procedures_callcustomreturn" id="O`7e2u+7h+sPmPk;$KOL">
                                                        <mutation name="etwas tun">
                                                          <arg name="ObjectID"></arg>
                                                        </mutation>
                                                        <value name="ARG0">
                                                          <block type="variables_get" id="?]9aV@EwT(LizcR!z%0U">
                                                            <field name="VAR" id="!-C1G,Bt?w:QXfuK+JNF">VPN_id</field>
                                                          </block>
                                                        </value>
                                                      </block>
                                                    </value>
                                                    <next>
                                                      <block type="variables_set" id="*}v}R$9qPggi%$yJXNeB">
                                                        <field name="VAR" id="z2tXOU!,`e.Tvs40S(2*">VPN_Namen</field>
                                                        <value name="VALUE">
                                                          <block type="procedures_callcustomreturn" id="j|VQN(1}XPcDaJk[Zae6">
                                                            <mutation name="etwas tun">
                                                              <arg name="ObjectID"></arg>
                                                            </mutation>
                                                            <value name="ARG0">
                                                              <block type="variables_get" id="?2Y(i;(|lekpGLZTh@Dr">
                                                                <field name="VAR" id="!-C1G,Bt?w:QXfuK+JNF">VPN_id</field>
                                                              </block>
                                                            </value>
                                                          </block>
                                                        </value>
                                                        <next>
                                                          <block type="debug" id="?NKb,F`W=c1B_q.j$EQc">
                                                            <field name="Severity">debug</field>
                                                            <value name="TEXT">
                                                              <shadow type="text" id="[MR#*oXE?!}?O-zS4(zJ">
                                                                <field name="TEXT">Wert ist wahr.</field>
                                                              </shadow>
                                                              <block type="variables_get" id="@~.)U#SEueoR;^]9,%Zm">
                                                                <field name="VAR" id="z2tXOU!,`e.Tvs40S(2*">VPN_Namen</field>
                                                              </block>
                                                            </value>
                                                          </block>
                                                        </next>
                                                      </block>
                                                    </next>
                                                  </block>
                                                </next>
                                              </block>
                                            </statement>
                                            <statement name="ELSE">
                                              <block type="debug" id="K^tzcunaFD75;y#APe6O">
                                                <field name="Severity">warn</field>
                                                <value name="TEXT">
                                                  <shadow type="text" id="?M%CVVpR5,qk6S}OnNUg">
                                                    <field name="TEXT">Wert ist nicht wahr.</field>
                                                  </shadow>
                                                </value>
                                              </block>
                                            </statement>
                                          </block>
                                        </statement>
                                      </block>
                                    </next>
                                  </block>
                                </next>
                              </block>
                            </next>
                          </block>
                        </next>
                      </block>
                    </next>
                  </block>
                </next>
              </block>
            </statement>
          </block>
          <block type="procedures_defcustomreturn" id="@;-)7/5`2tfNSW6FR)HB" x="1188" y="-62">
            <mutation statements="false">
              <arg name="ObjectID" varid="!XoK2X3%QK4onFM)wEfP"></arg>
            </mutation>
            <field name="NAME">etwas tun</field>
            <field name="SCRIPT">cmV0dXJuIGdldE9iamVjdChPYmplY3RJRCkuY29tbW9uLm5hbWU7</field>
            <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
          </block>
        </xml>
        
        CodierknechtC Online
        CodierknechtC Online
        Codierknecht
        Developer Most Active
        schrieb am zuletzt editiert von
        #3

        @nas007
        Lass Dir doch mal mit einem Debug-Block ausgeben, was in dem Moment in "VPN_id" drinsteht.

        "Any fool can write code that a computer can understand. Good programmers write code that humans can understand." (Martin Fowler, "Refactoring")

        Proxmox 9.1.1 LXC|8 GB|Core i7-6700
        HmIP|ZigBee|Tasmota|Unifi
        Zabbix Certified Specialist
        Konnte ich Dir helfen? Dann benutze bitte das Voting unten rechts im Beitrag

        N 1 Antwort Letzte Antwort
        0
        • CodierknechtC Codierknecht

          @nas007
          Lass Dir doch mal mit einem Debug-Block ausgeben, was in dem Moment in "VPN_id" drinsteht.

          N Offline
          N Offline
          Nas007
          schrieb am zuletzt editiert von
          #4

          @Schmakus

          Das kann nicht wahr sein... das wars. Wie viel zeit ich damit verschwendet habe :cold_sweat:

          013a19d0-48b8-4eb9-b3ae-1e8ab82e1620-grafik.png

          @Codierknecht Ja das hatte ich schon, das passte. Habe ich leider nicht erwähnt.

          1 Antwort Letzte Antwort
          1
          Antworten
          • In einem neuen Thema antworten
          Anmelden zum Antworten
          • Älteste zuerst
          • Neuste zuerst
          • Meiste Stimmen


          Support us

          ioBroker
          Community Adapters
          Donate

          614

          Online

          32.6k

          Benutzer

          82.0k

          Themen

          1.3m

          Beiträge
          Community
          Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
          ioBroker Community 2014-2025
          logo
          • Anmelden

          • Du hast noch kein Konto? Registrieren

          • Anmelden oder registrieren, um zu suchen
          • Erster Beitrag
            Letzter Beitrag
          0
          • Home
          • Aktuell
          • Tags
          • Ungelesen 0
          • Kategorien
          • Unreplied
          • Beliebt
          • GitHub
          • Docu
          • Hilfe