NEWS
Wiederholen von Befehlen. Wie geht das
-
Sorry, verstehe ich nicht. Gezeigt ist ja nur der Timeout für einen Befehl. Was soll ich mit dem zweiten machen?
Ich habe zwei Screenshots gepostet, welcher ist jetzt der richtige Weg?
-
@Martin-0 sagte:
Gezeigt ist ja nur der Timeout für einen Befehl
Das ist nicht ein Befehl, sondern der Aufruf einer Funktion, die wiederum alles enthält, was in der ersten Version vor dem Timeout und dann im Timeout passiert.
Vorgehen: Du erstellst eine Funktion, verschiebst alles, was innerhalb des Timeouts ist, in die Funktion und in das leere Timeout kommt dann der Funktionsaufruf. Die Alexa-Befehle über dem Timeout werden dann durch einen weiteren Funktionsaufruf ersetzt.
-
-
Oder
so:
-
@Martin-0 sagte:
Oder
so:Beide Varianten unterscheiden sich im Ergebnis nicht, allerdings würde ich die zweite Variante mit nur einem Timeout bevorzugen.
Poste mal den XML-Export des Blocklys (mit nur einem Timeout) in Code tags. Dann kann ich es leicht modifizieren und zurück schicken.
-
var timeout;
schedule('{"time":{"exactTime":true,"start":"23:00"},"period":{"days":1}}', function () {
if (getState("hm-rpc.0.JEQ0068443.1.STATE").val == true) {
// Echo Wohnzimmer
// mit Bluetooth
if (getState("alexa2.0.Echo-Devices.G090U509847625MD.Bluetooth.3db393472f177440184a264d10ab21eaa3a40b727da721dacafdc36d7c924828.connected").val == true) {
setState("alexa2.0.Echo-Devices.G090U509847625MD.Commands.speak-volume"/Volume to use for speak commands/, '100');
setState("alexa2.0.Echo-Devices.G090U509847625MD.Commands.speak"/speak/, 'Sicherheitswarnung. Das Garagentor ist noch geöffnet');
} else {
setState("alexa2.0.Echo-Devices.G090U509847625MD.Commands.speak-volume"/Volume to use for speak commands/, '80');
setState("alexa2.0.Echo-Devices.G090U509847625MD.Commands.speak"/speak/, 'Sicherheitswarnung. Das Garagentor ist noch geöffnet');
}
// Echo Badezimmer
setState("alexa2.0.Echo-Devices.G090U50984653CEF.Commands.speak"/speak/, 'Sicherheitswarnung. Das Garagentor ist noch geöffnet');
// Echo Wintergarten rechts
setState("alexa2.0.Echo-Devices.G090U50991860QSL.Commands.speak-volume"/Volume to use for speak commands/, '50');
setState("alexa2.0.Echo-Devices.G090U50991860QSL.Commands.speak"/speak/, 'Sicherheitswarnung. Das Garagentor ist noch geöffnet');
// Echo Werkstatt
setState("alexa2.0.Echo-Devices.G090XG07930531PU.Commands.speak"/speak/, 'Sicherheitswarnung. Das Garagentor ist noch geöffnet');
// Echo Schlafzimmer
setState("alexa2.0.Echo-Devices.G090U50784360US6.Commands.speak-volume"/Volume to use for speak commands/, '40');
setState("alexa2.0.Echo-Devices.G090U50784360US6.Commands.speak"/speak/, 'Sicherheitswarnung. Das Garagentor ist noch geöffnet');
timeout = setTimeout(function () {
// Echo Wohnzimmer
if (getState("alexa2.0.Echo-Devices.G090U509847625MD.Bluetooth.3db393472f177440184a264d10ab21eaa3a40b727da721dacafdc36d7c924828.connected").val == true) {
setState("alexa2.0.Echo-Devices.G090U509847625MD.Commands.speak-volume"/Volume to use for speak commands/, '100');
setState("alexa2.0.Echo-Devices.G090U509847625MD.Commands.speak"/speak/, 'Sicherheitswarnung. Das Garagentor ist noch geöffnet');
} else {
setState("alexa2.0.Echo-Devices.G090U509847625MD.Commands.speak-volume"/Volume to use for speak commands/, '80');
setState("alexa2.0.Echo-Devices.G090U509847625MD.Commands.speak"/speak/, 'Sicherheitswarnung. Das Garagentor ist noch geöffnet');
}
// Echo Badezimmer
setState("alexa2.0.Echo-Devices.G090U50984653CEF.Commands.speak"/speak/, 'Sicherheitswarnung. Das Garagentor ist noch geöffnet');
// Echo Wintergarten rechts
setState("alexa2.0.Echo-Devices.G090U50991860QSL.Commands.speak-volume"/Volume to use for speak commands/, '50');
setState("alexa2.0.Echo-Devices.G090U50991860QSL.Commands.speak"/speak/, 'Sicherheitswarnung. Das Garagentor ist noch geöffnet');
// Echo Werkstatt
setState("alexa2.0.Echo-Devices.G090XG07930531PU.Commands.speak"/speak/, 'Sicherheitswarnung. Das Garagentor ist noch geöffnet');
// Echo Schlafzimmer
setState("alexa2.0.Echo-Devices.G090U50784360US6.Commands.speak-volume"/Volume to use for speak commands/, '40');
setState("alexa2.0.Echo-Devices.G090U50784360US6.Commands.speak"/speak/, 'Sicherheitswarnung. Das Garagentor ist noch geöffnet');
}, 10000);
}
}); -
@Martin-0
Das ist nicht der XML-Export von Blockly, sondern der erzeugte Javascript-Code. Das linke Symbol oben rechts erzeugt den Export. Bitte in Code tags (</> Symbol oben) posten. -
<xml xmlns="http://www.w3.org/1999/xhtml">
<variables>
<variable type="undefined" id="timeout">timeout</variable>
</variables>
<block type="schedule" id="I4$lt{y={6ktxUOFUAUp" x="-1062" y="-988">
<field name="SCHEDULE">{"time":{"exactTime":true,"start":"23:00"},"period":{"days":1}}</field>
<statement name="STATEMENT">
<block type="controls_if" id="+5B75]y|H0xaV^k}nzN#">
<value name="IF0">
<block type="logic_compare" id=":g^t/wOP@Eyn8Ps}y*;:">
<field name="OP">EQ</field>
<value name="A">
<block type="get_value" id="K[j1v-@LyMurc%MVd:Qj">
<field name="ATTR">val</field>
<field name="OID">hm-rpc.0.JEQ0068443.1.STATE</field>
</block>
</value>
<value name="B">
<block type="logic_boolean" id="CGp0Xup1{gaa=LN-p)V">
<field name="BOOL">TRUE</field>
</block>
</value>
</block>
</value>
<statement name="DO0">
<block type="comment" id="#a6CqObU980oj_+jN;va">
<field name="COMMENT">Echo Wohnzimmer</field>
<next>
<block type="comment" id="~MfNhQGcG5-eodj/Ag$/">
<field name="COMMENT">mit Bluetooth</field>
<next>
<block type="controls_if" id="Sa@D_Q}pR0un/ZL#_g5Y">
<mutation else="1"></mutation>
<value name="IF0">
<block type="logic_compare" id=")5oGRI;zacHW%(xtMCA">
<field name="OP">EQ</field>
<value name="A">
<block type="get_value" id="%L!7BNil_:j$$v-/HB5;">
<field name="ATTR">val</field>
<field name="OID">alexa2.0.Echo-Devices.G090U509847625MD.Bluetooth.3db393472f177440184a264d10ab21eaa3a40b727da721dacafdc36d7c924828.connected</field>
</block>
</value>
<value name="B">
<block type="logic_boolean" id="r3RrA0!BG9HErLI10+Gi">
<field name="BOOL">TRUE</field>
</block>
</value>
</block>
</value>
<statement name="DO0">
<block type="control" id="YN/F]|V8jV^q2^rkjfq">
<mutation delay_input="false"></mutation>
<field name="OID">alexa2.0.Echo-Devices.G090U509847625MD.Commands.speak-volume</field>
<field name="WITH_DELAY">FALSE</field>
<value name="VALUE">
<block type="text" id="ssnF/8[n]OT}5q_NF1fC">
<field name="TEXT">100</field>
</block>
</value>
<next>
<block type="control" id="1kd^IJMa~xjhk/in4g/"> <mutation delay_input="false"></mutation> <field name="OID">alexa2.0.Echo-Devices.G090U509847625MD.Commands.speak</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="text" id="2wFdJ]Ku|O=k-t(mi~s}"> <field name="TEXT">Sicherheitswarnung. Das Garagentor ist noch geöffnet</field> </block> </value> </block> </next> </block> </statement> <statement name="ELSE"> <block type="control" id="456o(v0t,!9Pty]^$Nab"> <mutation delay_input="false"></mutation> <field name="OID">alexa2.0.Echo-Devices.G090U509847625MD.Commands.speak-volume</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="text" id="]L]{t#x=u%j]%;m18k^t"> <field name="TEXT">80</field> </block> </value> <next> <block type="control" id=";QN|_Yq9@aD[a*_C{ukc"> <mutation delay_input="false"></mutation> <field name="OID">alexa2.0.Echo-Devices.G090U509847625MD.Commands.speak</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="text" id="x%H-#:
N03mu2ABh1sA1">
<field name="TEXT">Sicherheitswarnung. Das Garagentor ist noch geöffnet</field>
</block>
</value>
</block>
</next>
</block>
</statement>
<next>
<block type="comment" id="v[0Drg.U64ZRqvA;=5"> <field name="COMMENT">Echo Badezimmer</field> <next> <block type="control" id="HSi=j(%sT
DAKr?##.xd">
<mutation delay_input="false"></mutation>
<field name="OID">alexa2.0.Echo-Devices.G090U50984653CEF.Commands.speak</field>
<field name="WITH_DELAY">FALSE</field>
<value name="VALUE">
<block type="text" id="U~W8VXo$DkbtBSgtE7?c">
<field name="TEXT">Sicherheitswarnung. Das Garagentor ist noch geöffnet</field>
</block>
</value>
<next>
<block type="comment" id="5vVI?(=4i),Vx@;%[4~">
<field name="COMMENT">Echo Wintergarten rechts</field>
<next>
<block type="control" id=".;a7k%koIj1$Og=qj[?y">
<mutation delay_input="false"></mutation>
<field name="OID">alexa2.0.Echo-Devices.G090U50991860QSL.Commands.speak-volume</field>
<field name="WITH_DELAY">FALSE</field>
<value name="VALUE">
<block type="text" id="5iFhLmvjYvFqy3RaE(N">
<field name="TEXT">50</field>
</block>
</value>
<next>
<block type="control" id="E)s;fE+FKe;OmVJ6HH!Q">
<mutation delay_input="false"></mutation>
<field name="OID">alexa2.0.Echo-Devices.G090U50991860QSL.Commands.speak</field>
<field name="WITH_DELAY">FALSE</field>
<value name="VALUE">
<block type="text" id="OyH6w3SSbrse9@K1O0p7">
<field name="TEXT">Sicherheitswarnung. Das Garagentor ist noch geöffnet</field>
</block>
</value>
<next>
<block type="comment" id="4N%z;b.Vph^QV}:].I3]">
<field name="COMMENT">Echo Werkstatt</field>
<next>
<block type="control" id="sXob%i4YEM-H@#wn|gns">
<mutation delay_input="false"></mutation>
<field name="OID">alexa2.0.Echo-Devices.G090XG07930531PU.Commands.speak</field>
<field name="WITH_DELAY">FALSE</field>
<value name="VALUE">
<block type="text" id="0PS%cft}7288H.C#]26D">
<field name="TEXT">Sicherheitswarnung. Das Garagentor ist noch geöffnet</field>
</block>
</value>
<next>
<block type="comment" id="^H8jD(8nqF(j)gz:y?P"> <field name="COMMENT">Echo Schlafzimmer</field> <next> <block type="control" id="#2~KZ2gr5;Aw,$Nvh,jj"> <mutation delay_input="false"></mutation> <field name="OID">alexa2.0.Echo-Devices.G090U50784360US6.Commands.speak-volume</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="text" id="@ob#{]|aCDU2-he=FE,k"> <field name="TEXT">40</field> </block> </value> <next> <block type="control" id="nJzG=cD{s|=u7[a7^wPL"> <mutation delay_input="false"></mutation> <field name="OID">alexa2.0.Echo-Devices.G090U50784360US6.Commands.speak</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="text" id="yMG?ET?+@ku@wk2:BA1H"> <field name="TEXT">Sicherheitswarnung. Das Garagentor ist noch geöffnet</field> </block> </value> <next> <block type="timeouts_settimeout" id="^MQc)RrII$IK?vh7[oBh"> <field name="NAME">timeout</field> <field name="DELAY">10</field> <field name="UNIT">sec</field> <statement name="STATEMENT"> <block type="comment" id="CazBpF8s^39B=V2!u|(P"> <field name="COMMENT">Echo Wohnzimmer</field> <next> <block type="controls_if" id="hZ~V,z25PwxAgScWkEG5"> <mutation else="1"></mutation> <value name="IF0"> <block type="logic_compare" id="}V^09Y3*p=0?g^!t8WIn"> <field name="OP">EQ</field> <value name="A"> <block type="get_value" id="
a+yjeHL8Bq.Gw,Ooru">
<field name="ATTR">val</field>
<field name="OID">alexa2.0.Echo-Devices.G090U509847625MD.Bluetooth.3db393472f177440184a264d10ab21eaa3a40b727da721dacafdc36d7c924828.connected</field>
</block>
</value>
<value name="B">
<block type="logic_boolean" id="iL;.^qKRI/EvT__-ijX0">
<field name="BOOL">TRUE</field>
</block>
</value>
</block>
</value>
<statement name="DO0">
<block type="control" id="o1v=umqvl[o$Cv|;f]S-">
<mutation delay_input="false"></mutation>
<field name="OID">alexa2.0.Echo-Devices.G090U509847625MD.Commands.speak-volume</field>
<field name="WITH_DELAY">FALSE</field>
<value name="VALUE">
<block type="text" id="i3ku|QIY+,p5sKUz$tok">
<field name="TEXT">100</field>
</block>
</value>
<next>
<block type="control" id="N/JW|@/%ImTm,eNq6On,">
<mutation delay_input="false"></mutation>
<field name="OID">alexa2.0.Echo-Devices.G090U509847625MD.Commands.speak</field>
<field name="WITH_DELAY">FALSE</field>
<value name="VALUE">
<block type="text" id="{AiP(D{1D[#^P@^BYu3"> <field name="TEXT">Sicherheitswarnung. Das Garagentor ist noch geöffnet</field> </block> </value> </block> </next> </block> </statement> <statement name="ELSE"> <block type="control" id="M%o@@T68jp?jm4shN%!b"> <mutation delay_input="false"></mutation> <field name="OID">alexa2.0.Echo-Devices.G090U509847625MD.Commands.speak-volume</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="text" id="?%K^o[D*RD1O7/dctrsL"> <field name="TEXT">80</field> </block> </value> <next> <block type="control" id="bof(^Kc6*HkP+s:j[6#_"> <mutation delay_input="false"></mutation> <field name="OID">alexa2.0.Echo-Devices.G090U509847625MD.Commands.speak</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="text" id="Zg.26|*7@*QXlQ0+s:j0"> <field name="TEXT">Sicherheitswarnung. Das Garagentor ist noch geöffnet</field> </block> </value> </block> </next> </block> </statement> <next> <block type="comment" id="})*dm=K.%!t}u%{{lOOo"> <field name="COMMENT">Echo Badezimmer</field> <next> <block type="control" id="=Bdy1/j[B-XGezQyz^hF"> <mutation delay_input="false"></mutation> <field name="OID">alexa2.0.Echo-Devices.G090U50984653CEF.Commands.speak</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="text" id="S|yEcx6C#zv
b-j)/k27">
<field name="TEXT">Sicherheitswarnung. Das Garagentor ist noch geöffnet</field>
</block>
</value>
<next>
<block type="comment" id="I7D#-CK31A(.9PL{OIrS">
<field name="COMMENT">Echo Wintergarten rechts</field>
<next>
<block type="control" id="N-z_H{7CHOH?f6BF_fBH">
<mutation delay_input="false"></mutation>
<field name="OID">alexa2.0.Echo-Devices.G090U50991860QSL.Commands.speak-volume</field>
<field name="WITH_DELAY">FALSE</field>
<value name="VALUE">
<block type="text" id="Y[**e(JPeIK`iIvbIrOt">
<field name="TEXT">50</field>
</block>
</value>
<next>
<block type="control" id="T8r(PQcs.=m8,Z37N;-y">
<mutation delay_input="false"></mutation>
<field name="OID">alexa2.0.Echo-Devices.G090U50991860QSL.Commands.speak</field>
<field name="WITH_DELAY">FALSE</field>
<value name="VALUE">
<block type="text" id="~z$.B^I!-OrhLnIM{H6">
<field name="TEXT">Sicherheitswarnung. Das Garagentor ist noch geöffnet</field>
</block>
</value>
<next>
<block type="comment" id="h7VHm$s|m_^_/_nyScx.">
<field name="COMMENT">Echo Werkstatt</field>
<next>
<block type="control" id="YEdU^w}S1+:gN%81VAQ@">
<mutation delay_input="false"></mutation>
<field name="OID">alexa2.0.Echo-Devices.G090XG07930531PU.Commands.speak</field>
<field name="WITH_DELAY">FALSE</field>
<value name="VALUE">
<block type="text" id="Z+dfSsT@UU6foNz|/p+d">
<field name="TEXT">Sicherheitswarnung. Das Garagentor ist noch geöffnet</field>
</block>
</value>
<next>
<block type="comment" id="F1(av/Fq.7jObTX.yG[">
<field name="COMMENT">Echo Schlafzimmer</field>
<next>
<block type="control" id="Nj@c?9:P,d?puaw0vMfz">
<mutation delay_input="false"></mutation>
<field name="OID">alexa2.0.Echo-Devices.G090U50784360US6.Commands.speak-volume</field>
<field name="WITH_DELAY">FALSE</field>
<value name="VALUE">
<block type="text" id="m!!hO]X%6vvn=%DIjF}">
<field name="TEXT">40</field>
</block>
</value>
<next>
<block type="control" id="J?BofaiaB2V!fQ$cGc3^">
<mutation delay_input="false"></mutation>
<field name="OID">alexa2.0.Echo-Devices.G090U50784360US6.Commands.speak</field>
<field name="WITH_DELAY">FALSE</field>
<value name="VALUE">
<block type="text" id="4S9Zmgr#-ynXmvr7yY">
<field name="TEXT">Sicherheitswarnung. Das Garagentor ist noch geöffnet</field>
</block>
</value>
</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>
</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>
</statement>
</block>
</xml> -
@Martin-0
Hier mit Funktion zum Importieren.
-
Das sieht ja super aus.
Also ich mache das ganze seit Vorgestern, deshalb noch etwas holprig.Ich habe mir das jetzt mal angeschaut.
Sind die "ansagen" jetzt dadurch verknüpft, dass die jeweils in den Textfeldern stehen?
Da muss ich ja garnicht jedesmal den Befehl überall reinschreiben, sondern kann das benennen und dann einfügen, richtig? -
@Martin-0 sagte in Wiederholen von Befehlen. Wie geht das:
Da muss ich ja garnicht jedesmal den Befehl überall reinschreiben, sondern kann das benennen und dann einfügen
Da der Ansagetext überall gleich ist, habe ich eine Variante mit Variable erstellt.
Ist "Commands.speak-volume" tatsächlich ein String-Datenpunkt oder ein Zahl-Datenpunkt ?