- Home
- Deutsch
- Skripten / Logik
- Blockly InfluxDB2.0 Flux Abfrage
Blockly InfluxDB2.0 Flux Abfrage
This topic has been deleted. Only users with topic management privileges can see it.
-
Hallo zusammen,
mir ging es darum den niedrigsten Preis der letzten 14 Tage zu ermitteln.
Ich habe mit Hilfe der Suche nichts konkretes gefunden wie man mit Blockly einen Wert aus der InfluxDB Datenbank bekommen kann. So hab ich selber gefummelt.
Was dabei raus gekommen ist möchte ich mit euch teilen, vielleicht kann jemand das ein oder andere Schnipsel gebrauchen.<xml xmlns="https://developers.google.com/blockly/xml"> <variables> <variable id=":)VLwK/`@H+J(LM#$WD7">flux</variable> <variable id=".5z}V1WTXA6xD^rmM@W4">preis</variable> <variable id="Hap*,T)oNQNM[M8bZeb7">result</variable> <variable id="19e+]})FfXk}~`Wj.4bM">htmlString</variable> </variables> <block type="schedule" id="n=UEN2;yjIT1`l#FdcV_" x="-762" y="-1037"> <field name="SCHEDULE">*/60 * * * *</field> <statement name="STATEMENT"> <block type="variables_set" id="x45T#QqEweP.8DbaXVqx"> <field name="VAR" id=":)VLwK/`@H+J(LM#$WD7">flux</field> <value name="VALUE"> <block type="text_join" id="o9Vd,Q~U,{!3is[fPCf."> <mutation items="7"></mutation> <value name="ADD0"> <block type="text" id="?I]TaO6_Vbp6gDEIQkdm"> <field name="TEXT">from(bucket: "ioBroker")</field> </block> </value> <value name="ADD1"> <block type="text" id="yj4=}t)xOExa-Vb!lRg5"> <field name="TEXT"> |> range(start: -14d, stop: now())</field> </block> </value> <value name="ADD2"> <block type="text" id="$wF;t#c|U7%H4c3VEjr-"> <field name="TEXT"> |> filter(fn: (r) => r["_measurement"] == "DP_Guenstigste")</field> </block> </value> <value name="ADD3"> <block type="text" id="T7*$6*6|Y::w)O)CnG}m"> <field name="TEXT"> |> filter(fn: (r) => r["_field"] == "value")</field> </block> </value> <value name="ADD4"> <block type="text" id="$K[IvM%br(mA/cThGg80"> <field name="TEXT"> |> filter(fn: (r) => r._value > 0)</field> </block> </value> <value name="ADD5"> <block type="text" id=".{=s3%v;VOKcjo8,LjuJ"> <field name="TEXT"> |> group()</field> </block> </value> <value name="ADD6"> <block type="text" id="M;0{W([Va4?^;%p)r0{x"> <field name="TEXT"> |> min()</field> </block> </value> </block> </value> <next> <block type="sendto_custom" id="5y7]CToD:3Ygw}FhT%(D"> <mutation xmlns="http://www.w3.org/1999/xhtml" items="" with_statement="true"></mutation> <field name="INSTANCE">influxdb.0</field> <field name="COMMAND">query</field> <field name="LOG"></field> <field name="WITH_STATEMENT">TRUE</field> <value name="ARG0"> <shadow type="text" id="NNx0rHt6*yq21~HguTF2"> <field name="TEXT">from(bucket: "ioBroker") |> range(start: -14d, stop: now()) |> filter(fn: (r) => r["_measurement"] == "DP_Guenstigste") |> filter(fn: (r) => r["_field"] == "value") |> filter(fn: (r) => r._value > 0) |> group() |> min()</field> </shadow> <block type="variables_get" id="B}$z9o?iyz%Y*wBKcvDF"> <field name="VAR" id=":)VLwK/`@H+J(LM#$WD7">flux</field> </block> </value> <statement name="STATEMENT"> <block type="controls_if" id="@q#iNuUr!:m7zob|9%)u"> <mutation else="1"></mutation> <value name="IF0"> <block type="logic_compare" id="|vlsW/V*`9wqY9BOp$Cx"> <field name="OP">NEQ</field> <value name="A"> <block type="get_attr" id="^9J$l,fj?KhQ@qUB:Nas"> <value name="PATH"> <shadow type="text" id="~z[BTi$mMMYZ+GcomoOq"> <field name="TEXT">error</field> </shadow> </value> <value name="OBJECT"> <block type="variables_get" id="N@T;SzLIsoETGcO$H+ri"> <field name="VAR" id="Hap*,T)oNQNM[M8bZeb7">result</field> </block> </value> </block> </value> <value name="B"> <block type="logic_null" id="+U3-sX~0PE)=BKfCuo7O"></block> </value> </block> </value> <statement name="DO0"> <block type="debug" id="LCT~%[BmemUbm?b4]W6U" inline="true"> <field name="Severity">error</field> <value name="TEXT"> <shadow type="text" id="mDRzWYEa1NzHsf1:2u16"> <field name="TEXT">test</field> </shadow> <block type="get_attr" id="8G61*~d~XGk2qY$ng{D4"> <value name="PATH"> <shadow type="text" id="45h$8w}|$sRP,uLQ(70%"> <field name="TEXT">error</field> </shadow> </value> <value name="OBJECT"> <block type="variables_get" id="LIT!%WT~ykvRmkF=1Gc9"> <field name="VAR" id="Hap*,T)oNQNM[M8bZeb7">result</field> </block> </value> </block> </value> </block> </statement> <statement name="ELSE"> <block type="debug" id="i.3k|[CfyGSyBVLFIjB2" inline="true" disabled="true"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id=";}f4Nyq)G@a^KU.L=B$("> <field name="TEXT">test</field> </shadow> <block type="convert_object2json" id="l-QhF#043ulT351D8qrO"> <field name="PRETTIFY">TRUE</field> <value name="VALUE"> <block type="variables_get" id="7hwW#k]308Ky.)yG7JEF"> <field name="VAR" id="Hap*,T)oNQNM[M8bZeb7">result</field> </block> </value> </block> </value> <next> <block type="variables_set" id="DD6;G(Wo]rIFaI+6.8:?"> <field name="VAR" id=".5z}V1WTXA6xD^rmM@W4">preis</field> <value name="VALUE"> <block type="convert_tostring" id="MQ|=t3[21rC.~l3cFZea"> <value name="VALUE"> <block type="get_attr" id="n36f=MeXwJ3Yc1kOE1/$"> <value name="PATH"> <shadow type="text" id="(b0I9y0aoY#dd84CK7KS"> <field name="TEXT">result.0.0._value</field> </shadow> </value> <value name="OBJECT"> <block type="convert_object2json" id="ERm+qpC!vRo1]{;r$+$("> <field name="PRETTIFY">TRUE</field> <value name="VALUE"> <block type="variables_get" id="+6+4;B%#/G*bG`j}yEgo"> <field name="VAR" id="Hap*,T)oNQNM[M8bZeb7">result</field> </block> </value> </block> </value> </block> </value> </block> </value> <next> <block type="comment" id="KoZ]ZSByDTlWb4^s_)xQ"> <field name="COMMENT">Kommentar</field> <next> <block type="debug" id="-M)_Dgrsw.+.x@5y1*()" inline="true" disabled="true"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text"> <field name="TEXT">test</field> </shadow> <block type="variables_get" id="e--Fk%lR(K!5Z96CC{uu"> <field name="VAR" id=".5z}V1WTXA6xD^rmM@W4">preis</field> </block> </value> <next> <block type="controls_if" id="iuLo^lOy^Qg)/#[A*q(L"> <mutation else="1"></mutation> <value name="IF0"> <block type="logic_compare" id="U.wOefdDK@:;kt3`^MmY"> <field name="OP">EQ</field> <value name="A"> <block type="text_length" id="-~ACns1F5u7EF=f(qfVs"> <value name="VALUE"> <shadow type="text" id=":xhtsG,UW?hdA9r~/IJ+"> <field name="TEXT">abc</field> </shadow> <block type="variables_get" id="[wde$^9G?veK#O[!#aK3"> <field name="VAR" id=".5z}V1WTXA6xD^rmM@W4">preis</field> </block> </value> </block> </value> <value name="B"> <block type="math_number" id="O};wwWf9LLIWspXZ_ZG."> <field name="NUM">5</field> </block> </value> </block> </value> <statement name="DO0"> <block type="variables_set" id="vd3MOaB/E.B.%`GT+Fw%"> <field name="VAR" id="19e+]})FfXk}~`Wj.4bM">htmlString</field> <value name="VALUE"> <block type="text_join" id="BNP,)B,LyiB6@@zuP`MQ"> <mutation items="5"></mutation> <value name="ADD0"> <block type="text" id="Nr2XbzF(;A*k`y8(DXE5"> <field name="TEXT"><span class="station_open"></field> </block> </value> <value name="ADD1"> <block type="text_getSubstring" id="!1KEwrCzBu%cT^;blwvN"> <mutation at1="false" at2="true"></mutation> <field name="WHERE1">FIRST</field> <field name="WHERE2">FROM_END</field> <value name="STRING"> <block type="variables_get" id="GL]X=,r4[-|2qWDQJds}"> <field name="VAR" id=".5z}V1WTXA6xD^rmM@W4">preis</field> </block> </value> <value name="AT2"> <block type="math_number" id="44i2DFWiG46^!/DI[e0n"> <field name="NUM">2</field> </block> </value> </block> </value> <value name="ADD2"> <block type="text" id="tq/!H0_6OK3.h|##H,!/"> <field name="TEXT"><sup style="font-size: 50%"></field> </block> </value> <value name="ADD3"> <block type="text_charAt" id="C7-+51yO(qm[2Mn2l|Uf"> <mutation at="true"></mutation> <field name="WHERE">FROM_END</field> <value name="VALUE"> <block type="variables_get" id="`7MC`CAP(bGhlG,u.9n:"> <field name="VAR" id=".5z}V1WTXA6xD^rmM@W4">preis</field> </block> </value> <value name="AT"> <block type="math_number" id="ZRGIl0[.5EC=iuSbU7Xj"> <field name="NUM">1</field> </block> </value> </block> </value> <value name="ADD4"> <block type="text" id="~vixZf=L=I?W#tN=#J9`"> <field name="TEXT"></sup> <span class="station_combined_euro">€</span></span></field> </block> </value> </block> </value> <next> <block type="update" id="}!6!8(47NX^9;U6C_G#a"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">0_userdata.0.Datenpunkte.Diesel14TageTiefstpreis</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="variables_get" id="%ge_Q6+64-Xvb0u@}{Mb"> <field name="VAR" id="19e+]})FfXk}~`Wj.4bM">htmlString</field> </block> </value> <next> <block type="debug" id="+Po4LYz|l3-bP_*!uMLD" inline="true" disabled="true"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="upBA@|x/?+tqJ;{2_X^+"> <field name="TEXT">test</field> </shadow> <block type="variables_get" id="@Nvf(injXf$Yw_H/!rZO"> <field name="VAR" id="19e+]})FfXk}~`Wj.4bM">htmlString</field> </block> </value> <next> <block type="debug" id="PA/=R6e@4[]/tuW5m,I3" inline="true"> <field name="Severity">log</field> <value name="TEXT"> <shadow type="text" id="[54tEV#3P+y$ZwK{^|g~"> <field name="TEXT">Diesel 14 Tage Tiefstpreis aktualisiert</field> </shadow> </value> </block> </next> </block> </next> </block> </next> </block> </statement> <statement name="ELSE"> <block type="debug" id="eG[!NGV)c1@lXqO0RRaA" inline="true"> <field name="Severity">warn</field> <value name="TEXT"> <shadow type="text" id="e;9g?#xrOkVdJvU?OQWj"> <field name="TEXT">length of the price string does not fit</field> </shadow> </value> </block> </statement> </block> </next> </block> </next> </block> </next> </block> </next> </block> </statement> </block> </statement> </block> </next> </block> </statement> </block> </xml>
Blockly ist zur Diskussion freigegeben
MfG Ralf
-
@spacerx Bitte auch einen Export vom Blockly freigeben (Spoiler + Code). Danke.
-
@mcu OK, Spoiler mit Export hinzugefügt.
-
@spacerx Hast das "Measurement" selbst definiert?
-
@mcu das habe ich mit dem Querybuilder von InfluxDB erstellt und wird von einem Datenpunkt unter Tankerkönig geloggt.