Skip to content
Sebastian Bormann edited this page Dec 25, 2021 · 1 revision

Hallo,

hab mir grad mit Blockly eine kleine Tabelle für den Birthdays Adapter (https://forum.iobroker.net/topic/40228/test-adapter-birthdays-0-0-1) gebastelt.

Wollte das Blockly nur kurz zu Verfügung stellen.

image image

<xml xmlns="https://developers.google.com/blockly/xml">
  <variables>
    <variable id="(m}dH@gw]g]CrCq4X:^O">Liste</variable>
    <variable id="^u_U-Az-`mhCz~(F_#oT">text</variable>
    <variable id="x(8OtWm-n$bsM}t4],DO">i</variable>
    <variable id="B=:MPlbZ]`U`oQR_H1ZO">obj</variable>
    <variable id="|9,SdA]rgGmj%K}^fKl*">Alter</variable>
    <variable id="2xs$M*SFSh^lkODi*Z,g">Name</variable>
    <variable id=";RHJ=)9w[N*6ii2YVbv#">Tage_bis_Geburtstag</variable>
    <variable id="[hejW*.Wk;gQUlv)`eJ|">Tag_Monat</variable>
    <variable id="e}Pk:{7j{A~j7#a%49!f">Geburtsjahr</variable>
  </variables>
  <block type="on" id="ubL@LBF!,o_rkk4*V?$c" x="263" y="38">
    <field name="OID">birthdays.0.summary.json</field>
    <field name="CONDITION">ne</field>
    <field name="ACK_CONDITION"></field>
    <statement name="STATEMENT">
      <block type="variables_set" id="W?1q7FaV,*wmZaIkPQ*o">
        <field name="VAR" id="(m}dH@gw]g]CrCq4X:^O">Liste</field>
        <value name="VALUE">
          <block type="convert_json2object" id="-+dC_oJ;-(a!X+qq3ItL">
            <value name="VALUE">
              <block type="on_source" id="W9LY54G8%@AW$,Dv.c1;">
                <field name="ATTR">state.val</field>
              </block>
            </value>
          </block>
        </value>
        <next>
          <block type="variables_set" id="*Gbs7`LVq2ggdi|-gk1#">
            <field name="VAR" id="^u_U-Az-`mhCz~(F_#oT">text</field>
            <value name="VALUE">
              <block type="text" id="D2QaAKbM6V%.nH8G!WO8">
                <field name="TEXT"></field>
              </block>
            </value>
            <next>
              <block type="controls_for" id="VAh4_5skpQ(-58)cTsN5">
                <field name="VAR" id="x(8OtWm-n$bsM}t4],DO">i</field>
                <value name="FROM">
                  <shadow type="math_number" id="UtEruMTPhi^T~g$#4=X%">
                    <field name="NUM">1</field>
                  </shadow>
                </value>
                <value name="TO">
                  <shadow type="math_number" id="SL!L;!$5LE6b.-i2{-x8">
                    <field name="NUM">10</field>
                  </shadow>
                  <block type="lists_length" id="IA8x7(aD91K?{^4e{t?p">
                    <value name="VALUE">
                      <block type="variables_get" id="Uw=RBKOt~o^7pvz5@?jp">
                        <field name="VAR" id="(m}dH@gw]g]CrCq4X:^O">Liste</field>
                      </block>
                    </value>
                  </block>
                </value>
                <value name="BY">
                  <shadow type="math_number" id="X?ku5(f{C?`POZ9}Ykn$">
                    <field name="NUM">1</field>
                  </shadow>
                </value>
                <statement name="DO">
                  <block type="variables_set" id="?x8p%;#1!zl^M{*-WeD_">
                    <field name="VAR" id="B=:MPlbZ]`U`oQR_H1ZO">obj</field>
                    <value name="VALUE">
                      <block type="lists_getIndex" id="!p81u1HNh}swg_ZCMWGd">
                        <mutation statement="false" at="true"></mutation>
                        <field name="MODE">GET</field>
                        <field name="WHERE">FROM_START</field>
                        <value name="VALUE">
                          <block type="variables_get" id="3ETVK*E:VqCH}#kblamq">
                            <field name="VAR" id="(m}dH@gw]g]CrCq4X:^O">Liste</field>
                          </block>
                        </value>
                        <value name="AT">
                          <block type="variables_get" id="4ZY9FTQA,JoJx!nEg^nc">
                            <field name="VAR" id="x(8OtWm-n$bsM}t4],DO">i</field>
                          </block>
                        </value>
                      </block>
                    </value>
                    <next>
                      <block type="variables_set" id="_?!N}.aye8u=,XQ}5rY{">
                        <field name="VAR" id="|9,SdA]rgGmj%K}^fKl*">Alter</field>
                        <value name="VALUE">
                          <block type="get_attr" id="V=ixw;0O?aW0sXtNbLyR">
                            <value name="PATH">
                              <shadow type="text" id="XE}T12XOKYB-U6A8etD(">
                                <field name="TEXT">age</field>
                              </shadow>
                            </value>
                            <value name="OBJECT">
                              <block type="variables_get" id="Aqx9nyk[/uZhLuG|WKW]">
                                <field name="VAR" id="B=:MPlbZ]`U`oQR_H1ZO">obj</field>
                              </block>
                            </value>
                          </block>
                        </value>
                        <next>
                          <block type="variables_set" id="C@RzukD_z2Vc[/_q1s4q">
                            <field name="VAR" id="2xs$M*SFSh^lkODi*Z,g">Name</field>
                            <value name="VALUE">
                              <block type="get_attr" id="si%nmaEYZ8yF2`)aXAA[">
                                <value name="PATH">
                                  <shadow type="text" id="Vv?R@/OzO]p40i%9sCnd">
                                    <field name="TEXT">name</field>
                                  </shadow>
                                </value>
                                <value name="OBJECT">
                                  <block type="variables_get" id="Dv389p@`@/Y3}]gx``_e">
                                    <field name="VAR" id="B=:MPlbZ]`U`oQR_H1ZO">obj</field>
                                  </block>
                                </value>
                              </block>
                            </value>
                            <next>
                              <block type="variables_set" id=")z0aBTEtrg5l23)8iHRs">
                                <field name="VAR" id=";RHJ=)9w[N*6ii2YVbv#">Tage_bis_Geburtstag</field>
                                <value name="VALUE">
                                  <block type="get_attr" id="`wPRO=fu4+XJSLOOaSO0">
                                    <value name="PATH">
                                      <shadow type="text" id="%IZ(eKv9iMml(NI-f]5P">
                                        <field name="TEXT">daysLeft</field>
                                      </shadow>
                                    </value>
                                    <value name="OBJECT">
                                      <block type="variables_get" id="3Hno*M89!AaJIE6(3=33">
                                        <field name="VAR" id="B=:MPlbZ]`U`oQR_H1ZO">obj</field>
                                      </block>
                                    </value>
                                  </block>
                                </value>
                                <next>
                                  <block type="variables_set" id="J/6:.#/@k1b,K1u(Bpq/">
                                    <field name="VAR" id="[hejW*.Wk;gQUlv)`eJ|">Tag_Monat</field>
                                    <value name="VALUE">
                                      <block type="get_attr" id=";tsY?ta87G!Ip{x3uz#T">
                                        <value name="PATH">
                                          <shadow type="text" id="HmVz%-OkrSIKER](18V:">
                                            <field name="TEXT">dateFormat</field>
                                          </shadow>
                                        </value>
                                        <value name="OBJECT">
                                          <block type="variables_get" id="Vq9etR=Lc?:t?%0IUjP9">
                                            <field name="VAR" id="B=:MPlbZ]`U`oQR_H1ZO">obj</field>
                                          </block>
                                        </value>
                                      </block>
                                    </value>
                                    <next>
                                      <block type="variables_set" id="$+EHiR+SK#`|(Fs[.{n~">
                                        <field name="VAR" id="e}Pk:{7j{A~j7#a%49!f">Geburtsjahr</field>
                                        <value name="VALUE">
                                          <block type="get_attr" id="vr3`]9_k0Ke3+G;BPe0$">
                                            <value name="PATH">
                                              <shadow type="text" id="g}99n.xJZe2a;])BF`jI">
                                                <field name="TEXT">birthYear</field>
                                              </shadow>
                                            </value>
                                            <value name="OBJECT">
                                              <block type="variables_get" id="C?}|MWY(:zJSY(62Q!L-">
                                                <field name="VAR" id="B=:MPlbZ]`U`oQR_H1ZO">obj</field>
                                              </block>
                                            </value>
                                          </block>
                                        </value>
                                        <next>
                                          <block type="variables_set" id=",AX3xaQpP,RI_FeH!Xx|">
                                            <field name="VAR" id="^u_U-Az-`mhCz~(F_#oT">text</field>
                                            <value name="VALUE">
                                              <block type="text_join" id="oc7)%`;1Y7hZ,{LSK@n^">
                                                <mutation items="12"></mutation>
                                                <value name="ADD0">
                                                  <block type="variables_get" id="SjYSlvJOrj+1T]NFWCL0">
                                                    <field name="VAR" id="^u_U-Az-`mhCz~(F_#oT">text</field>
                                                  </block>
                                                </value>
                                                <value name="ADD1">
                                                  <block type="text" id="@UfRgRh#-n,^e{wnY,#$">
                                                    <field name="TEXT">&lt;td align=left&gt;</field>
                                                  </block>
                                                </value>
                                                <value name="ADD2">
                                                  <block type="variables_get" id="bJfAhLxPp7#nS|JLsb$2">
                                                    <field name="VAR" id="2xs$M*SFSh^lkODi*Z,g">Name</field>
                                                  </block>
                                                </value>
                                                <value name="ADD3">
                                                  <block type="text" id="SmFyDO|0Dgd0$?eaA`Sg">
                                                    <field name="TEXT">&lt;/td&gt;&lt;td align=left&gt;</field>
                                                  </block>
                                                </value>
                                                <value name="ADD4">
                                                  <block type="variables_get" id=";1!SxOtb)P*,f@2txLG+">
                                                    <field name="VAR" id="[hejW*.Wk;gQUlv)`eJ|">Tag_Monat</field>
                                                  </block>
                                                </value>
                                                <value name="ADD5">
                                                  <block type="text" id="3Q6jnW~yh]:hVCAUBoKb">
                                                    <field name="TEXT">&lt;/td&gt;&lt;td align=left&gt;</field>
                                                  </block>
                                                </value>
                                                <value name="ADD6">
                                                  <block type="variables_get" id="7r#.X6VO;Q,F#?pc,v0W">
                                                    <field name="VAR" id="e}Pk:{7j{A~j7#a%49!f">Geburtsjahr</field>
                                                  </block>
                                                </value>
                                                <value name="ADD7">
                                                  <block type="text" id="+vLQ9vR)6X{N-nzVKvN^">
                                                    <field name="TEXT">&lt;/td&gt;&lt;td align=left&gt;</field>
                                                  </block>
                                                </value>
                                                <value name="ADD8">
                                                  <block type="variables_get" id="A]OKm4e`3x(zLzn6s(QN">
                                                    <field name="VAR" id="|9,SdA]rgGmj%K}^fKl*">Alter</field>
                                                  </block>
                                                </value>
                                                <value name="ADD9">
                                                  <block type="text" id="r~]`+Ui@uG2}fm0!SCcO">
                                                    <field name="TEXT">&lt;/td&gt;&lt;td align=left&gt;</field>
                                                  </block>
                                                </value>
                                                <value name="ADD10">
                                                  <block type="variables_get" id="fIhTLcQB}M=fC^B;!y[3">
                                                    <field name="VAR" id=";RHJ=)9w[N*6ii2YVbv#">Tage_bis_Geburtstag</field>
                                                  </block>
                                                </value>
                                                <value name="ADD11">
                                                  <block type="text" id="0ihN7QSrFrH1sgNZgp;f">
                                                    <field name="TEXT">&lt;/tr&gt; </field>
                                                  </block>
                                                </value>
                                              </block>
                                            </value>
                                          </block>
                                        </next>
                                      </block>
                                    </next>
                                  </block>
                                </next>
                              </block>
                            </next>
                          </block>
                        </next>
                      </block>
                    </next>
                  </block>
                </statement>
                <next>
                  <block type="update" id="~ezoSMAi3J%e*eL}tsO.">
                    <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                    <field name="OID">0_userdata.0.VIS.Tabellen.Geburtstage</field>
                    <field name="WITH_DELAY">FALSE</field>
                    <value name="VALUE">
                      <block type="text_join" id=")4[foVL+;!xdhFv($WVn">
                        <mutation items="3"></mutation>
                        <value name="ADD0">
                          <block type="text" id="rqH.Tp+,./Gm@C8e99ZY">
                            <field name="TEXT">&lt;table&gt;   &lt;tr&gt;     &lt;th width=100 align=left&gt;Name&lt;/th&gt;     &lt;th width=60 align=left&gt;Datum&lt;/th&gt;     &lt;th width=60 align=left&gt;Jahr&lt;/th&gt;     &lt;th width=60 align=left&gt;Alter&lt;/th&gt;     &lt;th width=60 align=left&gt;In Tagen&lt;/th&gt;   &lt;/tr&gt;   &lt;tr&gt;   &lt;td colspan="5"&gt;&lt;hr&gt;&lt;/td&gt;   &lt;/tr&gt;   &lt;tr&gt;</field>
                          </block>
                        </value>
                        <value name="ADD1">
                          <block type="variables_get" id="4R$*aP-tIeoXAU7-OHcp">
                            <field name="VAR" id="^u_U-Az-`mhCz~(F_#oT">text</field>
                          </block>
                        </value>
                        <value name="ADD2">
                          <block type="text" id="3Nljk,tpV27x(#;V?7mB">
                            <field name="TEXT"> &lt;/table&gt;</field>
                          </block>
                        </value>
                      </block>
                    </value>
                  </block>
                </next>
              </block>
            </next>
          </block>
        </next>
      </block>
    </statement>
  </block>
</xml>

Im letzten Text erstellen Block findet Ihr im ersten Textbereich mehrnals was von "th width=......", dort könnt Ihr die Spaltenbreiten an eure Bedürfnisse anpassen. Wenn dort nur eine Zahl steht gebt Ihr Pixel an, mit einem % die Spaltenbreite in %.

(C) by David G. (https://forum.iobroker.net/user/david-g)