NEWS
Blockly Lösung, Vereinfachung?
-
Hi zusammen, und wieder wäre euer Schwarmwissen gefragt?
Folgender Ausgangspunkt.
Ich bekomme vom Adapter in einen Datenpunkt 3 Werte geschrieben 20,21,22, dies ist die Uhrzeit zu der der Strom an der Börse am billigsten wäre. Diesen String gliedere ich dann in 3 Zeiten auf, nun möchte ich aber noch gerne prüfen ob zu diesen Zeiten ein Preis von 0,25€ unterschritten wird, ist dies der Fall, sollen andere Datenpunkte unter 0userdata als wahr geschaltet werden.
Dies müßte ich natürlich für 24 Stunden lösen, geht dies nicht einfacher?
Blockly:
<block xmlns="https://developers.google.com/blockly/xml" type="on" id="^i^u{-7v4L_#$J|DK:o:" x="113" y="903"> <field name="OID">tibber.0.calculations.Feedback</field> <field name="CONDITION">any</field> <field name="ACK_CONDITION"></field> <statement name="STATEMENT"> <block type="debug" id="klBD-k2Lb+uh!Dw]Fe~7"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="*Fdm/Lo%XI]CClLJe_;v"> <field name="TEXT">test</field> </shadow> <block type="on_source" id="s+mV4hh^]i`ua2q9R]B/"> <field name="ATTR">state.val</field> </block> </value> <next> <block type="variables_set" id="V#[k)0OlH/c?JL~/JEk,"> <field name="VAR" id="d$VYHI2Oswd~cr8]=Ot2">string_Details</field> <value name="VALUE"> <block type="lists_split" id="I-TqU;O9mck]VAf20jSO"> <mutation mode="SPLIT"></mutation> <field name="MODE">SPLIT</field> <value name="INPUT"> <block type="on_source" id="`$[;ZwP~[t62KKd10nOF"> <field name="ATTR">state.val</field> </block> </value> <value name="DELIM"> <shadow type="text" id="70Y1T7y.mv[)XM`@{6:w"> <field name="TEXT">,</field> </shadow> </value> </block> </value> <next> <block type="variables_set" id="wY4Jbg4*izkFGueErlqD"> <field name="VAR" id="e%4dw~|?#N7?ElIpOSX.">Zeit1</field> <value name="VALUE"> <block type="lists_getIndex" id="Rf=Cx/]sVr)3V2kvJ-wl"> <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="k5{vdHA)TJT%8AclC:(z"> <field name="VAR" id="d$VYHI2Oswd~cr8]=Ot2">string_Details</field> </block> </value> <value name="AT"> <block type="math_number" id=")Zuc{3Bb9MTZWaSeFYob"> <field name="NUM">1</field> </block> </value> </block> </value> <next> <block type="variables_set" id="`w~}{66%{PS^RYgkQ5$h"> <field name="VAR" id="d(SX?~mKqY,czb9Cqq5/">Zeit2</field> <value name="VALUE"> <block type="lists_getIndex" id="_Wn}(^O+AZ6x-|auanrm"> <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=")sAg@c0}^P:8V4X:(BeR"> <field name="VAR" id="d$VYHI2Oswd~cr8]=Ot2">string_Details</field> </block> </value> <value name="AT"> <block type="math_number" id="_lRgqY,RiNtVR*fdhvV1"> <field name="NUM">2</field> </block> </value> </block> </value> <next> <block type="variables_set" id="Q@-*N3!wUqpeq:=W6Dfn"> <field name="VAR" id="UJzoK`PB6J:Q;FkN2_B{">Zeit3</field> <value name="VALUE"> <block type="lists_getIndex" id="b-[cVuuPZ?DF9@j^szXB"> <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="DW2L6n{m.],tSW24}e?C"> <field name="VAR" id="d$VYHI2Oswd~cr8]=Ot2">string_Details</field> </block> </value> <value name="AT"> <block type="math_number" id="}dLbe9#IP7K17lwOt5{#"> <field name="NUM">3</field> </block> </value> </block> </value> <next> <block type="controls_if" id="CO/IJkKBnHK.[]JLzeb4"> <value name="IF0"> <block type="logic_operation" id="]EUgJll6J0F$hl;:WK^9" inline="false"> <field name="OP">OR</field> <value name="A"> <block type="logic_compare" id="~r4!+Xs3MVHk{KQEX_Pq"> <field name="OP">EQ</field> <value name="A"> <block type="variables_get" id="TkaktvliMS`Bz#H]pQXk"> <field name="VAR" id="e%4dw~|?#N7?ElIpOSX.">Zeit1</field> </block> </value> <value name="B"> <block type="math_number" id="]7jys;C~f-%jGTGq.`}c"> <field name="NUM">0</field> </block> </value> </block> </value> <value name="B"> <block type="logic_operation" id="X/v!1E}M(d7/!y`SYwbe" inline="false"> <field name="OP">OR</field> <value name="A"> <block type="logic_compare" id=",$mh#3V+,C1H8VHBVUtw"> <field name="OP">EQ</field> <value name="A"> <block type="variables_get" id="={;4q.]*MH*XWNX5x@J#"> <field name="VAR" id="d(SX?~mKqY,czb9Cqq5/">Zeit2</field> </block> </value> <value name="B"> <block type="math_number" id="|5H=Y;zAC,Kpy@(%Lz$2"> <field name="NUM">0</field> </block> </value> </block> </value> <value name="B"> <block type="logic_compare" id="Sc3q%S2xgXb!uHlddp!w"> <field name="OP">EQ</field> <value name="A"> <block type="variables_get" id="Gww|,Fk9X:5x[5M%q:Xd"> <field name="VAR" id="UJzoK`PB6J:Q;FkN2_B{">Zeit3</field> </block> </value> <value name="B"> <block type="math_number" id="o5,Vk%:51W(g{;MMoP[`"> <field name="NUM">0</field> </block> </value> </block> </value> </block> </value> </block> </value> <statement name="DO0"> <block type="controls_if" id="K+*-J|uA{gcI4.uR0sVy"> <value name="IF0"> <block type="logic_compare" id="+_G9otj^ER0J{[LQD4t_"> <field name="OP">LT</field> <value name="A"> <block type="get_value" id="RXuRX$y|$cA#;RXW!;~6"> <field name="ATTR">val</field> <field name="OID">tibber.0.priceInfo.today.00.total</field> </block> </value> <value name="B"> <block type="variables_get" id="#s~j9P}KSvw2+8SOVZsW"> <field name="VAR" id="zY/pnWZfu]uLCS;lYHaw">Strompreis</field> </block> </value> </block> </value> <statement name="DO0"> <block type="update" id="CJtl~i(0)1uL3}0{QbEE"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">0_userdata.0.Tibber.Bester_Preis.0_Uhr</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="logic_boolean" id="ss2V9f)3_v5vs=!q_(iS"> <field name="BOOL">TRUE</field> </block> </value> <next> <block type="timeouts_wait" id="5eN%fHgUbs0oViZ2Yd*6"> <field name="DELAY">62</field> <field name="UNIT">min</field> <next> <block type="update" id="0$T|0SfNY]N#!d24t:1J"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">0_userdata.0.Tibber.Bester_Preis.0_Uhr</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="logic_boolean" id="LHoXvkZ;o07KdO6obvXs"> <field name="BOOL">FALSE</field> </block> </value> </block> </next> </block> </next> </block> </statement> </block> </statement> <next> <block type="controls_if" id="`U`Bq2Rm_Rxzldj:[xl{"> <value name="IF0"> <block type="logic_operation" id=",*ipP!Z$nk7{{-6fj57T" inline="false"> <field name="OP">OR</field> <value name="A"> <block type="logic_compare" id="cI5DK#dOuz/C.ceG-g_C"> <field name="OP">EQ</field> <value name="A"> <block type="variables_get" id="zg?IYaR.dYK]TT4xC4+w"> <field name="VAR" id="e%4dw~|?#N7?ElIpOSX.">Zeit1</field> </block> </value> <value name="B"> <block type="math_number" id="L,9|:twm?LR4N|mTH,d:"> <field name="NUM">1</field> </block> </value> </block> </value> <value name="B"> <block type="logic_operation" id="/Vm/Biu3!R?,sVm5UALl" inline="false"> <field name="OP">OR</field> <value name="A"> <block type="logic_compare" id="ooj}Dn:7pGp_HqV*dIDL"> <field name="OP">EQ</field> <value name="A"> <block type="variables_get" id="||Om^$/5d2bcfGw_/HJ+"> <field name="VAR" id="d(SX?~mKqY,czb9Cqq5/">Zeit2</field> </block> </value> <value name="B"> <block type="math_number" id="GkhE~@DmA)Ho1{fF_/}J"> <field name="NUM">1</field> </block> </value> </block> </value> <value name="B"> <block type="logic_compare" id="9e}p+_Bh`|T3H0N4Y4n:"> <field name="OP">EQ</field> <value name="A"> <block type="variables_get" id="fvu^=(.BveL2#x^Z-?-L"> <field name="VAR" id="UJzoK`PB6J:Q;FkN2_B{">Zeit3</field> </block> </value> <value name="B"> <block type="math_number" id=".*[[x[i5-,X%}8B:Ai)_"> <field name="NUM">1</field> </block> </value> </block> </value> </block> </value> </block> </value> <statement name="DO0"> <block type="controls_if" id="58JbqrnN/f8OexE:;bzh"> <value name="IF0"> <block type="logic_compare" id="[C@]Tvk7dmw9t5Z}68j!"> <field name="OP">LT</field> <value name="A"> <block type="get_value" id="A9jFv]!{g`1RP$ejqEkF"> <field name="ATTR">val</field> <field name="OID">tibber.0.priceInfo.today.01.total</field> </block> </value> <value name="B"> <block type="variables_get" id="MhZ+J{D,V+[QEPl2-+!y"> <field name="VAR" id="zY/pnWZfu]uLCS;lYHaw">Strompreis</field> </block> </value> </block> </value> <statement name="DO0"> <block type="update" id="F9..)%3G@MhE51-v-qnX"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">0_userdata.0.Tibber.Bester_Preis.1_Uhr</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="logic_boolean" id="rt9EQPd/dkqsy~G$lxTy"> <field name="BOOL">TRUE</field> </block> </value> <next> <block type="timeouts_wait" id="qNfO8/G4(Ks4s9eZ=V-q"> <field name="DELAY">62</field> <field name="UNIT">min</field> <next> <block type="update" id="U}AXz0{~O_^ol}RH8{+l"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">0_userdata.0.Tibber.Bester_Preis.1_Uhr</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="logic_boolean" id="gsk=:2t$hB$:-?n9:x!`"> <field name="BOOL">FALSE</field> </block> </value> </block> </next> </block> </next> </block> </statement> </block> </statement> <next> <block type="controls_if" id="/5)e5i{(f__!L7[NuVR!"> <value name="IF0"> <block type="logic_operation" id="#Ej#[hL#aodF?N7e|ANW" inline="false"> <field name="OP">OR</field> <value name="A"> <block type="logic_compare" id=")Y78wdH#5XLMZ9wUzp#O"> <field name="OP">EQ</field> <value name="A"> <block type="variables_get" id="?Fj8#C2WnJDt~E$DeGBv"> <field name="VAR" id="e%4dw~|?#N7?ElIpOSX.">Zeit1</field> </block> </value> <value name="B"> <block type="math_number" id="L0XQPDTrE09TsUI(8?n1"> <field name="NUM">2</field> </block> </value> </block> </value> <value name="B"> <block type="logic_operation" id="eW9=cv$YmF63)%t3I#|J" inline="false"> <field name="OP">OR</field> <value name="A"> <block type="logic_compare" id="@%3Q.}+e?Y:k0butfV%N"> <field name="OP">EQ</field> <value name="A"> <block type="variables_get" id="T/o.91$eg1v?x0sdcKdQ"> <field name="VAR" id="d(SX?~mKqY,czb9Cqq5/">Zeit2</field> </block> </value> <value name="B"> <block type="math_number" id="G%lhd/**q;A*V$1)vQ5)"> <field name="NUM">2</field> </block> </value> </block> </value> <value name="B"> <block type="logic_compare" id="RYqym6vd^C5lsCxYcPx+"> <field name="OP">EQ</field> <value name="A"> <block type="variables_get" id="+.dhtW^x9+NF@AqDGbg/"> <field name="VAR" id="UJzoK`PB6J:Q;FkN2_B{">Zeit3</field> </block> </value> <value name="B"> <block type="math_number" id="_B,ZAsI#V3@kl;D3e-!#"> <field name="NUM">2</field> </block> </value> </block> </value> </block> </value> </block> </value> <statement name="DO0"> <block type="controls_if" id=".Z:sU0lfx~06Di}sRnd{"> <value name="IF0"> <block type="logic_compare" id="W$mMwpw35|8T,I={JYn+"> <field name="OP">LT</field> <value name="A"> <block type="get_value" id="L[nsLct|FKb6D(.26l*Y"> <field name="ATTR">val</field> <field name="OID">tibber.0.priceInfo.today.02.total</field> </block> </value> <value name="B"> <block type="variables_get" id="b|90t(N$z[_$t5aA2xaa"> <field name="VAR" id="zY/pnWZfu]uLCS;lYHaw">Strompreis</field> </block> </value> </block> </value> <statement name="DO0"> <block type="update" id="1LVnwRU^f0T@uJ19/]fW"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">0_userdata.0.Tibber.Bester_Preis.2_Uhr</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="logic_boolean" id="LHd.{gAiFWl+XD0{kG)5"> <field name="BOOL">TRUE</field> </block> </value> <next> <block type="timeouts_wait" id="-}5C[qoKK[4%-vrkR](^"> <field name="DELAY">62</field> <field name="UNIT">min</field> <next> <block type="update" id="1d6Dm3U%U!l)Y2jC]ct7"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">0_userdata.0.Tibber.Bester_Preis.2_Uhr</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="logic_boolean" id="=NFouMv.bCOpRJ*amY@A"> <field name="BOOL">FALSE</field> </block> </value> </block> </next> </block> </next> </block> </statement> </block> </statement> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </statement> </block>
Würde mich über eine Vereinfachung freuen, wenn nciht muß ich es 24 mal schreiben. Danke im Voraus.
Hier als Bild.
-
@babl bitte das Blockly auch zeigen!
https://forum.iobroker.net/topic/51555/hinweise-für-gute-forenbeiträge/1
-
Ich würde es als Liste belassen und wie in meinem Beispiel aus deinem Post von eben mit einer Schleife lösen.
-
@david-g sorry das ist mir zu hoch, aber ich habe noch ein klitzekleines problem und zwar im string bekomme ich folgendes
[20,21,22]
Nun nehme ich den 1. Teil, 2.Teil und 3. Teil beim 2. Teil funktioniert die Abnahme, aber beim 1. und 3 Teil habe ich die eckigen Klammern, wie kann ich die denn löschen?
-
Es gibt bestimmt einen besseren Weg.
Ich würde bevor ich die Liste erstelle mit den Text Bausteinen die erste und letzte Stelle entfernen.Nimm 2 bis 8.
Oder besser so, falls es einstelligen Uhrzeiten gibt:
-
@david-g es geht mit der konvertierung als json dann sind die klammern weg
-
Okay, oder so.
Mein Beispiel von eben war fehlerhaft.Wobei der Weg über json schon besser ist
Erkenne die nicht immer am ersten Blick. -