NEWS
[gelöst] Zeitdifferenz seit Tür offen per Alexa melden
-
Hallo,
ich würde gern mit dem neuen Baustein "Zeitdifferenz formatieren" die Sekunden ansagen lassen,
wie lange die Tür geöffnet ist. Natürlich gern auch in Minuten und Sekunden, hab ich aber auch nicht hinbekommen.Ich verstehe die Ausgabe "NaN" nicht, als Ergebnis der Differenz.
Folgendes Blockly:
Blockly als Export:
<xml xmlns="https://developers.google.com/blockly/xml"> <variables> <variable type="timeout" id="timeout">timeout</variable> <variable type="interval" id="Intervall">Intervall</variable> </variables> <block type="comment" id="E]MP@[K{#cTLg{$AMwTZ" x="187" y="63"> <field name="COMMENT">Falls die Katze die Eingangstür geöffnet hat :-)</field> <next> <block type="on_ext" id="atH#6C)3sLsRz:[/a;-S"> <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="~Gy1+Nve9BU8gT[/p!A0"> <field name="oid">deconz.0.Sensors.16.open</field> </shadow> </value> <statement name="STATEMENT"> <block type="comment" id="srmVj@5$F].*].Uk^(eh"> <field name="COMMENT">Log-Eintrag</field> <next> <block type="debug" id="4mNUgJ~p]+`9nOK^IzBk"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="bM6;F`}628@P%#_.VOmY"> <field name="TEXT">Wohnungstür wurde bewegt</field> </shadow> </value> <next> <block type="comment" id="vcm4p3@P?gBO7-|iLC{P"> <field name="COMMENT">Tür ist geöffnet</field> <next> <block type="controls_if" id="wx#pk4O6:x_+0=N5N9%k"> <mutation elseif="1"></mutation> <value name="IF0"> <block type="logic_compare" id="BbE:${hy@Mmf)b~=SbA4"> <field name="OP">EQ</field> <value name="A"> <block type="get_value" id="_s$69E[UaX4dmb1u72B^"> <field name="ATTR">val</field> <field name="OID">deconz.0.Sensors.16.open</field> </block> </value> <value name="B"> <block type="logic_boolean" id="9@ToFcv[2%$^V?XRio+0"> <field name="BOOL">TRUE</field> </block> </value> </block> </value> <statement name="DO0"> <block type="comment" id="P3KUYepECCZ[/?%Fg]HG"> <field name="COMMENT">Wenn Tür länger als 1 Minuten geöffnet</field> <next> <block type="timeouts_settimeout" id="3~V:#D%BjIj8T%DyWlyP"> <field name="NAME">timeout</field> <field name="DELAY">1</field> <field name="UNIT">min</field> <statement name="STATEMENT"> <block type="comment" id=",/@3(6dO@x7T@ql/qAR6"> <field name="COMMENT">Ansage auf Alexa Wohnzimmer alle 20 Sek. wiederholen</field> <next> <block type="timeouts_setinterval" id="5e;tV`4muF^1_bs|({;Y"> <field name="NAME">Intervall</field> <field name="INTERVAL">20</field> <field name="UNIT">sec</field> <statement name="STATEMENT"> <block type="debug" id="_w1JPJ+aO)R~E*m=+pZo"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id=".g7tzw9?Jx}$7(sYVu?k"> <field name="TEXT">test</field> </shadow> <block type="text_join" id="J/6Oj4-9KRijv.i+N5Cu"> <mutation items="5"></mutation> <value name="ADD0"> <block type="time_get" id="h3~`!Sg`fS,_Hzp[LQ8Q"> <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation> <field name="OPTION">hh:mm:ss</field> </block> </value> <value name="ADD1"> <block type="text_newline" id="J*1m4yUwaI^MQh0$hQfn"> <field name="Type">\n</field> </block> </value> <value name="ADD2"> <block type="convert_from_date" id="ZI]KiUn]]x~b35n=5Tdk"> <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation> <field name="OPTION">hh:mm:ss</field> <value name="VALUE"> <block type="on_source" id="EhA1/n0iRzHd,6+sh3$h"> <field name="ATTR">state.ts</field> </block> </value> </block> </value> <value name="ADD3"> <block type="text_newline" id="8),p/URrv(93/K]#xw],"> <field name="Type">\n</field> </block> </value> <value name="ADD4"> <block type="convert_time_difference" id="f]4BPgjCPs/pAy/bsFG`"> <mutation xmlns="http://www.w3.org/1999/xhtml" format="true"></mutation> <field name="OPTION">custom</field> <field name="FORMAT">ss</field> <value name="VALUE"> <block type="math_arithmetic" id="T}Fs?TdU.],zS,8.Wq60"> <field name="OP">MINUS</field> <value name="A"> <shadow type="math_number" id="IXF=83gVje?|vQlTVs7m"> <field name="NUM">1</field> </shadow> <block type="time_get" id="!*{6e^PL{O6Pw9my{^?P"> <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation> <field name="OPTION">hh:mm:ss</field> </block> </value> <value name="B"> <shadow type="math_number" id="sj|e!z2rK!;BlW$;W(FW"> <field name="NUM">1</field> </shadow> <block type="convert_from_date" id="?h0g34O2n`QZp|W?g+1#"> <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation> <field name="OPTION">hh:mm:ss</field> <value name="VALUE"> <block type="on_source" id="Ouc+OZDgZc8s#W^C!c{p"> <field name="ATTR">state.ts</field> </block> </value> </block> </value> </block> </value> </block> </value> </block> </value> <next> <block type="comment" id="Z9Bq0)V*(KRTw4+*7-.9"> <field name="COMMENT">Alexa im Wohnzimmer sprechen lassen</field> <next> <block type="control" id="IRhk|FAR,]5M%!Y4ODhM"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">alexa2.0.Echo-Devices.G0922M0633660ARC.Commands.speak</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="text_join" id="Qk`ac?xH|1:-}Vl7r-bN"> <mutation items="3"></mutation> <value name="ADD0"> <block type="text" id="-5KJ`_9ODdV.5TCNe1NL"> <field name="TEXT">Die Wohnungstür ist seit mehr als </field> </block> </value> <value name="ADD1"> <block type="convert_time_difference" id="gAeK,6PazLBK$|6MO{C6"> <mutation xmlns="http://www.w3.org/1999/xhtml" format="true"></mutation> <field name="OPTION">custom</field> <field name="FORMAT">ss</field> <value name="VALUE"> <block type="math_arithmetic" id="YbIYF=|T33#Yfk0LT0cV"> <field name="OP">MINUS</field> <value name="A"> <shadow type="math_number" id="IXF=83gVje?|vQlTVs7m"> <field name="NUM">1</field> </shadow> <block type="time_get" id="McA=aqSl/Zuuqw@.ZJ@q"> <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation> <field name="OPTION">hh:mm:ss</field> </block> </value> <value name="B"> <shadow type="math_number" id="sj|e!z2rK!;BlW$;W(FW"> <field name="NUM">1</field> </shadow> <block type="convert_from_date" id="u]G0|v@PHg;[-H/V%PBC"> <mutation xmlns="http://www.w3.org/1999/xhtml" format="false" language="false"></mutation> <field name="OPTION">hh:mm:ss</field> <value name="VALUE"> <block type="on_source" id="Wp3_^tcaTJO:B]rBnQk6"> <field name="ATTR">state.ts</field> </block> </value> </block> </value> </block> </value> </block> </value> <value name="ADD2"> <block type="text" id=";UaS4nmH:b+^7DH4Q^)%"> <field name="TEXT">offen, bitte die Wohnungstür schließen.</field> </block> </value> </block> </value> </block> </next> </block> </next> </block> </statement> <next> <block type="comment" id="x(jzz|Jt#x=[y$U,eul*"> <field name="COMMENT">Log-Eintrag</field> <next> <block type="debug" id="kAVunY$1;8({61V(Hp@Y"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="yBt4z6,?7(hH(!!Ab1$@"> <field name="TEXT">Wohnungstür ist länger als 1 Minute geöffnet</field> </shadow> </value> </block> </next> </block> </next> </block> </next> </block> </statement> </block> </next> </block> </statement> <value name="IF1"> <block type="logic_compare" id="eiiAPu,4~4H#d9|#FCC^"> <field name="OP">EQ</field> <value name="A"> <block type="get_value" id="Xk5Z:$#dEk]yE:uLH#+d"> <field name="ATTR">val</field> <field name="OID">deconz.0.Sensors.16.open</field> </block> </value> <value name="B"> <block type="logic_boolean" id="*3CT.XZmz4UB8T5kXXW="> <field name="BOOL">FALSE</field> </block> </value> </block> </value> <statement name="DO1"> <block type="timeouts_cleartimeout" id="k+207}1sw/i4#Gwqd3OX"> <field name="NAME">timeout</field> <next> <block type="timeouts_clearinterval" id="#{?W19bu(tJLQ6ukl;;I"> <field name="NAME">Intervall</field> <next> <block type="comment" id="`JBdU{jh!~y1?+9]f*;L"> <field name="COMMENT">Log-Eintrag</field> <next> <block type="debug" id="hgv3Jkz/t042!an$o$S!"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="[A[~mwC$;tr{,}sUwD]u"> <field name="TEXT">Wohnungstür wieder geschlossen</field> </shadow> </value> </block> </next> </block> </next> </block> </next> </block> </statement> </block> </next> </block> </next> </block> </next> </block> </statement> </block> </next> </block> </xml>
Aus dem Log nach Intervall kommen folgende Ergebnisse:
18:43:00.469 info javascript.0 (155712) script.js.Skripte.Wohnung.Eingangstür_offen: 18:43:00 18:41:00 NaN 18:43:20.469 info javascript.0 (155712) script.js.Skripte.Wohnung.Eingangstür_offen: 18:43:20 18:41:00 NaN 18:43:40.470 info javascript.0 (155712) script.js.Skripte.Wohnung.Eingangstür_offen: 18:43:40 18:41:00 NaN 18:44:00.471 info javascript.0 (155712) script.js.Skripte.Wohnung.Eingangstür_offen: 18:44:00 18:41:00 NaN 18:44:20.471 info javascript.0 (155712) script.js.Skripte.Wohnung.Eingangstür_offen: 18:44:20 18:41:00 NaN 18:44:40.471 info javascript.0 (155712) script.js.Skripte.Wohnung.Eingangstür_offen: 18:44:40 18:41:00 NaN
-
@siggi0904 sagte: Ich verstehe die Ausgabe "NaN" nicht, als Ergebnis der Differenz.
"NaN" = "Not a Number". Man kann keine Strings subtrahieren, sondern so:
-
@paul53 ah cool, wusste nicht dass das ein String dann ist.
Aktuell ist blöd, dass Alexa da "2 Uhr 40" oder "1 doppelpunkt null" draus macht.
Wie kann ich das nach Minuten und Sekunden zerlegen?
-
@siggi0904 sagte: Wie kann ich das nach Minuten und Sekunden zerlegen?
-
@paul53 grandios.
Das in eine Liste zu zerlegen bin ich nicht drauf gekommen.