- Home
- Deutsch
- Skripten / Logik
- Blockly
- Fenster, Lichter zählen
Fenster, Lichter zählen
-
Hallo,
ich möchte gerne in VIS angezeigt bekommen, welche Fenster auf/ Lichter an/... sind. Ich möchte das gerne mit Blockly lösen. Folgendes Blockly funktioniert nicht. Würde bitte jemand drüber schauen und mir einen Hinweis geben, woran es liegt? Ich habe hier das ganze für 1 Fenster erst einmal gestetet. Bei mehreren Fenstern müssen diese ja nur in den Trigger oben mit eingefügt werden?!
<xml xmlns="https://developers.google.com/blockly/xml"> <variables> <variable id="~Wi-J?QUCu{;hTg#^[.!">offene Fenster</variable> <variable id="/|{Paqw|`?,RWX@dU+4f">Fenster</variable> <variable id="7%,^YwO7ma)%{YrQYW$l">Ausgabe</variable> </variables> <block type="variables_set" id="dBcitHNWr9jX:Ub;;eSd" x="-738" y="1012"> <field name="VAR" id="~Wi-J?QUCu{;hTg#^[.!">offene Fenster</field> <value name="VALUE"> <block type="math_number" id=",TX;`m#6*Sw)kXItl6tj"> <field name="NUM">0</field> </block> </value> <next> <block type="variables_set" id="lY:|ehah_#|x(f,.kJp4"> <field name="VAR" id="/|{Paqw|`?,RWX@dU+4f">Fenster</field> <value name="VALUE"> <block type="text" id="A_t@#Pw`wD]W@}^@1dSH"> <field name="TEXT"></field> </block> </value> <next> <block type="variables_set" id="_N%+5H3?my:Hhre+4o6y"> <field name="VAR" id="7%,^YwO7ma)%{YrQYW$l">Ausgabe</field> <value name="VALUE"> <block type="text" id="KA~DgX3/J*6]qxSr1#W,"> <field name="TEXT"></field> </block> </value> <next> <block type="on_ext" id="!2=2wPMi@XdSNrXB%8Mx"> <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="GhETUTkKjHhMW?%A?`s2"> <field name="oid">hm-rpc.1.00109D8995945E.1.STATE</field> </shadow> </value> <statement name="STATEMENT"> <block type="comment" id="^N8=D(eOI=/l!C;?Lh8b"> <field name="COMMENT">hier Fenster mit Wert auf/zu</field> <next> <block type="controls_if" id="f~bR/E-C}~M4[,`G.^g]"> <value name="IF0"> <block type="logic_compare" id="l.eoB-)z_`xPiIS#KS]k"> <field name="OP">EQ</field> <value name="A"> <block type="get_value" id="4d5)vAINPX=+K?.K7c*R"> <field name="ATTR">val</field> <field name="OID">hm-rpc.1.00109D8995945E.1.STATE</field> </block> </value> <value name="B"> <block type="math_number" id="05ZQNV-(nMyFIN04AS2r"> <field name="NUM">1</field> </block> </value> </block> </value> <statement name="DO0"> <block type="variables_set" id="%W#^rxs1;oiK~|#1diU!"> <field name="VAR" id="/|{Paqw|`?,RWX@dU+4f">Fenster</field> <value name="VALUE"> <block type="text_join" id="QoihJ`yiu~9^ZtpPV.sE"> <mutation items="3"></mutation> <value name="ADD0"> <block type="variables_get" id="q?QN3f(dh]:@Wlrs:!jG"> <field name="VAR" id="/|{Paqw|`?,RWX@dU+4f">Fenster</field> </block> </value> <value name="ADD1"> <block type="text_newline" id="2Ho-*A#$3@+4I}blR;0="> <field name="Type">\n</field> </block> </value> <value name="ADD2"> <block type="text" id=".#p12G6P9[[)2VQ,tM6s"> <field name="TEXT">Wohnzimmertür</field> </block> </value> </block> </value> <next> <block type="math_change" id="|dRFcN4qn*Yz~-Xa,:q6"> <field name="VAR" id="~Wi-J?QUCu{;hTg#^[.!">offene Fenster</field> <value name="DELTA"> <shadow type="math_number" id="l*`!8InCD{tXH;1_*uUw"> <field name="NUM">1</field> </shadow> </value> </block> </next> </block> </statement> <next> <block type="controls_if" id="j+GAfET~f]};UBsC}MG!"> <value name="IF0"> <block type="logic_compare" id="8a#8#;^]^!_MkUm{%r,t"> <field name="OP">EQ</field> <value name="A"> <block type="get_value" id="URR:W~^tgG.UFXDe15s:"> <field name="ATTR">val</field> <field name="OID">hm-rpc.1.00109D8995945E.1.STATE</field> </block> </value> <value name="B"> <block type="math_number" id="h*hGJ?o]?,;C42am~=E{"> <field name="NUM">0</field> </block> </value> </block> </value> <statement name="DO0"> <block type="math_change" id="Nl@x8btHp/ee]]ohT[}?"> <field name="VAR" id="~Wi-J?QUCu{;hTg#^[.!">offene Fenster</field> <value name="DELTA"> <shadow type="math_number" id="%=2,7d={.7z=/F[}z/^v"> <field name="NUM">-1</field> </shadow> </value> </block> </statement> <next> <block type="comment" id="x%xL?W(}x9hx5dr0-Y^#"> <field name="COMMENT">ab hier Ausgabe</field> <next> <block type="controls_if" id="0-taM{aJ^:NIi`N3F2XZ"> <value name="IF0"> <block type="logic_compare" id="D2j9QGB[O]]OBb[_U.?b"> <field name="OP">EQ</field> <value name="A"> <block type="variables_get" id="!6(?5?5[SH-2kh/are1c"> <field name="VAR" id="~Wi-J?QUCu{;hTg#^[.!">offene Fenster</field> </block> </value> <value name="B"> <block type="math_number" id="qRsYI27i]r-M4Jvw|B=]"> <field name="NUM">1</field> </block> </value> </block> </value> <statement name="DO0"> <block type="variables_set" id="0i[!WvfUh{zT!*g2j(:["> <field name="VAR" id="7%,^YwO7ma)%{YrQYW$l">Ausgabe</field> <value name="VALUE"> <block type="text_join" id="qP.8AfF=#Edn@F;T1:-w"> <mutation items="3"></mutation> <value name="ADD0"> <block type="text" id="mL.aZtUXq(5S4~[KsR:)"> <field name="TEXT">Es ist folgendes Fenster offen:</field> </block> </value> <value name="ADD1"> <block type="text_newline" id="zz0V,K7I-5nshar;6tPZ"> <field name="Type">\n</field> </block> </value> <value name="ADD2"> <block type="variables_get" id="khzEI~oTm`E0EHHP37W0"> <field name="VAR" id="/|{Paqw|`?,RWX@dU+4f">Fenster</field> </block> </value> </block> </value> <next> <block type="control" id="+:b%Z@9Fs@YLQH$qakNK"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">0_userdata.0.Status.EG.Fenster.Anzahl</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="variables_get" id="wi`nCEJRM!Z5hZcynAaL"> <field name="VAR" id="~Wi-J?QUCu{;hTg#^[.!">offene Fenster</field> </block> </value> <next> <block type="control" id="=Wb)!_p468d7EgoC~OrL"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">0_userdata.0.Status.EG.Fenster.Aufzählung</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="variables_get" id="vGf}v3.}=Rz,HxRWiyuI"> <field name="VAR" id="7%,^YwO7ma)%{YrQYW$l">Ausgabe</field> </block> </value> </block> </next> </block> </next> </block> </statement> <next> <block type="controls_if" id="#-7JFh(%PAhztruK[FsC"> <value name="IF0"> <block type="logic_compare" id="Q@ws+/O-eC:]gf+;6;;u"> <field name="OP">GT</field> <value name="A"> <block type="variables_get" id="Mc5q^[7=vqcp?3:v4nmx"> <field name="VAR" id="~Wi-J?QUCu{;hTg#^[.!">offene Fenster</field> </block> </value> <value name="B"> <block type="math_number" id="kmO[QfiU+XX?zbr?M)lK"> <field name="NUM">1</field> </block> </value> </block> </value> <statement name="DO0"> <block type="variables_set" id="=]9yIQ~w0v~*wAji[L57"> <field name="VAR" id="7%,^YwO7ma)%{YrQYW$l">Ausgabe</field> <value name="VALUE"> <block type="text_join" id=")T*0dl@9]J:M`Zb@JoCi"> <mutation items="2"></mutation> <value name="ADD0"> <block type="text" id="{UNAB`t47B_kMB4Gr7!V"> <field name="TEXT">Es sind folgende Fenster offen:</field> </block> </value> <value name="ADD1"> <block type="variables_get" id="shT1Vel4ni0U%KkmA8s)"> <field name="VAR" id="/|{Paqw|`?,RWX@dU+4f">Fenster</field> </block> </value> </block> </value> <next> <block type="control" id=":/QmSc[CLuu)N$=3p?z~"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">0_userdata.0.Status.EG.Fenster.Anzahl</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="variables_get" id="v7G?js@m38uh7_%[UY-w"> <field name="VAR" id="~Wi-J?QUCu{;hTg#^[.!">offene Fenster</field> </block> </value> <next> <block type="control" id="=:*.U_y5Mou]:g-KyD@J"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">0_userdata.0.Status.EG.Fenster.Aufzählung</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="variables_get" id="8265O[maB/2RuzHF;k5S"> <field name="VAR" id="7%,^YwO7ma)%{YrQYW$l">Ausgabe</field> </block> </value> </block> </next> </block> </next> </block> </statement> <next> <block type="controls_if" id="x,y#p8BGYEF=dxG6L)q3"> <value name="IF0"> <block type="logic_compare" id="%XBDxv8OG.zADMMUYt/["> <field name="OP">EQ</field> <value name="A"> <block type="variables_get" id=":IlS!t)kBRySlNGmwSi!"> <field name="VAR" id="~Wi-J?QUCu{;hTg#^[.!">offene Fenster</field> </block> </value> <value name="B"> <block type="math_number" id="HRNzo;oq;26nZO17*HJA"> <field name="NUM">0</field> </block> </value> </block> </value> <statement name="DO0"> <block type="variables_set" id="J1i^yzNnTtkFT)|l(|m-"> <field name="VAR" id="7%,^YwO7ma)%{YrQYW$l">Ausgabe</field> <value name="VALUE"> <block type="text" id="@fm3!zkB)o%-j#rZ847o"> <field name="TEXT"> Alle Fenster sind geschlossen.</field> </block> </value> <next> <block type="control" id="#!5i!.W5r2PMnOPF{e@:"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">0_userdata.0.Status.EG.Fenster.Anzahl</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="variables_get" id="O]|.D-,xEHcw;Tc!uWMJ"> <field name="VAR" id="~Wi-J?QUCu{;hTg#^[.!">offene Fenster</field> </block> </value> <next> <block type="control" id="#M[,jzbMK:nZub``i7a`"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">0_userdata.0.Status.EG.Fenster.Aufzählung</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="variables_get" id=")X.lOdjHm[S!nD|Q2HM4"> <field name="VAR" id="7%,^YwO7ma)%{YrQYW$l">Ausgabe</field> </block> </value> </block> </next> </block> </next> </block> </statement> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </statement> </block> </next> </block> </next> </block> </next> </block> </xml>
-
@jwerlsdf sagte: Bei mehreren Fenstern müssen diese ja nur in den Trigger oben mit eingefügt werden?!
Nein, man benötigt eine Schleife über eine Liste von IDs.
Es gibt hier im Forum genügend Beispiele. Bemühe mal die Suche.EDIT: Prinzip mit Selektor und einem Array mit den Kanalnamen der offenen Fenster:
Inhalt der JS-Funktion parentName(id):
id = id.substring(0, id.lastIndexOf('.')); if(existsObject(id)) return getObject(id).common.name;
-
@paul53
Vielen Dank. Leider funktioniert es bei mir nicht. Schaust du bitte noch einmal drüber? Ich gehe davon aus, dass ich die falsche JS-Funktion ausgewählt haben?<xml xmlns="https://developers.google.com/blockly/xml"> <variables> <variable id="a8Hk_)m.S#v]xOx,|g]B">ids</variable> <variable id="p8z4a0D*3/v6krF]%fZK">offen</variable> <variable id="49uXg6HLqFYWFA:qXC@Q">id</variable> <variable id="P(vzemG|?%LTz:_r9=_I">ausgabe</variable> </variables> <block type="variables_set" id="+MFQe5tZBT5!whBe|iFA" x="38" y="38"> <field name="VAR" id="a8Hk_)m.S#v]xOx,|g]B">ids</field> <value name="VALUE"> <block type="selector" id="|Y{K/}d6n@!iKbM},%LM"> <field name="TEXT">*.STATE(functions=Fenster-EG)</field> </block> </value> <next> <block type="on_ext" id="%;xKJA^hdmL.h]{^~f1^"> <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="/IZY1f-MIzB=|5jwj%X^"> <field name="oid">default</field> </shadow> <block type="variables_get" id="C!jgwb6-ylj1moU4[@-|"> <field name="VAR" id="a8Hk_)m.S#v]xOx,|g]B">ids</field> </block> </value> <statement name="STATEMENT"> <block type="variables_set" id="jw[mYBdN9^y9Dk!BPhJE"> <field name="VAR" id="p8z4a0D*3/v6krF]%fZK">offen</field> <value name="VALUE"> <block type="lists_create_with" id="`9G-Tj284acj[FYBy%rN"> <mutation items="0"></mutation> </block> </value> <next> <block type="controls_forEach" id="WMPl}l}=L$2Zw)NA*TVy"> <field name="VAR" id="49uXg6HLqFYWFA:qXC@Q">id</field> <value name="LIST"> <block type="variables_get" id="l;;%nd.bGb.#gpGdu;b4"> <field name="VAR" id="a8Hk_)m.S#v]xOx,|g]B">ids</field> </block> </value> <statement name="DO"> <block type="controls_if" id="`JE~9u-b2ugOMZ.:1(#X"> <value name="IF0"> <block type="get_value_var" id="}_NRDK8u4v`;cKJcme`7"> <field name="ATTR">val</field> <value name="OID"> <shadow type="text" id="tzQ/EjJ-;3Z,h.sG`jKi"> <field name="TEXT"></field> </shadow> <block type="variables_get" id=".l1{d-4+KoMP[E$t|=Gb"> <field name="VAR" id="49uXg6HLqFYWFA:qXC@Q">id</field> </block> </value> </block> </value> <statement name="DO0"> <block type="lists_setIndex" id="DyfzqLSC_%oiZ`g^W?m:"> <mutation at="false"></mutation> <field name="MODE">INSERT</field> <field name="WHERE">LAST</field> <value name="LIST"> <block type="variables_get" id="CpNch0%9GPu|K{s+|m!}"> <field name="VAR" id="p8z4a0D*3/v6krF]%fZK">offen</field> </block> </value> <value name="TO"> <block type="procedures_callcustomreturn" id="z*lB%;}2qJrPQkmG~u8@"> <mutation name="parentName"></mutation> </block> </value> </block> </statement> </block> </statement> <next> <block type="controls_if" id="hR^gCWwe.;UCu9p-qyGx"> <mutation elseif="1" else="1"></mutation> <value name="IF0"> <block type="logic_compare" id="p`L;~I5uAoOKRrfa5q%5"> <field name="OP">EQ</field> <value name="A"> <block type="lists_length" id="B0-8oi/qN*^MH*+eY%}o"> <value name="VALUE"> <block type="variables_get" id="9wi8O-AzAH/n~~6ZmvsG"> <field name="VAR" id="p8z4a0D*3/v6krF]%fZK">offen</field> </block> </value> </block> </value> <value name="B"> <block type="math_number" id="%6|xhjTa4nGB(Q8^QbWC"> <field name="NUM">0</field> </block> </value> </block> </value> <statement name="DO0"> <block type="variables_set" id="-iZbaLpFBLPN.J@90mF~"> <field name="VAR" id="P(vzemG|?%LTz:_r9=_I">ausgabe</field> <value name="VALUE"> <block type="text" id="aejqq*esw$7N.go7eu}8"> <field name="TEXT">Alle Fenster sind geschlossen.</field> </block> </value> </block> </statement> <value name="IF1"> <block type="logic_compare" id="J;3HQA0zahV=5||8`a{M"> <field name="OP">EQ</field> <value name="A"> <block type="lists_length" id="tGrk`@6hM}vbYuPp^.X?"> <value name="VALUE"> <block type="variables_get" id="*9Ls*xgSS$m3UsN-sRoL"> <field name="VAR" id="p8z4a0D*3/v6krF]%fZK">offen</field> </block> </value> </block> </value> <value name="B"> <block type="math_number" id="bmu)D!?io4CW#nzEkUY#"> <field name="NUM">1</field> </block> </value> </block> </value> <statement name="DO1"> <block type="variables_set" id="Q12Yagv4i-tD51BDOL^}"> <field name="VAR" id="P(vzemG|?%LTz:_r9=_I">ausgabe</field> <value name="VALUE"> <block type="text_join" id="$8SEyS(fCl]34vt@zGOY"> <mutation items="2"></mutation> <value name="ADD0"> <block type="text" id="gpmM(s|B-T+HTjs39dd7"> <field name="TEXT">Ein Fenster ist offen:</field> </block> </value> <value name="ADD1"> <block type="lists_getIndex" id="uGu+PjyJ,YH},N)0^y`0"> <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="1:t{r2P-/)Dy:}/@pUpK"> <field name="VAR" id="p8z4a0D*3/v6krF]%fZK">offen</field> </block> </value> <value name="AT"> <block type="math_number" id="s!.zhK}UIPL42aEBV`kx"> <field name="NUM">1</field> </block> </value> </block> </value> </block> </value> </block> </statement> <statement name="ELSE"> <block type="variables_set" id="96@Bh=6u1R(Z?;6{3ElK"> <field name="VAR" id="P(vzemG|?%LTz:_r9=_I">ausgabe</field> <value name="VALUE"> <block type="text_join" id="635UtV%:d-(K_*y]VpCo"> <mutation items="3"></mutation> <value name="ADD0"> <block type="text" id="31=V#t*UIp8YFWi7+{(A"> <field name="TEXT">Folgende Fenster sind offen:</field> </block> </value> <value name="ADD1"> <block type="text_newline" id=")f_:k4CJ8%I?J?4Oj]B8"> <field name="Type">\n</field> </block> </value> <value name="ADD2"> <block type="lists_split" id="Ijd5bXGR[PLR6Asezh0Q"> <mutation mode="SPLIT"></mutation> <field name="MODE">SPLIT</field> <value name="INPUT"> <block type="variables_get" id="@[6p#KdsR}+[:i%rq0jp"> <field name="VAR" id="p8z4a0D*3/v6krF]%fZK">offen</field> </block> </value> <value name="DELIM"> <shadow type="text" id="MTy@`+OFu$3rBE02j^XH"> <field name="TEXT">,</field> </shadow> <block type="text_newline" id="%6,QDgXz|$,~l2IK]:14"> <field name="Type">\n</field> </block> </value> </block> </value> </block> </value> </block> </statement> <next> <block type="update" id="ij5GfvgPkPgtFeM^r,6="> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">0_userdata.0.Status.EG.Fenster.offen</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="lists_length" id="yAh@[4L7aiqh|Y-mp=)T"> <value name="VALUE"> <block type="variables_get" id="gc)VyPoi_;-]k`}DWZ3("> <field name="VAR" id="p8z4a0D*3/v6krF]%fZK">offen</field> </block> </value> </block> </value> <next> <block type="update" id="1#i4HwZ)Lu5@1*b6H%Q$"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">0_userdata.0.Status.EG.Fenster.Ausgabe</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="variables_get" id="3ujfW6Y_|@F1$zIV_R11"> <field name="VAR" id="P(vzemG|?%LTz:_r9=_I">ausgabe</field> </block> </value> </block> </next> </block> </next> </block> </next> </block> </next> </block> </statement> </block> </next> </block> <block type="procedures_defcustomreturn" id="C0=Q3DO]s2JewM3;[Og1" x="312" y="87"> <mutation statements="false"></mutation> <field name="NAME">parentName</field> <field name="SCRIPT">aWQgPSBpZC5zdWJzdHJpbmcoMCwgaWQubGFzdEluZGV4T2YoJy4nKSk7DQppZihleGlzdHNPYmplY3QoaWQpKSByZXR1cm4gZ2V0T2JqZWN0KGlkKS5jb21tb24ubmFtZTs=</field> <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment> </block> </xml>
Bei der Aufzählung habe ich folgendes enum:
Fenster-EGenum.functions.Fenster-EG
Dort habe ich dann die Fenster-Module eingegeben, z.B.:
EG Fensterkontakt Wohnzimmertür:1 hm-rpc.1.00109DXXXXXX.1
-
@jwerlsdf
Bei der JS-Funktion fehlt der Übergabe-Parameterid
.An die Funktion muss die ID übergeben werden.
Es muss ein Text aus der Liste erstellt werden - nicht umgekehrt.
@jwerlsdf sagte: Bei der Aufzählung habe ich folgendes enum:
Die Enums müssen unter Wurzelordner enum erstellt werden:
enum.functions.Fenster-EG
Verwende den Tab "Aufzählungen" dafür.
-
@paul53
Hat alles geklappt. Vielen Dank!