OctoPrint in den ioBroker integrieren

Mit ** gekennzeichnete Links auf dieser Seite sind Affiliatelinks.

OctoPrint in den ioBroker integrieren
OctoPrint in den ioBroker integrieren
  • Matthias Kleine
  • 25.11.2020
  • Integration
  • Blockly
  • Hardware

Nun habe ich schon viele Jahre OctoPrint im Einsatz. Leider gab es bis dato keine Integration von OctoPrint in den ioBroker. Diese Lücke habe ich mit einem neuen Adapter geschlossen. Natürlich möchte ich Dir nun nicht vorenthalten, wie man die Integration realisiert, welche Möglichkeiten man mit dem Adapter hat und ich zeige Dir einige Anwendungsbeispiele mit Blockly, wie man mit diesen Daten dann weiter arbeiten kann. So senden wir uns zum Beipspiel regelmäßig den Druckfortschritt per Telegram. Inklusive Live-Foto vom der angeschlossenen Kamera natürlich.

Video

ioBroker-Kurs

Blockly-Script

Das Blockly-Script aus dem Video kannst Du hier einfach kopieren und importieren.

<xml xmlns="https://developers.google.com/blockly/xml">
  <variables>
    <variable type="timeout" id="5">5</variable>
    <variable id="B~BTO*6q5Agv5`texS#)">isPrinting</variable>
    <variable id="g)X^C;6zD#$ZYdE[~mkN">lastInfoAtPercent</variable>
    <variable type="timeout" id="timeout">timeout</variable>
  </variables>
  <block type="comment" id="pe[o0]cEqUSGp+)-pgqJ" x="63" y="162">
    <field name="COMMENT">Beispiel Start-Routine</field>
    <next>
      <block type="on" id="cEpZ[ZkcOKlr:c{QFo:K">
        <field name="OID">Object ID</field>
        <field name="CONDITION">ne</field>
        <field name="ACK_CONDITION"></field>
        <statement name="STATEMENT">
          <block type="controls_if" id=":O7M!DnFd4%w.u@v3}^J">
            <value name="IF0">
              <block type="on_source" id="qPMITDkMtIF,cPB(6y)#">
                <field name="ATTR">state.val</field>
              </block>
            </value>
            <statement name="DO0">
              <block type="timeouts_settimeout" id="|WA}Q[aOyW+wRmOhBs]x">
                <field name="NAME">5</field>
                <field name="DELAY">1000</field>
                <field name="UNIT">sec</field>
                <statement name="STATEMENT">
                  <block type="control" id="uVwMd_u+_kEzvx-9u+Hp">
                    <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                    <field name="OID">octoprint.0.command.printer</field>
                    <field name="WITH_DELAY">FALSE</field>
                    <value name="VALUE">
                      <block type="text" id="|`Tjm4};c.7~4-yB95R~">
                        <field name="TEXT">connect</field>
                      </block>
                    </value>
                    <next>
                      <block type="control" id="*O{6~e+.av(1O@%Wyins">
                        <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="true"></mutation>
                        <field name="OID">octoprint.0.command.system</field>
                        <field name="WITH_DELAY">TRUE</field>
                        <field name="DELAY_MS">5</field>
                        <field name="UNIT">sec</field>
                        <field name="CLEAR_RUNNING">FALSE</field>
                        <value name="VALUE">
                          <block type="text" id="T7h5KziKN]X!0`@|Y]tW">
                            <field name="TEXT">custom/streamon</field>
                          </block>
                        </value>
                        <next>
                          <block type="control" id="o*HlP}/Tz`v,X:lfJx6E">
                            <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="true"></mutation>
                            <field name="OID">octoprint.0.command.printer</field>
                            <field name="WITH_DELAY">TRUE</field>
                            <field name="DELAY_MS">10</field>
                            <field name="UNIT">sec</field>
                            <field name="CLEAR_RUNNING">FALSE</field>
                            <value name="VALUE">
                              <block type="text" id="{)u5eUZbOzLHB$]nrIWq">
                                <field name="TEXT">home</field>
                              </block>
                            </value>
                          </block>
                        </next>
                      </block>
                    </next>
                  </block>
                </statement>
              </block>
            </statement>
          </block>
        </statement>
        <next>
          <block type="comment" id="-ns$YB{SR1o,}0Xpr8q}">
            <field name="COMMENT">Logik Druckfortschritt</field>
            <next>
              <block type="variables_set" id="|{LG=OM0tur(@h,p,|Q|">
                <field name="VAR" id="B~BTO*6q5Agv5`texS#)">isPrinting</field>
                <value name="VALUE">
                  <block type="logic_boolean" id="j;$Ecx@(apb0`yc2oZ`l">
                    <field name="BOOL">FALSE</field>
                  </block>
                </value>
                <next>
                  <block type="variables_set" id="L2HPIkUEpA@9/O~*{Y5K">
                    <field name="VAR" id="g)X^C;6zD#$ZYdE[~mkN">lastInfoAtPercent</field>
                    <value name="VALUE">
                      <block type="math_number" id="Jz!-X^a02.b+ZcWm3HL~">
                        <field name="NUM">0</field>
                      </block>
                    </value>
                    <next>
                      <block type="on" id="X#+#~Dh#5.#]T/in_!SC">
                        <field name="OID">octoprint.0.printer_status</field>
                        <field name="CONDITION">ne</field>
                        <field name="ACK_CONDITION"></field>
                        <statement name="STATEMENT">
                          <block type="controls_if" id="Bn#)|?v8r_h@F=}NQgx5">
                            <mutation elseif="1"></mutation>
                            <value name="IF0">
                              <block type="logic_compare" id="2o8FN/9t-F2;3I`l={tk">
                                <field name="OP">EQ</field>
                                <value name="A">
                                  <block type="on_source" id="jSH90aRl%L4ve`=q(pP,">
                                    <field name="ATTR">state.val</field>
                                  </block>
                                </value>
                                <value name="B">
                                  <block type="text" id="h_KcctQ[iVpVCYx@=HSy">
                                    <field name="TEXT">Printing</field>
                                  </block>
                                </value>
                              </block>
                            </value>
                            <statement name="DO0">
                              <block type="variables_set" id="o6cFpItF!WAr9Ttrzh)F">
                                <field name="VAR" id="B~BTO*6q5Agv5`texS#)">isPrinting</field>
                                <value name="VALUE">
                                  <block type="logic_boolean" id="hT1^!N/!OfkN2FU-;m9z">
                                    <field name="BOOL">TRUE</field>
                                  </block>
                                </value>
                                <next>
                                  <block type="telegram" id="3EDc=4v[=qflZt}op1oj">
                                    <field name="INSTANCE">.0</field>
                                    <field name="LOG"></field>
                                    <field name="SILENT">FALSE</field>
                                    <field name="PARSEMODE">default</field>
                                    <value name="MESSAGE">
                                      <shadow type="text" id="JNLY{Lz2DsH%%4i:af5^">
                                        <field name="TEXT"></field>
                                      </shadow>
                                      <block type="text" id="HNUYK}~{hKH-6Ffe]Yod">
                                        <field name="TEXT">3D-Druck gestartet.</field>
                                      </block>
                                    </value>
                                  </block>
                                </next>
                              </block>
                            </statement>
                            <value name="IF1">
                              <block type="logic_operation" id="`c-vF{+#Svmut)a09KJ|" inline="false">
                                <field name="OP">AND</field>
                                <value name="A">
                                  <block type="variables_get" id="Kv-6F~D!0+Y1*_vx)-^F">
                                    <field name="VAR" id="B~BTO*6q5Agv5`texS#)">isPrinting</field>
                                  </block>
                                </value>
                                <value name="B">
                                  <block type="logic_compare" id="1tx@(|z},mo+{_OFGT2F">
                                    <field name="OP">EQ</field>
                                    <value name="A">
                                      <block type="on_source" id="mH5ESV=OHvaP}ixfm0J@">
                                        <field name="ATTR">oldState.val</field>
                                      </block>
                                    </value>
                                    <value name="B">
                                      <block type="text" id="GT$3~9^z0rjk.Arz0*n0">
                                        <field name="TEXT">Printing</field>
                                      </block>
                                    </value>
                                  </block>
                                </value>
                              </block>
                            </value>
                            <statement name="DO1">
                              <block type="variables_set" id="(pU#oa4qaFuk.]Ahb7m2">
                                <field name="VAR" id="B~BTO*6q5Agv5`texS#)">isPrinting</field>
                                <value name="VALUE">
                                  <block type="logic_boolean" id="36G^[Jiz*y9tr*]E+k2f">
                                    <field name="BOOL">FALSE</field>
                                  </block>
                                </value>
                                <next>
                                  <block type="variables_set" id="g)E13AS!RhE%+iqI;;;V">
                                    <field name="VAR" id="g)X^C;6zD#$ZYdE[~mkN">lastInfoAtPercent</field>
                                    <value name="VALUE">
                                      <block type="math_number" id="iP_}[i,F2}?oOoxEFDsV">
                                        <field name="NUM">0</field>
                                      </block>
                                    </value>
                                    <next>
                                      <block type="telegram" id="!jhuWtiwf57m}OiMg3|N">
                                        <field name="INSTANCE">.0</field>
                                        <field name="LOG"></field>
                                        <field name="SILENT">FALSE</field>
                                        <field name="PARSEMODE">default</field>
                                        <value name="MESSAGE">
                                          <shadow type="text">
                                            <field name="TEXT"></field>
                                          </shadow>
                                          <block type="text" id="!mK7m$5C#ey^X/R5wV3J">
                                            <field name="TEXT">3D-Druck beendet.</field>
                                          </block>
                                        </value>
                                        <next>
                                          <block type="timeouts_settimeout" id="hfD-?U$^U3ZUJLV%f*Gk">
                                            <field name="NAME">timeout</field>
                                            <field name="DELAY">30</field>
                                            <field name="UNIT">sec</field>
                                            <statement name="STATEMENT">
                                              <block type="control" id="^7p%pSf(u){jBLR5kRW/">
                                                <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                                <field name="OID">octoprint.0.command.system</field>
                                                <field name="WITH_DELAY">FALSE</field>
                                                <value name="VALUE">
                                                  <block type="text" id="iU2f9{n$p=TfZviwMGEY">
                                                    <field name="TEXT">custom/streamoff</field>
                                                  </block>
                                                </value>
                                                <next>
                                                  <block type="control" id="R_3!WJ1zE5383/}jCT|9">
                                                    <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                                    <field name="OID">octoprint.0.command.printer</field>
                                                    <field name="WITH_DELAY">FALSE</field>
                                                    <value name="VALUE">
                                                      <block type="text" id="o96!=S(Fm2djw)f5ghW!">
                                                        <field name="TEXT">disconnect</field>
                                                      </block>
                                                    </value>
                                                  </block>
                                                </next>
                                              </block>
                                            </statement>
                                          </block>
                                        </next>
                                      </block>
                                    </next>
                                  </block>
                                </next>
                              </block>
                            </statement>
                          </block>
                        </statement>
                        <next>
                          <block type="on" id="TnDiOmu]3vZrB$iMY)n!">
                            <field name="OID">octoprint.0.printjob.progress.completion</field>
                            <field name="CONDITION">ne</field>
                            <field name="ACK_CONDITION"></field>
                            <statement name="STATEMENT">
                              <block type="controls_if" id="0kpu!A*#~KMJux#-J5CN">
                                <value name="IF0">
                                  <block type="logic_operation" id="1),tX~/w/:2kC}y7!#oX" inline="false">
                                    <field name="OP">AND</field>
                                    <value name="A">
                                      <block type="variables_get" id="FSEuzMqtYwjWA@vvGu_W">
                                        <field name="VAR" id="B~BTO*6q5Agv5`texS#)">isPrinting</field>
                                      </block>
                                    </value>
                                    <value name="B">
                                      <block type="logic_compare" id="N99Ug-pZWbqG]RlWc|Py">
                                        <field name="OP">GTE</field>
                                        <value name="A">
                                          <block type="math_arithmetic" id="qG|UO8#j^^WG(!/AasdL">
                                            <field name="OP">MINUS</field>
                                            <value name="A">
                                              <shadow type="math_number" id=";eJ0~2?bH~I)]dS0xLYH">
                                                <field name="NUM">1</field>
                                              </shadow>
                                              <block type="on_source" id="afCFkAZlpQ#b3g.i,5FW">
                                                <field name="ATTR">state.val</field>
                                              </block>
                                            </value>
                                            <value name="B">
                                              <shadow type="math_number" id="^RG14OX46#I,iwqo^!o*">
                                                <field name="NUM">0</field>
                                              </shadow>
                                              <block type="variables_get" id="}?F#QPX2~NRB/`cG]ief">
                                                <field name="VAR" id="g)X^C;6zD#$ZYdE[~mkN">lastInfoAtPercent</field>
                                              </block>
                                            </value>
                                          </block>
                                        </value>
                                        <value name="B">
                                          <block type="math_number" id="-n8NH%jtZa/TwI.R}9{-">
                                            <field name="NUM">5</field>
                                          </block>
                                        </value>
                                      </block>
                                    </value>
                                  </block>
                                </value>
                                <statement name="DO0">
                                  <block type="variables_set" id="L$lX?A+V!e-/3(B{pz97">
                                    <field name="VAR" id="g)X^C;6zD#$ZYdE[~mkN">lastInfoAtPercent</field>
                                    <value name="VALUE">
                                      <block type="on_source" id="T4*-thYBGkgB_^N?Aynf">
                                        <field name="ATTR">state.val</field>
                                      </block>
                                    </value>
                                    <next>
                                      <block type="exec" id="OpqK[l4gHXxabO~H0L1%">
                                        <mutation xmlns="http://www.w3.org/1999/xhtml" with_statement="true"></mutation>
                                        <field name="WITH_STATEMENT">TRUE</field>
                                        <field name="LOG">log</field>
                                        <value name="COMMAND">
                                          <shadow type="text" id="DhTl5ey`j:glq7,li`KC">
                                            <field name="TEXT">wget -q -O /opt/iobroker/iobroker-data/octoprint.snap.jpg "http://127.0.0.1:8080/?action=snapshot"</field>
                                          </shadow>
                                        </value>
                                        <statement name="STATEMENT">
                                          <block type="telegram" id="}iw[UKk~W#44W71:,(8}">
                                            <field name="INSTANCE">.0</field>
                                            <field name="LOG"></field>
                                            <field name="SILENT">FALSE</field>
                                            <field name="PARSEMODE">default</field>
                                            <value name="MESSAGE">
                                              <shadow type="text" id="apT2WiTJT_#u7S(D.e,m">
                                                <field name="TEXT"></field>
                                              </shadow>
                                              <block type="text_join" id="rbt$dsl9Q)flp+ZJvM8R">
                                                <mutation items="3"></mutation>
                                                <value name="ADD0">
                                                  <block type="text" id="%d/jI57,EX1K-0+B?8QH">
                                                    <field name="TEXT">Druckfortschritt: </field>
                                                  </block>
                                                </value>
                                                <value name="ADD1">
                                                  <block type="on_source" id="_a8=42F0RTs6q:[@(~15">
                                                    <field name="ATTR">state.val</field>
                                                  </block>
                                                </value>
                                                <value name="ADD2">
                                                  <block type="text" id="%M#C]VlT^B`i/HB:y@ym">
                                                    <field name="TEXT">%</field>
                                                  </block>
                                                </value>
                                              </block>
                                            </value>
                                            <next>
                                              <block type="telegram" id="n3lYyXcBGr_CKd(-7aX,">
                                                <field name="INSTANCE">.0</field>
                                                <field name="LOG"></field>
                                                <field name="SILENT">FALSE</field>
                                                <field name="PARSEMODE">default</field>
                                                <value name="MESSAGE">
                                                  <shadow type="text" id="y(Rj8#$;.:IVFUm,.WF~">
                                                    <field name="TEXT">/opt/iobroker/iobroker-data/octoprint.snap.jpg</field>
                                                  </shadow>
                                                </value>
                                              </block>
                                            </next>
                                          </block>
                                        </statement>
                                      </block>
                                    </next>
                                  </block>
                                </statement>
                              </block>
                            </statement>
                          </block>
                        </next>
                      </block>
                    </next>
                  </block>
                </next>
              </block>
            </next>
          </block>
        </next>
      </block>
    </next>
  </block>
</xml>
Ich will mehr

Smart-Home-Training von A-Z

Steig noch tiefer in die Themen ein und meistere Deine Projekte!

ioBroker-Master-Kurs

ioBroker-Master-Kurs

Mehr Infos
NodeRed-Kurs

NodeRed-Kurs

Mehr Infos
Lox-Kurs

Lox-Kurs

Mehr Infos
FHEM-Kurs

FHEM-Kurs

Mehr Infos