Navigation

    Logo
    • Register
    • Login
    • Search
    • Recent
    • Tags
    • Unread
    • Categories
    • Unreplied
    • Popular
    • GitHub
    • Docu
    • Hilfe
    1. Home
    2. Deutsch
    3. Skripten / Logik
    4. Blockly
    5. JSON Parsen in Blockly (ESP-RFID)

    NEWS

    • Neuer Blog: Fotos und Eindrücke aus Solingen

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

    • ioBroker goes Matter ... Matter Adapter in Stable

    JSON Parsen in Blockly (ESP-RFID)

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

      Hallo,

      ich habe ein Blueboard mit ESP-RFID (https://drive.google.com/file/d/17K6NVxq9r38fufxysGRDTxVwHWs_1wxA/view)
      mittels MQTT in den IOBroker "gezogen".
      Der JSON-String welcher beim auflegen eines RFID-Tags erscheint sieht wie folgt aus:

      {"type":"access","time":1612568936,"isKnown":"true","access":"Always","username":"User_2","uid":"47afa950","door":"esp-rfid"}
      

      Ich würde jetzt gern zwei getrennte Sachen in Blockly (2 Scripte) machen:

      1. Wenn ein bestimmter User (z.B. User_2) sich authentifiziert soll ein Shelly1 geschaltet werden
      2. Es soll gezählt werden wie oft ein User sich in einem Jahr authentifiziert. (z.B. User_2 35x in 2020 und 40x in 2021)

      wie muss ich in Blockly vorgehen - ich weis nicht mal wie ich anfangen soll...?

      Liebe Grüße
      Felix

      F 1 Reply Last reply Reply Quote 0
      • F
        fastfoot @Felix Merk last edited by

        @felix-merk Hier was zum Rumprobieren, du musst für jeden Benutzer einen Datenpunkt anlegen, der genau so heißt wie der User
        Access.PNG

        <xml xmlns="https://developers.google.com/blockly/xml">
         <variables>
           <variable id="smfipXSz7c$2VGi]fdHq">user</variable>
           <variable id="pg}_kRifeB^Nh#q+U1R)">idUser</variable>
           <variable id="kP9.Zv7p%TF[-@s01Q$6">Zähler</variable>
         </variables>
         <block type="on_ext" id="`r[e|Zre^i1M[,4#LQb8" x="13" y="12">
           <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="p{9:o5Vc#A]O|ijP.6kH">
               <field name="oid">0_userdata.0.example_state</field>
             </shadow>
           </value>
           <statement name="STATEMENT">
             <block type="variables_set" id="9zW]qjf1.oJ:*r(`Snhp">
               <field name="VAR" id="smfipXSz7c$2VGi]fdHq">user</field>
               <value name="VALUE">
                 <block type="get_attr" id="#OJnwsvskALVr7ICmA7E">
                   <value name="PATH">
                     <shadow type="text" id="?D?b78:-+x}`/|k;DtM;">
                       <field name="TEXT">username</field>
                     </shadow>
                   </value>
                   <value name="OBJECT">
                     <block type="on_source" id="]:H5pqerc{6Gyrkz1+P:">
                       <field name="ATTR">state.val</field>
                     </block>
                   </value>
                 </block>
               </value>
               <next>
                 <block type="controls_if" id="5Z}lU*NMnk]zNAgzO*W7">
                   <value name="IF0">
                     <block type="logic_compare" id="CgTx-f8!A72aCn4qgw!4">
                       <field name="OP">EQ</field>
                       <value name="A">
                         <block type="variables_get" id="82(vIy)iBDo#^9g7zX`h">
                           <field name="VAR" id="smfipXSz7c$2VGi]fdHq">user</field>
                         </block>
                       </value>
                       <value name="B">
                         <block type="text" id="+4Hvp,mBGMnKJVnTj_DY">
                           <field name="TEXT">User_2</field>
                         </block>
                       </value>
                     </block>
                   </value>
                   <statement name="DO0">
                     <block type="control" id="w(B.oiAevaA3m-g;(#4~">
                       <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                       <field name="OID">0_userdata.0.Access.openDoor</field>
                       <field name="WITH_DELAY">FALSE</field>
                       <value name="VALUE">
                         <block type="logic_boolean" id="hzzjuV;92~SuHDp!]Pvn">
                           <field name="BOOL">TRUE</field>
                         </block>
                       </value>
                     </block>
                   </statement>
                   <next>
                     <block type="variables_set" id="#FHf2r.z^~t7oo`*MP*f">
                       <field name="VAR" id="pg}_kRifeB^Nh#q+U1R)">idUser</field>
                       <value name="VALUE">
                         <block type="text_join" id="{FaFC2zrKG=!RWQh3WsR">
                           <mutation items="2"></mutation>
                           <value name="ADD0">
                             <block type="text" id="MkDE%9]+|6NHv*`+Da$D">
                               <field name="TEXT">0_userdata.0.Access.</field>
                             </block>
                           </value>
                           <value name="ADD1">
                             <block type="variables_get" id="/K=D*:-5)G:0p$EQQjFY">
                               <field name="VAR" id="smfipXSz7c$2VGi]fdHq">user</field>
                             </block>
                           </value>
                         </block>
                       </value>
                       <next>
                         <block type="variables_set" id="E]r-4)mJ,+.usET!X)_P">
                           <field name="VAR" id="kP9.Zv7p%TF[-@s01Q$6">Zähler</field>
                           <value name="VALUE">
                             <block type="math_arithmetic" id="v54KF@L:^UK#,tNSPLzF">
                               <field name="OP">ADD</field>
                               <value name="A">
                                 <shadow type="math_number" id="rpYetT,*vGRk`x.V3qz5">
                                   <field name="NUM">1</field>
                                 </shadow>
                                 <block type="get_value_var" id="m_QU:+P}oMA9`4u;:%Tn">
                                   <field name="ATTR">val</field>
                                   <value name="OID">
                                     <shadow type="text" id="r^$d7+JL.wTkmx[P#[9v">
                                       <field name="TEXT"></field>
                                     </shadow>
                                     <block type="variables_get" id="rD9}!-dy@?.lA6{z/0v|">
                                       <field name="VAR" id="pg}_kRifeB^Nh#q+U1R)">idUser</field>
                                     </block>
                                   </value>
                                 </block>
                               </value>
                               <value name="B">
                                 <shadow type="math_number" id="Nyl%jdwgBIL:B+wK_%3[">
                                   <field name="NUM">1</field>
                                 </shadow>
                               </value>
                             </block>
                           </value>
                           <next>
                             <block type="control_ex" id="XngmWG?I+2NoNy1N?F/_" inline="true">
                               <field name="TYPE">true</field>
                               <field name="CLEAR_RUNNING">FALSE</field>
                               <value name="OID">
                                 <shadow type="field_oid" id="gF8pxI(%1$X%I%zYx5$(">
                                   <field name="oid">Object ID</field>
                                 </shadow>
                                 <block type="variables_get" id="C{`8w!T}^0IpFH!{jKvp">
                                   <field name="VAR" id="pg}_kRifeB^Nh#q+U1R)">idUser</field>
                                 </block>
                               </value>
                               <value name="VALUE">
                                 <shadow type="logic_boolean" id="(^jF.I-z3NW+Yx(F[hB2">
                                   <field name="BOOL">TRUE</field>
                                 </shadow>
                                 <block type="variables_get" id="l%d(u4|li)cr+1Y4`/K]">
                                   <field name="VAR" id="kP9.Zv7p%TF[-@s01Q$6">Zähler</field>
                                 </block>
                               </value>
                               <value name="DELAY_MS">
                                 <shadow type="math_number" id="*`g2tjBPpI{]ElN=^m1c">
                                   <field name="NUM">0</field>
                                 </shadow>
                               </value>
                             </block>
                           </next>
                         </block>
                       </next>
                     </block>
                   </next>
                 </block>
               </next>
             </block>
           </statement>
         </block>
        </xml>
        

        Felix Merk 2 Replies Last reply Reply Quote 0
        • Felix Merk
          Felix Merk @fastfoot last edited by

          @fastfoot Danke, werde ich testen und berichten!

          1 Reply Last reply Reply Quote 0
          • Felix Merk
            Felix Merk @fastfoot last edited by Felix Merk

            @fastfoot
            der Erste Teil mit dem Schalten des Shellys läuft schon mal super! Oder fast 🙂
            Ich hab einen "Fehler" den ich nicht nachvollziehen kann:

            blockly14564564.jpg

            oder

            blockly2.JPG

            <xml xmlns="http://www.w3.org/1999/xhtml">
              <variables>
                <variable type="" id="smfipXSz7c$2VGi]fdHq">user</variable>
              </variables>
              <block type="on_ext" id="`r[e|Zre^i1M[,4#LQb8" x="13" y="12">
                <mutation items="1"></mutation>
                <field name="CONDITION">ne</field>
                <field name="ACK_CONDITION"></field>
                <value name="OID0">
                  <shadow type="field_oid" id="p{9:o5Vc#A]O|ijP.6kH">
                    <field name="oid">mqtt.0.rfid.leser.send</field>
                  </shadow>
                </value>
                <statement name="STATEMENT">
                  <block type="variables_set" id="9zW]qjf1.oJ:*r(`Snhp">
                    <field name="VAR" id="smfipXSz7c$2VGi]fdHq" variabletype="">user</field>
                    <value name="VALUE">
                      <block type="get_attr" id="#OJnwsvskALVr7ICmA7E">
                        <value name="PATH">
                          <shadow type="text" id="?D?b78:-+x}`/|k;DtM;">
                            <field name="TEXT">username</field>
                          </shadow>
                        </value>
                        <value name="OBJECT">
                          <block type="on_source" id="]:H5pqerc{6Gyrkz1+P:">
                            <field name="ATTR">state.val</field>
                          </block>
                        </value>
                      </block>
                    </value>
                    <next>
                      <block type="controls_if" id="5Z}lU*NMnk]zNAgzO*W7">
                        <value name="IF0">
                          <block type="logic_compare" id="CgTx-f8!A72aCn4qgw!4">
                            <field name="OP">EQ</field>
                            <value name="A">
                              <block type="variables_get" id="82(vIy)iBDo#^9g7zX`h">
                                <field name="VAR" id="smfipXSz7c$2VGi]fdHq" variabletype="">user</field>
                              </block>
                            </value>
                            <value name="B">
                              <block type="text" id="+4Hvp,mBGMnKJVnTj_DY">
                                <field name="TEXT">Felix_Merk</field>
                              </block>
                            </value>
                          </block>
                        </value>
                        <statement name="DO0">
                          <block type="controls_if" id="5atN0y`}7v.,-CWFc{7+">
                            <mutation else="1"></mutation>
                            <value name="IF0">
                              <block type="logic_compare" id="t}Prj}J%L_3NhJWc3RFc">
                                <field name="OP">EQ</field>
                                <value name="A">
                                  <block type="get_value" id="|2.+HO)ztM2;q[q!I.H6">
                                    <field name="ATTR">val</field>
                                    <field name="OID">shelly.0.SHSW-1#F4282B#2.Relay0.Switch</field>
                                  </block>
                                </value>
                                <value name="B">
                                  <block type="logic_boolean" id="x-jP*Fd?NV+Sp|hhl_1N">
                                    <field name="BOOL">TRUE</field>
                                  </block>
                                </value>
                              </block>
                            </value>
                            <statement name="DO0">
                              <block type="control" id="[0Pd9wpD:kB|qifUBtvQ">
                                <mutation delay_input="false"></mutation>
                                <field name="OID">shelly.0.SHSW-1#F4282B#2.Relay0.Switch</field>
                                <field name="WITH_DELAY">FALSE</field>
                                <value name="VALUE">
                                  <block type="logic_boolean" id="VR-P7mpXpzO{e0)})fm)">
                                    <field name="BOOL">FALSE</field>
                                  </block>
                                </value>
                              </block>
                            </statement>
                            <statement name="ELSE">
                              <block type="control" id="i9zorrxcYyWgt:Owx]S/">
                                <mutation delay_input="false"></mutation>
                                <field name="OID">shelly.0.SHSW-1#F4282B#2.Relay0.Switch</field>
                                <field name="WITH_DELAY">FALSE</field>
                                <value name="VALUE">
                                  <block type="logic_boolean" id="}]GVlr$BK-~JwT1~|tv0">
                                    <field name="BOOL">TRUE</field>
                                  </block>
                                </value>
                              </block>
                            </statement>
                          </block>
                        </statement>
                      </block>
                    </next>
                  </block>
                </statement>
              </block>
            </xml>
            
            

            
            BlocklyJavascriptTypeScript
            Protokoll
            Ausgewählte Blöcke exportieren
            <xml xmlns="http://www.w3.org/1999/xhtml">
              <variables>
                <variable type="" id="smfipXSz7c$2VGi]fdHq">user</variable>
              </variables>
              <block type="on_ext" id="`r[e|Zre^i1M[,4#LQb8" x="13" y="12">
                <mutation items="1"></mutation>
                <field name="CONDITION">ne</field>
                <field name="ACK_CONDITION"></field>
                <value name="OID0">
                  <shadow type="field_oid" id="p{9:o5Vc#A]O|ijP.6kH">
                    <field name="oid">mqtt.0.rfid.leser.send</field>
                  </shadow>
                </value>
                <statement name="STATEMENT">
                  <block type="variables_set" id="9zW]qjf1.oJ:*r(`Snhp">
                    <field name="VAR" id="smfipXSz7c$2VGi]fdHq" variabletype="">user</field>
                    <value name="VALUE">
                      <block type="get_attr" id="#OJnwsvskALVr7ICmA7E">
                        <value name="PATH">
                          <shadow type="text" id="?D?b78:-+x}`/|k;DtM;">
                            <field name="TEXT">username</field>
                          </shadow>
                        </value>
                        <value name="OBJECT">
                          <block type="on_source" id="]:H5pqerc{6Gyrkz1+P:">
                            <field name="ATTR">state.val</field>
                          </block>
                        </value>
                      </block>
                    </value>
                    <next>
                      <block type="controls_if" id="5Z}lU*NMnk]zNAgzO*W7">
                        <value name="IF0">
                          <block type="logic_compare" id="CgTx-f8!A72aCn4qgw!4">
                            <field name="OP">EQ</field>
                            <value name="A">
                              <block type="variables_get" id="82(vIy)iBDo#^9g7zX`h">
                                <field name="VAR" id="smfipXSz7c$2VGi]fdHq" variabletype="">user</field>
                              </block>
                            </value>
                            <value name="B">
                              <block type="text" id="+4Hvp,mBGMnKJVnTj_DY">
                                <field name="TEXT">Felix_Merk</field>
                              </block>
                            </value>
                          </block>
                        </value>
                        <statement name="DO0">
                          <block type="toggle" id="O^Dz6KQS3aV=x*=SUJHd">
                            <mutation delay_input="false"></mutation>
                            <field name="OID">shelly.0.SHSW-1#F4282B#2.Relay0.Switch</field>
                            <field name="WITH_DELAY">FALSE</field>
                          </block>
                        </statement>
                      </block>
                    </next>
                  </block>
                </statement>
              </block>
            </xml>
            <xml xmlns="http://www.w3.org/1999/xhtml">
              <variables>
                <variable type="" id="smfipXSz7c$2VGi]fdHq">user</variable>
              </variables>
              <block type="on_ext" id="`r[e|Zre^i1M[,4#LQb8" x="13" y="12">
                <mutation items="1"></mutation>
                <field name="CONDITION">ne</field>
                <field name="ACK_CONDITION"></field>
                <value name="OID0">
                  <shadow type="field_oid" id="p{9:o5Vc#A]O|ijP.6kH">
                    <field name="oid">mqtt.0.rfid.leser.send</field>
                  </shadow>
                </value>
                <statement name="STATEMENT">
                  <block type="variables_set" id="9zW]qjf1.oJ:*r(`Snhp">
                    <field name="VAR" id="smfipXSz7c$2VGi]fdHq" variabletype="">user</field>
                    <value name="VALUE">
                      <block type="get_attr" id="#OJnwsvskALVr7ICmA7E">
                        <value name="PATH">
                          <shadow type="text" id="?D?b78:-+x}`/|k;DtM;">
                            <field name="TEXT">username</field>
                          </shadow>
                        </value>
                        <value name="OBJECT">
                          <block type="on_source" id="]:H5pqerc{6Gyrkz1+P:">
                            <field name="ATTR">state.val</field>
                          </block>
                        </value>
                      </block>
                    </value>
                    <next>
                      <block type="controls_if" id="5Z}lU*NMnk]zNAgzO*W7">
                        <value name="IF0">
                          <block type="logic_compare" id="CgTx-f8!A72aCn4qgw!4">
                            <field name="OP">EQ</field>
                            <value name="A">
                              <block type="variables_get" id="82(vIy)iBDo#^9g7zX`h">
                                <field name="VAR" id="smfipXSz7c$2VGi]fdHq" variabletype="">user</field>
                              </block>
                            </value>
                            <value name="B">
                              <block type="text" id="+4Hvp,mBGMnKJVnTj_DY">
                                <field name="TEXT">Felix_Merk</field>
                              </block>
                            </value>
                          </block>
                        </value>
                        <statement name="DO0">
                          <block type="toggle" id="O^Dz6KQS3aV=x*=SUJHd">
                            <mutation delay_input="false"></mutation>
                            <field name="OID">shelly.0.SHSW-1#F4282B#2.Relay0.Switch</field>
                            <field name="WITH_DELAY">FALSE</field>
                          </block>
                        </statement>
                      </block>
                    </next>
                  </block>
                </statement>
              </block>
            </xml>
            
            

            Wenn der shelly aus ist (false) und ich hebe den RFID tag ran, geht das Licht an, wie es soll. Wenn ich ich den Tag aber nochmal hinhalte passiert nichts. Erst beim zweiten mal hinhalten (Zeit spielt keine Rolle) geht das Licht wieder aus.
            Lässt sich beliebig oft wiederholen.... beim ausschalten muss ich immer zweimal hinhalten.
            An was liegt das?

            Liebe Grüße

            F 1 Reply Last reply Reply Quote 0
            • F
              fastfoot @Felix Merk last edited by

              @felix-merk Schwierig zu sagen, probiere mal mit 2 Debug-Blöcken wie gezeigt. Das zeigt ob der Trigger immer anspricht(sollte er eigentlich) und ob die Werte richtig sind. Dann sehen wir weiter
              Access1.PNG

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

              Support us

              ioBroker
              Community Adapters
              Donate

              682
              Online

              31.7k
              Users

              79.9k
              Topics

              1.3m
              Posts

              2
              5
              548
              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