Divera-script2

From
Revision as of 20:55, 8 February 2021 by Tobias (talk | contribs) (Blockly Skript)
Jump to: navigation, search

Voraussetzung

IoBroker Adapter:

IoT Cloud Adapter[1]

Java Skript[2]


Anmeldungen: (ein Account benötigt)

IoBroker pro (kostenlos unter bestimmten Rahmenbedingungen) [3]


Übersicht

Divera-Webhook sendet bei Alarm eine JSON Datei an den IoT-Adapter über ein Blockly Skript (siehe unten) werden die Einsatzdaten aufgelöst und in Datenpunkte geschrieben.




Einstellung IoT-Adapter

Iotadapter.png


Benutzername und Passwort aus der Iobroker.pro Registrierung eingeben.

Adapter starten.



Configiotadapter.png


1. Button "Neuen Service URL-Schlüssel abrufen"

2. Dienst hinzufügen: ein * eingeben und auf das + um den Dienst hinzuzufügen.

3. Den unteren Service Link in eine Editor kopieren.

4. Speichern und Schließen




Bearbeitenlink.png


Die eckigen Klammern durch entsprechenden Namen ersetzen ich habe bei mir divera und alarm verwendet.



Einstellungen in DIVERA

Diveralinkjson.png


Den Link aus dem Editor in URL / Ziel einfügen.

Format: POST application/json

Inhalt: Vollständiges Objekt


Blockly Skript

Zurück in Iobroker, neues Blockly Skript anlegen.


Blocklydivera.png


Einfach dieses Skript über den Button "Blöcke importieren" anlegen.

<xml xmlns="https://developers.google.com/blockly/xml">

 <variables>
   <variable id="|G[Y+bO,EA0kt?b(?K0(">Json_Divera</variable>
   <variable id="yq+XTG%9ZF0a{qA]0R}r">Stichwort</variable>
   <variable id="Ba(%G8@6W=~:(iz~q*kc">Group_Nr</variable>
   <variable id="EF)$x9H7HRf?/+^9CZs8">text</variable>
   <variable id="eKF!XB#($U+UWftcAq!j">adresse</variable>
   <variable id="=2de~$lYnQHb2O{/:5r$">prio</variable>
   <variable id="Xxd~mw/Ltnh$r?AzqM?v">Liste</variable>
   <variable id="?rw*g?W9fI{:iLw)qJ5)">AnzahlText</variable>
 </variables>
 <block type="on" id=",Z@@D}%DNp!Wo8)D}=*3" x="-937" y="-63">
   <field name="OID">iot.0.services.custom_divera</field>
   <field name="CONDITION">ne</field>
   <field name="ACK_CONDITION"></field>
   <comment pinned="false" h="80" w="160">Datenpunkt aus dem IOT Adapter </comment>
   <statement name="STATEMENT">
     <block type="comment" id="6#f4{)jYo-=LovphYFC*">
       <field name="COMMENT">Datenpunkt im Trigger und "Wert" vom Objekt auf den JSON Datenpunkt aus dem IOT Adapter setzten </field>
       <next>
         <block type="variables_set" id="DO_%`5Fz%l-]E!nWklca">
           <field name="VAR" id="|G[Y+bO,EA0kt?b(?K0(">Json_Divera</field>
           <value name="VALUE">
             <block type="convert_json2object" id="SFrsNk|8l!d[7:D9`sRs">
               <value name="VALUE">
                 <block type="get_value" id="BUYhmzC+D+9Bzv19nlrs">
                   <field name="ATTR">val</field>
                   <field name="OID">iot.0.services.custom_divera</field>
                   <comment pinned="false" h="80" w="160">Datenpunkt aus dem IOT Adapter </comment>
                 </block>
               </value>
             </block>
           </value>
           <next>
             <block type="debug" id="]S]xvd8kj3gMfn6(;@i:">
               <field name="Severity">log</field>
               <value name="TEXT">
                 <shadow type="text">
                   <field name="TEXT">test</field>
                 </shadow>
                 <block type="convert_jsonata" id="e=W#)PIL.rU8:JxXP*iv">
                   <value name="EXPRESSION">
                     <shadow type="text" id="Ll7oN3UMU9-_.~pQ8eGG">
                       <field name="TEXT">*</field>
                     </shadow>
                   </value>
                   <value name="TARGET">
                     <block type="variables_get" id="oZ0kgGzi.5#x-Fg])nzd">
                       <field name="VAR" id="|G[Y+bO,EA0kt?b(?K0(">Json_Divera</field>
                     </block>
                   </value>
                 </block>
               </value>
               <next>
                 <block type="comment" id="j_G,ua`=ofN_yWTQI~I!">
                   <field name="COMMENT">Auswertung der JSON</field>
                   <next>
                     <block type="variables_set" id="oNUr3L$49X3RtnA-;c?9">
                       <field name="VAR" id="yq+XTG%9ZF0a{qA]0R}r">Stichwort</field>
                       <value name="VALUE">
                         <block type="convert_jsonata" id="LFzrwZD(GGiG]i=4(Gn!">
                           <value name="EXPRESSION">
                             <shadow type="text" id="h4+*G:H^UxHBjd758zu$">
                               <field name="TEXT">title [0]</field>
                             </shadow>
                           </value>
                           <value name="TARGET">
                             <block type="variables_get" id="p0{]--*@,c9:hwa9WJ4W">
                               <field name="VAR" id="|G[Y+bO,EA0kt?b(?K0(">Json_Divera</field>
                             </block>
                           </value>
                         </block>
                       </value>
                       <next>
                         <block type="variables_set" id="lCAt{HFw6Lk{@Go+Ys#^">
                           <field name="VAR" id="Ba(%G8@6W=~:(iz~q*kc">Group_Nr</field>
                           <value name="VALUE">
                             <block type="convert_jsonata" id="aL??h/H9KPTKm$)NmAu~">
                               <value name="EXPRESSION">
                                 <shadow type="text" id="Pel~c|ap1isx(LG{/?hb">
                                   <field name="TEXT">group[0]</field>
                                 </shadow>
                               </value>
                               <value name="TARGET">
                                 <block type="variables_get" id=",0K)Gk(^U69WsU$m413=">
                                   <field name="VAR" id="|G[Y+bO,EA0kt?b(?K0(">Json_Divera</field>
                                 </block>
                               </value>
                             </block>
                           </value>
                           <next>
                             <block type="variables_set" id="bmgY/}Qr-2;RAd%6dkZD">
                               <field name="VAR" id="EF)$x9H7HRf?/+^9CZs8">text</field>
                               <value name="VALUE">
                                 <block type="convert_jsonata" id="MvlDF3xcp%CGxsm)iPXg">
                                   <value name="EXPRESSION">
                                     <shadow type="text" id="/mdP3%:@tqs:P,g8bbc(">
                                       <field name="TEXT">text [0]</field>
                                     </shadow>
                                   </value>
                                   <value name="TARGET">
                                     <block type="variables_get" id=".}dq$r#t)wNi`+!8L(r{">
                                       <field name="VAR" id="|G[Y+bO,EA0kt?b(?K0(">Json_Divera</field>
                                     </block>
                                   </value>
                                 </block>
                               </value>
                               <next>
                                 <block type="variables_set" id="MKfz^4jk%BlET*]EVV5U">
                                   <field name="VAR" id="eKF!XB#($U+UWftcAq!j">adresse</field>
                                   <value name="VALUE">
                                     <block type="convert_jsonata" id="QM=DDGXLz-#KE6eIv^`E">
                                       <value name="EXPRESSION">
                                         <shadow type="text" id="wFiWl?P|Ey5P5aG/pIh#">
                                           <field name="TEXT">address [0]</field>
                                         </shadow>
                                       </value>
                                       <value name="TARGET">
                                         <block type="variables_get" id="m^1[-yf)iB3pu/O4k*IL">
                                           <field name="VAR" id="|G[Y+bO,EA0kt?b(?K0(">Json_Divera</field>
                                         </block>
                                       </value>
                                     </block>
                                   </value>
                                   <next>
                                     <block type="variables_set" id="6nU@HHq`FQ/AQPx|E-t5">
                                       <field name="VAR" id="=2de~$lYnQHb2O{/:5r$">prio</field>
                                       <value name="VALUE">
                                         <block type="convert_jsonata" id="cG4K++qtBK$cWDBS,K3A">
                                           <value name="EXPRESSION">
                                             <shadow type="text" id="i]H1Q8wtH~A[Yt?BMv#[">
                                               <field name="TEXT">priority [0]</field>
                                             </shadow>
                                           </value>
                                           <value name="TARGET">
                                             <block type="variables_get" id="jN-f#$GabIL1Vzt34W$9">
                                               <field name="VAR" id="|G[Y+bO,EA0kt?b(?K0(">Json_Divera</field>
                                             </block>
                                           </value>
                                         </block>
                                       </value>
                                       <next>
                                         <block type="comment" id="0wN{D:Br2K,G[jG,Y.DY">
                                           <field name="COMMENT">Folgende Datenpunkte müssen Erstellt werden analog zu den Variablen </field>
                                           <next>
                                             <block type="update" id=";{fL8_PkBzUsb~6x{220">
                                               <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                               <field name="OID">0_userdata.0.DIVERA_24/7.Stichwort</field>
                                               <field name="WITH_DELAY">FALSE</field>
                                               <value name="VALUE">
                                                 <block type="variables_get" id="S#m;l3oY4ESNTC6+x8tR">
                                                   <field name="VAR" id="yq+XTG%9ZF0a{qA]0R}r">Stichwort</field>
                                                 </block>
                                               </value>
                                               <next>
                                                 <block type="update" id="W~5@v#a$YlvDUWg4}qu}">
                                                   <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                                   <field name="OID">0_userdata.0.DIVERA_24/7.Priorität</field>
                                                   <field name="WITH_DELAY">FALSE</field>
                                                   <value name="VALUE">
                                                     <block type="variables_get" id="3I@]4lc;f`IY#aEc)@OC">
                                                       <field name="VAR" id="=2de~$lYnQHb2O{/:5r$">prio</field>
                                                     </block>
                                                   </value>
                                                   <next>
                                                     <block type="update" id="fAO,_M%v%cOqP8Pv?-^?">
                                                       <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                                       <field name="OID">0_userdata.0.DIVERA_24/7.Text</field>
                                                       <field name="WITH_DELAY">FALSE</field>
                                                       <value name="VALUE">
                                                         <block type="variables_get" id="2!uVgq;WS1|s@{-72Q?E">
                                                           <field name="VAR" id="EF)$x9H7HRf?/+^9CZs8">text</field>
                                                         </block>
                                                       </value>
                                                       <next>
                                                         <block type="update" id="iQ:UKD*x}vAJ-d[#fo9o">
                                                           <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                                           <field name="OID">0_userdata.0.DIVERA_24/7.Adresse</field>
                                                           <field name="WITH_DELAY">FALSE</field>
                                                           <value name="VALUE">
                                                             <block type="variables_get" id="HCb=.n^gBaj0vr2u7(l/">
                                                               <field name="VAR" id="eKF!XB#($U+UWftcAq!j">adresse</field>
                                                             </block>
                                                           </value>
                                                           <next>
                                                             <block type="comment" id="D#q^YUJ*gAGa:d/ew8#6">
                                                               <field name="COMMENT">Auflösen der Adresse </field>
                                                               <next>
                                                                 <block type="variables_set" id="-NCVvS,sjMGAeMgclnB}">
                                                                   <field name="VAR" id="Xxd~mw/Ltnh$r?AzqM?v">Liste</field>
                                                                   <value name="VALUE">
                                                                     <block type="lists_split" id="Y6Un+S?%7dIL4{U]AWnM">
                                                                       <mutation mode="SPLIT"></mutation>
                                                                       <field name="MODE">SPLIT</field>
                                                                       <value name="INPUT">
                                                                         <block type="variables_get" id="DtBgntHdy5?Sh|*%7^Z^">
                                                                           <field name="VAR" id="eKF!XB#($U+UWftcAq!j">adresse</field>
                                                                         </block>
                                                                       </value>
                                                                       <value name="DELIM">
                                                                         <shadow type="text" id="Aeo~5~UN!Mz.(;{)g|$T">
                                                                           <field name="TEXT">, </field>
                                                                         </shadow>
                                                                       </value>
                                                                     </block>
                                                                   </value>
                                                                   <next>
                                                                     <block type="variables_set" id="[$xbg!p*D@@HGCp.}FLG">
                                                                       <field name="VAR" id="?rw*g?W9fI{:iLw)qJ5)">AnzahlText</field>
                                                                       <value name="VALUE">
                                                                         <block type="lists_length" id="-dlK`d1T?|/VXP$fo48%">
                                                                           <value name="VALUE">
                                                                             <block type="variables_get" id="[[vt@|dd42~2`,?!vDEK">
                                                                               <field name="VAR" id="Xxd~mw/Ltnh$r?AzqM?v">Liste</field>
                                                                             </block>
                                                                           </value>
                                                                         </block>
                                                                       </value>
                                                                       <next>
                                                                         <block type="update" id="Lht,Mg79xwt@7q~6.{HV">
                                                                           <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                                                           <field name="OID">0_userdata.0.DIVERA_24/7.Adress_Anzahl</field>
                                                                           <field name="WITH_DELAY">FALSE</field>
                                                                           <value name="VALUE">
                                                                             <block type="variables_get" id="ox)kN/$iEPx0S)QCEI6.">
                                                                               <field name="VAR" id="?rw*g?W9fI{:iLw)qJ5)">AnzahlText</field>
                                                                             </block>
                                                                           </value>
                                                                           <next>
                                                                             <block type="controls_if" id="H](3U+rZ~UuR`P)od6Xd">
                                                                               <mutation elseif="2"></mutation>
                                                                               <value name="IF0">
                                                                                 <block type="logic_compare" id="DALlOHOs:`]UHuZ6kqSj">
                                                                                   <field name="OP">EQ</field>
                                                                                   <value name="A">
                                                                                     <block type="variables_get" id="g?kT)K=ThFK`33;Bx?s5">
                                                                                       <field name="VAR" id="?rw*g?W9fI{:iLw)qJ5)">AnzahlText</field>
                                                                                     </block>
                                                                                   </value>
                                                                                   <value name="B">
                                                                                     <block type="math_number" id="[_kX+#9vL3O0-XxVLxi$">
                                                                                       <field name="NUM">1</field>
                                                                                     </block>
                                                                                   </value>
                                                                                 </block>
                                                                               </value>
                                                                               <statement name="DO0">
                                                                                 <block type="update" id="-#GlK~fBotGRQov..?/!">
                                                                                   <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                                                                   <field name="OID">0_userdata.0.DIVERA_24/7.Adress_1</field>
                                                                                   <field name="WITH_DELAY">FALSE</field>
                                                                                   <value name="VALUE">
                                                                                     <block type="lists_getIndex" id="Bi^T//M{(ad^d)FJ9pqA">
                                                                                       <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="QhRqT?C%^I)..1Y=@gEB">
                                                                                           <field name="VAR" id="Xxd~mw/Ltnh$r?AzqM?v">Liste</field>
                                                                                         </block>
                                                                                       </value>
                                                                                       <value name="AT">
                                                                                         <block type="math_number" id="!PqH[%Ttk~|]U9H8l,8r">
                                                                                           <field name="NUM">1</field>
                                                                                         </block>
                                                                                       </value>
                                                                                     </block>
                                                                                   </value>
                                                                                 </block>
                                                                               </statement>
                                                                               <value name="IF1">
                                                                                 <block type="logic_compare" id="cyd%ujNx*;h`5@2W})YT">
                                                                                   <field name="OP">EQ</field>
                                                                                   <value name="A">
                                                                                     <block type="variables_get" id="4FE8b5]j+x$5=V8;|4B?">
                                                                                       <field name="VAR" id="?rw*g?W9fI{:iLw)qJ5)">AnzahlText</field>
                                                                                     </block>
                                                                                   </value>
                                                                                   <value name="B">
                                                                                     <block type="math_number" id="b?P;j*_e)ilrDEREjO;[">
                                                                                       <field name="NUM">2</field>
                                                                                     </block>
                                                                                   </value>
                                                                                 </block>
                                                                               </value>
                                                                               <statement name="DO1">
                                                                                 <block type="update" id="b`-e=,((3!j0uTI6ArQk">
                                                                                   <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                                                                   <field name="OID">0_userdata.0.DIVERA_24/7.Adress_1</field>
                                                                                   <field name="WITH_DELAY">FALSE</field>
                                                                                   <value name="VALUE">
                                                                                     <block type="lists_getIndex" id=")ez3`*jSOhXieI9JEd]%">
                                                                                       <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="{WQl_w=4(9UdlFX_65]V">
                                                                                           <field name="VAR" id="Xxd~mw/Ltnh$r?AzqM?v">Liste</field>
                                                                                         </block>
                                                                                       </value>
                                                                                       <value name="AT">
                                                                                         <block type="math_number" id=".1O+RPd1,|ReeH:@#OuW">
                                                                                           <field name="NUM">1</field>
                                                                                         </block>
                                                                                       </value>
                                                                                     </block>
                                                                                   </value>
                                                                                   <next>
                                                                                     <block type="update" id="y)7CqtXWc0=rHt(6!SS,">
                                                                                       <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                                                                       <field name="OID">0_userdata.0.DIVERA_24/7.Adress_2</field>
                                                                                       <field name="WITH_DELAY">FALSE</field>
                                                                                       <value name="VALUE">
                                                                                         <block type="lists_getIndex" id="(W)MRMkd,bNzbcN+*K/4">
                                                                                           <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="0phE2j5q$ew(-b4C:2r(">
                                                                                               <field name="VAR" id="Xxd~mw/Ltnh$r?AzqM?v">Liste</field>
                                                                                             </block>
                                                                                           </value>
                                                                                           <value name="AT">
                                                                                             <block type="math_number" id="0++Ja?2nMTO9mNMEq^k[">
                                                                                               <field name="NUM">2</field>
                                                                                             </block>
                                                                                           </value>
                                                                                         </block>
                                                                                       </value>
                                                                                     </block>
                                                                                   </next>
                                                                                 </block>
                                                                               </statement>
                                                                               <value name="IF2">
                                                                                 <block type="logic_compare" id="Cy{6%.23%A!+P(*6:2[k">
                                                                                   <field name="OP">EQ</field>
                                                                                   <value name="A">
                                                                                     <block type="variables_get" id="(tcO[k,?x9l`k*q)m25}">
                                                                                       <field name="VAR" id="?rw*g?W9fI{:iLw)qJ5)">AnzahlText</field>
                                                                                     </block>
                                                                                   </value>
                                                                                   <value name="B">
                                                                                     <block type="math_number" id=")I{k!2puDs3YK~piu:0|">
                                                                                       <field name="NUM">3</field>
                                                                                     </block>
                                                                                   </value>
                                                                                 </block>
                                                                               </value>
                                                                               <statement name="DO2">
                                                                                 <block type="update" id="/P{p/UNNt1u6}!qJ`6^A">
                                                                                   <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                                                                   <field name="OID">0_userdata.0.DIVERA_24/7.Adress_1</field>
                                                                                   <field name="WITH_DELAY">FALSE</field>
                                                                                   <value name="VALUE">
                                                                                     <block type="lists_getIndex" id="BS1u-,;94.Xw=O4}{5xT">
                                                                                       <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="EkiTBW95$~l(jY,OF}Ew">
                                                                                           <field name="VAR" id="Xxd~mw/Ltnh$r?AzqM?v">Liste</field>
                                                                                         </block>
                                                                                       </value>
                                                                                       <value name="AT">
                                                                                         <block type="math_number" id="$^*(ne!7bVI;2zs~59j-">
                                                                                           <field name="NUM">1</field>
                                                                                         </block>
                                                                                       </value>
                                                                                     </block>
                                                                                   </value>
                                                                                   <next>
                                                                                     <block type="update" id="FL:Xkr)#c00k-^(ej8t^">
                                                                                       <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                                                                       <field name="OID">0_userdata.0.DIVERA_24/7.Adress_2</field>
                                                                                       <field name="WITH_DELAY">FALSE</field>
                                                                                       <value name="VALUE">
                                                                                         <block type="lists_getIndex" id="aiyooD?`Nz=]BA]la.f_">
                                                                                           <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="g.8eBKQ/LwPzF0/o:+~M">
                                                                                               <field name="VAR" id="Xxd~mw/Ltnh$r?AzqM?v">Liste</field>
                                                                                             </block>
                                                                                           </value>
                                                                                           <value name="AT">
                                                                                             <block type="math_number" id="}l9+|GT^%EJ3o=!t%7U~">
                                                                                               <field name="NUM">2</field>
                                                                                             </block>
                                                                                           </value>
                                                                                         </block>
                                                                                       </value>
                                                                                       <next>
                                                                                         <block type="update" id="Ikv2cK$LpnJ#Kj:(F6Xz">
                                                                                           <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation>
                                                                                           <field name="OID">0_userdata.0.DIVERA_24/7.Adress_3</field>
                                                                                           <field name="WITH_DELAY">FALSE</field>
                                                                                           <value name="VALUE">
                                                                                             <block type="lists_getIndex" id="_O?cRqOCDLp@xsnf~bK9">
                                                                                               <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="SdXl|40!c4zg1hh6o@$#">
                                                                                                   <field name="VAR" id="Xxd~mw/Ltnh$r?AzqM?v">Liste</field>
                                                                                                 </block>
                                                                                               </value>
                                                                                               <value name="AT">
                                                                                                 <block type="math_number" id="zo6IA%,YBHThe(tPBzHV">
                                                                                                   <field name="NUM">3</field>
                                                                                                 </block>
                                                                                               </value>
                                                                                             </block>
                                                                                           </value>
                                                                                         </block>
                                                                                       </next>
                                                                                     </block>
                                                                                   </next>
                                                                                 </block>
                                                                               </statement>
                                                                             </block>
                                                                           </next>
                                                                         </block>
                                                                       </next>
                                                                     </block>
                                                                   </next>
                                                                 </block>
                                                               </next>
                                                             </block>
                                                           </next>
                                                         </block>
                                                       </next>
                                                     </block>
                                                   </next>
                                                 </block>
                                               </next>
                                             </block>
                                           </next>
                                         </block>
                                       </next>
                                     </block>
                                   </next>
                                 </block>
                               </next>
                             </block>
                           </next>
                         </block>
                       </next>
                     </block>
                   </next>
                 </block>
               </next>
             </block>
           </next>
         </block>
       </next>
     </block>
   </statement>
 </block>

</xml>