Als Sylvester 2019 näher rückte fiel mir wieder der Luftdaten-Adapter ein um die Feinstaubbelastung zu monitoren.
Zum einen aus reinem Interesse an den Daten, zum anderen weil ich außerdem im Bereich einiger Petrochemie wohne und ein "Warnsystem" aufbauen wollte um im Falle einer zu hohen Immission die Fenster zu schließen.
Um solche Daten zu erhalten gibt es bisher in ioBroker den Luftdaten-Adapter , der die Info von Luftdaten.info holt sowie ein Skript , welches die Informationen über vom Umweltbundesamt zur Verfügung gestellten Daten abruft.
Im Laufe des Versuches diese Daten zu nutzen entspann sich eine rege Diskussion
Die Daten von Luftdaten.info werden weitestgehend mit selbstgebaute Sensoren ermittelt. Auf deren Seite gibt es auch die Bauanleitung und Firmware dafür.
Der dort verwendete PM-Sensor ist jedoch nicht für relative Luftfeuchte >70% rH spezifiziert und liefert dann zu hohe Werte.
Die Daten des UBA scheinen sich jeweils auf den Vortag zu beziehen, da das BImSchG die Grenzwerte auf den Tagesmittelwert bezieht, der bekanntlich erst am (Morgen des) nächsten Tag ermittelt werden kann.
Auch die Webseiten der diversen Landesämter waren nicht einfach auszulesen..
Letztendlich war die Seite von OpenSenseMap eine gute Quelle für weitere Informationen.
Auch dort werden Selbstbausensoren verwendet, Die Daten enthalten jedoch die Bezeichnung des verbauten Sensors so dass man die Werte entsprechend einschätzen kann. Außerdem liefern die Stationen auch weitere Informationen wie eben die Luftfeuchte an dem Messort, so dass man zum einen eine Einschätzung der Richtigkeit und vielleicht eine Korrektur der Werte durchführen kann.
vorweg:
Ich bin kein Skripter. Dies ist mein erstes etwas größeres Projekt. Ich mich endlich etwas tiefer in JavaScript einarbeiten, und da kam so eine Aufgabe gerade richtig, mich mit Variablen und Funktionen zu beschäftigen.
Daher habe ich es auch (noch) in Blockly durchgeführt. Leider gibt es dort (noch) nicht alle Blöcke, mit denen eine einfachere Abarbeitung möglich gewesen wäre.
Da die Daten als JSON vorliegen wäre auch der über das direkte Auslesen des JSON möglich gewesen - das Skript sollte aber für mich später auch für HTML und plain Text Seiten funktionieren.
Code
Der momentan aktuelle Code ist dieser:
Spoiler
<xml xmlns="http://www.w3.org/1999/xhtml">
<variables>
<variable type="" id="|zrtv-e98n%+)6SmMQGz">Anfang</variable>
<variable type="" id="#UHnaMpV=lSawq.B$u/_">tausch</variable>
<variable type="" id="%g9ob`$FnQ!zF#~C8Ret">Ende</variable>
<variable type="" id="2DY4,TA7#ra1oA6Bz925">URL</variable>
<variable type="" id="+7xcGWJ647XP265eD.Ll">JSON</variable>
<variable type="" id="d[?QaF(N/mc|eq/IOy75">Param1</variable>
<variable type="" id="@hb0FIlN^F6YBg^(y}Pm">Station</variable>
<variable type="" id="IN6AA6TiKW]?_gBN5J!v">SensemapJson</variable>
<variable type="" id="?%Q@y58(tY1cXr7e17Gc">Unit1</variable>
<variable type="" id="kXTaix[lp7nNNGO=Zc+@">result</variable>
<variable type="" id="s@1tudN:J=lhR59TGl{3">Sensor1</variable>
<variable type="" id="G7^Cu8s)%C@Yuc,yq:|[">Wert1</variable>
<variable type="" id="Dj2Zyap_1N~eP!+x^$`B">Pfad</variable>
</variables>
<block type="variables_set" id="FQtuv{|Ya/Ot:jPQ_n7`" x="62" y="-912">
<field name="VAR" id="|zrtv-e98n%+)6SmMQGz" variabletype="">Anfang</field>
<value name="VALUE">
<block type="math_number" id="Kv4sBHn,XC@!]A7I[f(i">
<field name="NUM">0</field>
</block>
</value>
<next>
<block type="variables_set" id="P4j]IyBxs.:ehO`N#lN.">
<field name="VAR" id="%g9ob`$FnQ!zF#~C8Ret" variabletype="">Ende</field>
<value name="VALUE">
<block type="math_number" id="g$70HI]Kt!Q.)tZQK[Pg">
<field name="NUM">0</field>
</block>
</value>
<next>
<block type="variables_set" id="tIZY3oqO)|P0~/DcO);}">
<field name="VAR" id="+7xcGWJ647XP265eD.Ll" variabletype="">JSON</field>
<value name="VALUE">
<block type="text" id="aJ%kCZCrT#wMIt-|-$uJ">
<field name="TEXT">leer</field>
</block>
</value>
<next>
<block type="variables_set" id="5WmS{8Gu)!|OLFGxd1*_">
<field name="VAR" id="d[?QaF(N/mc|eq/IOy75" variabletype="">Param1</field>
<value name="VALUE">
<block type="text" id="sk7Oa[r2x[O+}zh]jh;I">
<field name="TEXT">leer</field>
</block>
</value>
<next>
<block type="variables_set" id="agz5l]A3M1?R5tjDMM|`">
<field name="VAR" id="?%Q@y58(tY1cXr7e17Gc" variabletype="">Unit1</field>
<value name="VALUE">
<block type="text" id=";%v6zGGw8ltr/KfOT9m-">
<field name="TEXT">leer</field>
</block>
</value>
<next>
<block type="variables_set" id="@R`~[Kt_N@ZwqJ$q*AYA">
<field name="VAR" id="s@1tudN:J=lhR59TGl{3" variabletype="">Sensor1</field>
<value name="VALUE">
<block type="text" id="~OUigK^EGJrnUq1z5pK`">
<field name="TEXT">leer</field>
</block>
</value>
<next>
<block type="variables_set" id="L1BTNCNCyf$`cFoeHi^b">
<field name="VAR" id="G7^Cu8s)%C@Yuc,yq:|[" variabletype="">Wert1</field>
<value name="VALUE">
<block type="math_number" id="bbN[Tip0g;Q)H`aTIOBS">
<field name="NUM">0</field>
</block>
</value>
<next>
<block type="variables_set" id="uK/sjNNqX.M=;f:vwWKx">
<field name="VAR" id="IN6AA6TiKW]?_gBN5J!v" variabletype="">SensemapJson</field>
<value name="VALUE">
<block type="text" id=":EK7!rwUA9Cr(hS._@?a">
<field name="TEXT">leer</field>
</block>
</value>
<next>
<block type="comment" id="SO{1x)9(IrO=t/HzhQ{q">
<field name="COMMENT">StationsID hier eintragen</field>
<next>
<block type="variables_set" id="yf|Zs$Eg)0-sY-z@UPq%">
<field name="VAR" id="@hb0FIlN^F6YBg^(y}Pm" variabletype="">Station</field>
<value name="VALUE">
<block type="text" id="{v/]|(@@$?rt:K?ykRBS">
<field name="TEXT">5daad22b25683a001a6260f5</field>
</block>
</value>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
<block type="procedures_defnoreturn" id="S0*nkNsu`02K8Z[2=4oC" x="988" y="-937">
<field name="NAME">Sensorwerte_auslesen</field>
<comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
<statement name="STACK">
<block type="variables_set" id="c0[adpg`4BA?`19@Z+G/">
<field name="VAR" id="|zrtv-e98n%+)6SmMQGz" variabletype="">Anfang</field>
<value name="VALUE">
<block type="text_indexOf" id=",Ifp_}FhWon~]!uqsSaz">
<field name="END">FIRST</field>
<value name="VALUE">
<block type="variables_get" id="{PSVZc3Mt]U=2EX!8|y.">
<field name="VAR" id="+7xcGWJ647XP265eD.Ll" variabletype="">JSON</field>
</block>
</value>
<value name="FIND">
<shadow type="text" id=":QjI.87@s4}se7F`#0~0">
<field name="TEXT">tle":"</field>
</shadow>
</value>
</block>
</value>
<next>
<block type="variables_set" id="ZbM/.4%L?dlr7LC6~d.~">
<field name="VAR" id="%g9ob`$FnQ!zF#~C8Ret" variabletype="">Ende</field>
<value name="VALUE">
<block type="text_indexOf" id="Ky}|pA4xEq}19rIH1|wa">
<field name="END">FIRST</field>
<value name="VALUE">
<block type="variables_get" id="vm@=7U5{//Z@-VC2!C.r">
<field name="VAR" id="+7xcGWJ647XP265eD.Ll" variabletype="">JSON</field>
</block>
</value>
<value name="FIND">
<shadow type="text" id="vqIa??-dUtC3tx[?y/%5">
<field name="TEXT">","uni</field>
</shadow>
</value>
</block>
</value>
<next>
<block type="variables_set" id="hI7XEC?nQ.ybOxR=pim8">
<field name="VAR" id="d[?QaF(N/mc|eq/IOy75" variabletype="">Param1</field>
<value name="VALUE">
<block type="convert_tostring" id="C*XQ}C]lyC=ai{CU7i5~">
<value name="VALUE">
<block type="text_getSubstring" id="H|t5#|Q,T#H/n$;$dM?[">
<mutation at1="true" at2="true"></mutation>
<field name="WHERE1">FROM_START</field>
<field name="WHERE2">FROM_START</field>
<value name="STRING">
<block type="variables_get" id="]`@9[9V_f5,bI3dR|Sn9">
<field name="VAR" id="+7xcGWJ647XP265eD.Ll" variabletype="">JSON</field>
</block>
</value>
<value name="AT1">
<block type="math_arithmetic" id="F}dh5=wXD/kE3,CQPb^n">
<field name="OP">ADD</field>
<value name="A">
<shadow type="math_number" id="uYdt.$Ve!GC|WDs/^5]u">
<field name="NUM">1</field>
</shadow>
<block type="variables_get" id="C!E[O!zbDhe=|sXd9/u9">
<field name="VAR" id="|zrtv-e98n%+)6SmMQGz" variabletype="">Anfang</field>
</block>
</value>
<value name="B">
<shadow type="math_number" id="lBUyeQ}#rN^8ab`lfRDD">
<field name="NUM">6</field>
</shadow>
</value>
</block>
</value>
<value name="AT2">
<block type="math_arithmetic" id="hb{d,FiAoPA=b2u8OHkt">
<field name="OP">MINUS</field>
<value name="A">
<shadow type="math_number" id="uYdt.$Ve!GC|WDs/^5]u">
<field name="NUM">1</field>
</shadow>
<block type="variables_get" id="FcT4LNed=RL+4CY_t_i]">
<field name="VAR" id="%g9ob`$FnQ!zF#~C8Ret" variabletype="">Ende</field>
</block>
</value>
<value name="B">
<shadow type="math_number" id="7Pgpj2}emCKVmwM#7OvV">
<field name="NUM">1</field>
</shadow>
</value>
</block>
</value>
</block>
</value>
</block>
</value>
<next>
<block type="variables_set" id="c7C2u6X2#UffWFDl=8Gq">
<field name="VAR" id="d[?QaF(N/mc|eq/IOy75" variabletype="">Param1</field>
<value name="VALUE">
<block type="procedures_callcustomreturn" id="%wzpiI/a@QQAjXYmlR6j">
<mutation name="besserer Punktekiller">
<arg name="tausch"></arg>
</mutation>
<value name="ARG0">
<block type="variables_get" id=":MP2_-vmlCh$EopvE$?q">
<field name="VAR" id="d[?QaF(N/mc|eq/IOy75" variabletype="">Param1</field>
</block>
</value>
</block>
</value>
<next>
<block type="variables_set" id="1#:Sf4T5R@hTztixi3xL">
<field name="VAR" id="|zrtv-e98n%+)6SmMQGz" variabletype="">Anfang</field>
<value name="VALUE">
<block type="text_indexOf" id="?bbVO}89ok~c1:54AAL*">
<field name="END">FIRST</field>
<value name="VALUE">
<block type="variables_get" id="chyaG7ihvA~HWj8QLIw2">
<field name="VAR" id="+7xcGWJ647XP265eD.Ll" variabletype="">JSON</field>
</block>
</value>
<value name="FIND">
<shadow type="text" id="j.,UtM!x1ax1T7Jhyr2)">
<field name="TEXT">nit":"</field>
</shadow>
</value>
</block>
</value>
<next>
<block type="variables_set" id="FECM,;fW1}3L+?T|MBEt">
<field name="VAR" id="%g9ob`$FnQ!zF#~C8Ret" variabletype="">Ende</field>
<value name="VALUE">
<block type="text_indexOf" id="XFb#?n*^L=DiWeAyDo{{">
<field name="END">FIRST</field>
<value name="VALUE">
<block type="variables_get" id="hgTcpZGeW^icqqo}$Jmq">
<field name="VAR" id="+7xcGWJ647XP265eD.Ll" variabletype="">JSON</field>
</block>
</value>
<value name="FIND">
<shadow type="text" id="WnR}(d{It%ar@+MOj=k-">
<field name="TEXT">","sen</field>
</shadow>
</value>
</block>
</value>
<next>
<block type="controls_if" id="hR_r#gpr)H[Zc3qvcgE{">
<mutation else="1"></mutation>
<value name="IF0">
<block type="logic_compare" id="cx(1+^(%UG:}8yZtNOTd">
<field name="OP">EQ</field>
<value name="A">
<block type="variables_get" id="}Tj#s^zKP}KBz+6mn@mR">
<field name="VAR" id="d[?QaF(N/mc|eq/IOy75" variabletype="">Param1</field>
</block>
</value>
<value name="B">
<block type="text" id="A$mL|h8e0~0O-KD7js,W">
<field name="TEXT">Luftdruck</field>
</block>
</value>
</block>
</value>
<statement name="DO0">
<block type="variables_set" id="CiZ0)tI@8$,{1o2lc:1r">
<field name="VAR" id="?%Q@y58(tY1cXr7e17Gc" variabletype="">Unit1</field>
<value name="VALUE">
<block type="convert_tostring" id="ECk^JHX|+Rzq07bGN8!d">
<value name="VALUE">
<block type="text" id="(2d7^0D{z.!}q5@w.[-m">
<field name="TEXT">hPa</field>
</block>
</value>
</block>
</value>
</block>
</statement>
<statement name="ELSE">
<block type="variables_set" id="IBdVHUvt%i|B*_fq+`r%">
<field name="VAR" id="?%Q@y58(tY1cXr7e17Gc" variabletype="">Unit1</field>
<value name="VALUE">
<block type="convert_tostring" id="`hyGfP3yD|0SmuaUpL*G">
<value name="VALUE">
<block type="text_getSubstring" id="a~1zAziTK7_2w%lM1em-">
<mutation at1="true" at2="true"></mutation>
<field name="WHERE1">FROM_START</field>
<field name="WHERE2">FROM_START</field>
<value name="STRING">
<block type="variables_get" id="jksgw1yp+;sLL]N{]SaO">
<field name="VAR" id="+7xcGWJ647XP265eD.Ll" variabletype="">JSON</field>
</block>
</value>
<value name="AT1">
<block type="math_arithmetic" id="g27+8^AN3#=^49*z%hQU">
<field name="OP">ADD</field>
<value name="A">
<shadow type="math_number" id="uYdt.$Ve!GC|WDs/^5]u">
<field name="NUM">1</field>
</shadow>
<block type="variables_get" id="Qb2-2@20]f`?a`_62ip@">
<field name="VAR" id="|zrtv-e98n%+)6SmMQGz" variabletype="">Anfang</field>
</block>
</value>
<value name="B">
<shadow type="math_number" id="HqU`kd0a+jsNd5w_V7Ac">
<field name="NUM">6</field>
</shadow>
</value>
</block>
</value>
<value name="AT2">
<block type="math_arithmetic" id="u2jFPtyVOn]x~D!?x472">
<field name="OP">MINUS</field>
<value name="A">
<shadow type="math_number" id="uYdt.$Ve!GC|WDs/^5]u">
<field name="NUM">1</field>
</shadow>
<block type="variables_get" id="qqt4kx/8G*[TJ;13,zq!">
<field name="VAR" id="%g9ob`$FnQ!zF#~C8Ret" variabletype="">Ende</field>
</block>
</value>
<value name="B">
<shadow type="math_number" id="X9/f]q+I_Ceiz|*94f)g">
<field name="NUM">1</field>
</shadow>
</value>
</block>
</value>
</block>
</value>
</block>
</value>
</block>
</statement>
<next>
<block type="variables_set" id="33HNy-m9hQ.@x,,06u2[">
<field name="VAR" id="|zrtv-e98n%+)6SmMQGz" variabletype="">Anfang</field>
<value name="VALUE">
<block type="text_indexOf" id=",MM!^6Knj8Vd-=(k+K%6">
<field name="END">FIRST</field>
<value name="VALUE">
<block type="variables_get" id="vN}Uc(edJ(=,SrNFZ!B(">
<field name="VAR" id="+7xcGWJ647XP265eD.Ll" variabletype="">JSON</field>
</block>
</value>
<value name="FIND">
<shadow type="text" id="/DT!$G}3%:Vyw;F5lUG2">
<field name="TEXT">Type":"</field>
</shadow>
</value>
</block>
</value>
<next>
<block type="variables_set" id="*m4F$b$TO~o}r(O_%,Q;">
<field name="VAR" id="%g9ob`$FnQ!zF#~C8Ret" variabletype="">Ende</field>
<value name="VALUE">
<block type="text_indexOf" id="|pR9b1/m3/EvX3*3n%T$">
<field name="END">FIRST</field>
<value name="VALUE">
<block type="variables_get" id="2Lsy{l#to~XP]k|b#B{U">
<field name="VAR" id="+7xcGWJ647XP265eD.Ll" variabletype="">JSON</field>
</block>
</value>
<value name="FIND">
<shadow type="text" id="R3+JJk`.^}P[O9*OVI(;">
<field name="TEXT">","ico</field>
</shadow>
</value>
</block>
</value>
<next>
<block type="variables_set" id="zi_JF/7ZG2nnNN6-H+yf">
<field name="VAR" id="s@1tudN:J=lhR59TGl{3" variabletype="">Sensor1</field>
<value name="VALUE">
<block type="convert_tostring" id="|#K/cR7hW1x[T^beQU?q">
<value name="VALUE">
<block type="text_getSubstring" id="t_XOX5,2igg(E]UF9.UM">
<mutation at1="true" at2="true"></mutation>
<field name="WHERE1">FROM_START</field>
<field name="WHERE2">FROM_START</field>
<value name="STRING">
<block type="variables_get" id="Fn@vgJ8o_6bine]:,8|#">
<field name="VAR" id="+7xcGWJ647XP265eD.Ll" variabletype="">JSON</field>
</block>
</value>
<value name="AT1">
<block type="math_arithmetic" id="eE^Cqu7umn2}|%.[A.LY">
<field name="OP">ADD</field>
<value name="A">
<shadow type="math_number" id="uYdt.$Ve!GC|WDs/^5]u">
<field name="NUM">1</field>
</shadow>
<block type="variables_get" id="5HyE-}uIls!Ex*nm{C!=">
<field name="VAR" id="|zrtv-e98n%+)6SmMQGz" variabletype="">Anfang</field>
</block>
</value>
<value name="B">
<shadow type="math_number" id="RuVFkSl*`pZvj$`yAIza">
<field name="NUM">7</field>
</shadow>
</value>
</block>
</value>
<value name="AT2">
<block type="math_arithmetic" id="m%|25vuw6#q+U+vRb=Os">
<field name="OP">MINUS</field>
<value name="A">
<shadow type="math_number" id="uYdt.$Ve!GC|WDs/^5]u">
<field name="NUM">1</field>
</shadow>
<block type="variables_get" id="T^GKJa:jKjr(VQeu$:QL">
<field name="VAR" id="%g9ob`$FnQ!zF#~C8Ret" variabletype="">Ende</field>
</block>
</value>
<value name="B">
<shadow type="math_number" id="$;j=!Awvlt;)!QD#?a.%">
<field name="NUM">1</field>
</shadow>
</value>
</block>
</value>
</block>
</value>
</block>
</value>
<next>
<block type="variables_set" id="P8Sbo8:R6dJJrWy;Z2_C">
<field name="VAR" id="s@1tudN:J=lhR59TGl{3" variabletype="">Sensor1</field>
<value name="VALUE">
<block type="procedures_callcustomreturn" id=";BiMLknZ:+(+ns_R08iL">
<mutation name="besserer Punktekiller">
<arg name="tausch"></arg>
</mutation>
<value name="ARG0">
<block type="variables_get" id="8#i5#YK+8v{kCKBTg*wv">
<field name="VAR" id="s@1tudN:J=lhR59TGl{3" variabletype="">Sensor1</field>
</block>
</value>
</block>
</value>
<next>
<block type="variables_set" id="/0A~_.]v:Ze{tkYo]@NG">
<field name="VAR" id="|zrtv-e98n%+)6SmMQGz" variabletype="">Anfang</field>
<value name="VALUE">
<block type="text_indexOf" id="y~*$cEVANX`~sMxH%z,f">
<field name="END">FIRST</field>
<value name="VALUE">
<block type="variables_get" id="IR!4R-vTG)GyxSR`Lh1V">
<field name="VAR" id="+7xcGWJ647XP265eD.Ll" variabletype="">JSON</field>
</block>
</value>
<value name="FIND">
<shadow type="text" id="oR*pi7MJ3pLDZro)HR-0">
<field name="TEXT">lue":"</field>
</shadow>
</value>
</block>
</value>
<next>
<block type="variables_set" id="`HCUZb7mgfzPb%99ltI4">
<field name="VAR" id="%g9ob`$FnQ!zF#~C8Ret" variabletype="">Ende</field>
<value name="VALUE">
<block type="text_indexOf" id="V;)0%M$DHIf,YgbwpbAl">
<field name="END">FIRST</field>
<value name="VALUE">
<block type="variables_get" id="v/i0zZ,Bv~!Exy}A6(MK">
<field name="VAR" id="+7xcGWJ647XP265eD.Ll" variabletype="">JSON</field>
</block>
</value>
<value name="FIND">
<shadow type="text" id="IPJ~]J49PVN{.SKe2GF*">
<field name="TEXT">","cre</field>
</shadow>
</value>
</block>
</value>
<next>
<block type="controls_if" id="p(q*jC%{Cd+-X$LI+ps^">
<mutation else="1"></mutation>
<value name="IF0">
<block type="logic_compare" id=",}!QK)T?En){DIEn,*a%">
<field name="OP">EQ</field>
<value name="A">
<block type="variables_get" id="}]2F`v{Oe/wYx82+k`Ze">
<field name="VAR" id="d[?QaF(N/mc|eq/IOy75" variabletype="">Param1</field>
</block>
</value>
<value name="B">
<block type="text" id="eu+@B(T?F;Xau$8=Nu;.">
<field name="TEXT">Luftdruck</field>
</block>
</value>
</block>
</value>
<statement name="DO0">
<block type="variables_set" id="w5p0?+}q}/4k2UIPIqJ|">
<field name="VAR" id="G7^Cu8s)%C@Yuc,yq:|[" variabletype="">Wert1</field>
<value name="VALUE">
<block type="math_rndfixed" id="u#Pps!@-djj#52`#53{U" inline="false">
<field name="n">1</field>
<value name="x">
<shadow type="math_number" id="1yA`y-}#_r{O,eT`b;^u">
<field name="NUM">3.1234</field>
</shadow>
<block type="math_arithmetic" id="p^(k%B8L:beLF.bXnCO:" inline="false">
<field name="OP">DIVIDE</field>
<value name="A">
<shadow type="math_number" id="(KD!_QMa_d{ENxR]A{@m">
<field name="NUM">1</field>
</shadow>
<block type="convert_tonumber" id="P(=Kapc@m7(gRg:kcCja">
<value name="VALUE">
<block type="text_getSubstring" id="|[eAX8i5`[gMbg@cBVMB">
<mutation at1="true" at2="true"></mutation>
<field name="WHERE1">FROM_START</field>
<field name="WHERE2">FROM_START</field>
<value name="STRING">
<block type="variables_get" id="U|BXf5Hd.E/-$CqQboe9">
<field name="VAR" id="+7xcGWJ647XP265eD.Ll" variabletype="">JSON</field>
</block>
</value>
<value name="AT1">
<block type="math_arithmetic" id="e2ymvlPlxob9*8)0//gT">
<field name="OP">ADD</field>
<value name="A">
<shadow type="math_number" id="uYdt.$Ve!GC|WDs/^5]u">
<field name="NUM">1</field>
</shadow>
<block type="variables_get" id=",4OZ;f]3QK(AKBT[#?~o">
<field name="VAR" id="|zrtv-e98n%+)6SmMQGz" variabletype="">Anfang</field>
</block>
</value>
<value name="B">
<shadow type="math_number" id="kbdVQS[2aKS?.fC{4uHr">
<field name="NUM">6</field>
</shadow>
</value>
</block>
</value>
<value name="AT2">
<block type="math_arithmetic" id="yDH65DG0ySkM9)7)It*x">
<field name="OP">MINUS</field>
<value name="A">
<shadow type="math_number" id="uYdt.$Ve!GC|WDs/^5]u">
<field name="NUM">1</field>
</shadow>
<block type="variables_get" id="-]hsPn8xD8]{v:f^}oo{">
<field name="VAR" id="%g9ob`$FnQ!zF#~C8Ret" variabletype="">Ende</field>
</block>
</value>
<value name="B">
<shadow type="math_number" id="T*vpx9*i)+hzIB?S;Kf*">
<field name="NUM">1</field>
</shadow>
</value>
</block>
</value>
</block>
</value>
</block>
</value>
<value name="B">
<shadow type="math_number" id=",I;tb_;FA6U!PB{C}/=O">
<field name="NUM">100</field>
</shadow>
</value>
</block>
</value>
</block>
</value>
</block>
</statement>
<statement name="ELSE">
<block type="variables_set" id="Kva1CD*.4l5V*Wt/If@/">
<field name="VAR" id="G7^Cu8s)%C@Yuc,yq:|[" variabletype="">Wert1</field>
<value name="VALUE">
<block type="convert_tonumber" id="IKWCBIrOgq,JKY/LZ].x">
<value name="VALUE">
<block type="text_getSubstring" id="eQ#KoXEdco@OXzNKs)RE">
<mutation at1="true" at2="true"></mutation>
<field name="WHERE1">FROM_START</field>
<field name="WHERE2">FROM_START</field>
<value name="STRING">
<block type="variables_get" id="EE{3EO^M}jC}]p/5?X:r">
<field name="VAR" id="+7xcGWJ647XP265eD.Ll" variabletype="">JSON</field>
</block>
</value>
<value name="AT1">
<block type="math_arithmetic" id="!tUwB)]?kN`cPWI-y#a{">
<field name="OP">ADD</field>
<value name="A">
<shadow type="math_number" id="uYdt.$Ve!GC|WDs/^5]u">
<field name="NUM">1</field>
</shadow>
<block type="variables_get" id="9S}$zW[ilGD{xC!_=.xn">
<field name="VAR" id="|zrtv-e98n%+)6SmMQGz" variabletype="">Anfang</field>
</block>
</value>
<value name="B">
<shadow type="math_number" id="E5xB:Z5Oy~L#bwV=|]J]">
<field name="NUM">6</field>
</shadow>
</value>
</block>
</value>
<value name="AT2">
<block type="math_arithmetic" id="`xE6xPnslg~DASN$|X:w">
<field name="OP">MINUS</field>
<value name="A">
<shadow type="math_number" id="uYdt.$Ve!GC|WDs/^5]u">
<field name="NUM">1</field>
</shadow>
<block type="variables_get" id="kmS~#Oql)QWtCi8CE?Yh">
<field name="VAR" id="%g9ob`$FnQ!zF#~C8Ret" variabletype="">Ende</field>
</block>
</value>
<value name="B">
<shadow type="math_number" id="lE|Ax*`pou)-*3[2ORDY">
<field name="NUM">1</field>
</shadow>
</value>
</block>
</value>
</block>
</value>
</block>
</value>
</block>
</statement>
<next>
<block type="comment" id=":Hmm)PF]TzV!|7Y5YjPP">
<field name="COMMENT">Bei Bedarf den Pfad zum DP hier ändern</field>
<next>
<block type="variables_set" id="dF3M=]rwX9J.p`nh.:/A">
<field name="VAR" id="Dj2Zyap_1N~eP!+x^$`B" variabletype="">Pfad</field>
<value name="VALUE">
<block type="text_join" id="nxFydL,as8ZjY]Bj`V_~">
<mutation items="6"></mutation>
<value name="ADD0">
<block type="text" id="fshO^7SBIJLbLFfrXfaJ">
<field name="TEXT">Luftdaten.</field>
</block>
</value>
<value name="ADD1">
<block type="variables_get" id="}kj.bsAvPB1B3s8t-rWs">
<field name="VAR" id="@hb0FIlN^F6YBg^(y}Pm" variabletype="">Station</field>
</block>
</value>
<value name="ADD2">
<block type="text" id="RW29(Xaj-Hn)YQ7yfAZy">
<field name="TEXT">.</field>
</block>
</value>
<value name="ADD3">
<block type="variables_get" id="(@h9,j_+Lmiys64V2$T5">
<field name="VAR" id="s@1tudN:J=lhR59TGl{3" variabletype="">Sensor1</field>
</block>
</value>
<value name="ADD4">
<block type="text" id="8$9r6vcOl,fmK/i@!{4n">
<field name="TEXT">.</field>
</block>
</value>
<value name="ADD5">
<block type="variables_get" id="wZYLDCY.SwgKoOzfaLcQ">
<field name="VAR" id="d[?QaF(N/mc|eq/IOy75" variabletype="">Param1</field>
</block>
</value>
</block>
</value>
<next>
<block type="procedures_callcustomnoreturn" id="S5!AiF|c[:o;`T.dEJNF">
<mutation name="DP anlegen"></mutation>
<next>
<block type="control_ex" id="kGx%e^r^h=4G1A%R?IR,">
<field name="TYPE">true</field>
<field name="CLEAR_RUNNING">FALSE</field>
<value name="OID">
<shadow type="field_oid" id="Fk{ir@V2=n__3I1-H=(4">
<field name="oid">Object ID</field>
</shadow>
<block type="variables_get" id="DOc`Oi;@12kV]HU.A-fA">
<field name="VAR" id="Dj2Zyap_1N~eP!+x^$`B" variabletype="">Pfad</field>
</block>
</value>
<value name="VALUE">
<shadow type="logic_boolean" id="V~d6J^rX-y(l28S+gVCO">
<field name="BOOL">TRUE</field>
</shadow>
<block type="variables_get" id="{4Q[prwGIZkadbq{bLD?">
<field name="VAR" id="G7^Cu8s)%C@Yuc,yq:|[" variabletype="">Wert1</field>
</block>
</value>
<value name="DELAY_MS">
<shadow type="math_number" id="b+(_Mj~N(Bj+m^-PiLo?">
<field name="NUM">0</field>
</shadow>
</value>
<next>
<block type="variables_set" id="TB3Q#LK[(+U[s1(lti3Z">
<field name="VAR" id="+7xcGWJ647XP265eD.Ll" variabletype="">JSON</field>
<value name="VALUE">
<block type="text_getSubstring" id="7#!6#t1#K{_L_7/_=`Hf">
<mutation at1="true" at2="true"></mutation>
<field name="WHERE1">FROM_START</field>
<field name="WHERE2">FROM_START</field>
<value name="STRING">
<block type="variables_get" id="lT2/5k~:F?*n9ubOJqsg">
<field name="VAR" id="+7xcGWJ647XP265eD.Ll" variabletype="">JSON</field>
</block>
</value>
<value name="AT1">
<block type="math_arithmetic" id="7gES8GK6wo~JH}0k^DwU">
<field name="OP">ADD</field>
<value name="A">
<shadow type="math_number" id="uYdt.$Ve!GC|WDs/^5]u">
<field name="NUM">1</field>
</shadow>
<block type="variables_get" id="8qF:R(NqG#h]D/XFC1(B">
<field name="VAR" id="%g9ob`$FnQ!zF#~C8Ret" variabletype="">Ende</field>
</block>
</value>
<value name="B">
<shadow type="math_number" id="HQA9B#2}g_CaSNxXVV{l">
<field name="NUM">30</field>
</shadow>
</value>
</block>
</value>
<value name="AT2">
<block type="math_number" id="o!n;egr4g,m+WsTiuS%x">
<field name="NUM">100000</field>
</block>
</value>
</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>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
<block type="schedule" id="B6o]GUG/x9B//xGnKk2E" x="-87" y="-613">
<field name="SCHEDULE">*/10 * * * *</field>
<statement name="STATEMENT">
<block type="variables_set" id="CzeTqycGqM(9}wMTb*:]">
<field name="VAR" id="2DY4,TA7#ra1oA6Bz925" variabletype="">URL</field>
<value name="VALUE">
<block type="text_join" id="8dSeeND{w@xNX^TY4@;w">
<mutation items="2"></mutation>
<value name="ADD0">
<block type="text" id="eL@Cb!-8FhFK[Hqa#|j=">
<field name="TEXT">https://api.opensensemap.org/boxes/</field>
</block>
</value>
<value name="ADD1">
<block type="variables_get" id="!X!CI`e~-Lo8M64061bA">
<field name="VAR" id="@hb0FIlN^F6YBg^(y}Pm" variabletype="">Station</field>
</block>
</value>
</block>
</value>
<next>
<block type="request" id="p@PZa|FbALxdQG[!5P=P">
<mutation with_statement="true"></mutation>
<field name="WITH_STATEMENT">TRUE</field>
<field name="LOG"></field>
<value name="URL">
<shadow type="text" id="R;W-TQbUXG)5Gbz=QPrM">
<field name="TEXT">https://api.opensensemap.org/boxes/5dd2e6674ec04e001aa48f9e</field>
</shadow>
<block type="variables_get" id="1~Xe85EKFq+2l2a,TIlB">
<field name="VAR" id="2DY4,TA7#ra1oA6Bz925" variabletype="">URL</field>
</block>
</value>
<statement name="STATEMENT">
<block type="variables_set" id="8!8U?^1.~Gs*4QiZGMs?">
<field name="VAR" id="IN6AA6TiKW]?_gBN5J!v" variabletype="">SensemapJson</field>
<value name="VALUE">
<block type="variables_get" id="1HyJyj/-EN2D]=M$n.-g">
<field name="VAR" id="kXTaix[lp7nNNGO=Zc+@" variabletype="">result</field>
</block>
</value>
<next>
<block type="update" id="{n0Q9R:Qrus}otFtjJJ{">
<mutation delay_input="false"></mutation>
<field name="OID">0_userdata.0.Umwelt.Feinstaub_JSON</field>
<field name="WITH_DELAY">FALSE</field>
<value name="VALUE">
<block type="variables_get" id="0upL:$#(xjQbDK)Zgt`{">
<field name="VAR" id="IN6AA6TiKW]?_gBN5J!v" variabletype="">SensemapJson</field>
</block>
</value>
<next>
<block type="variables_set" id="of$45[(ktxK;VNWg?Pm@">
<field name="VAR" id="+7xcGWJ647XP265eD.Ll" variabletype="">JSON</field>
<value name="VALUE">
<block type="variables_get" id="uA@D|=UY6z3KUkJtZI%N">
<field name="VAR" id="IN6AA6TiKW]?_gBN5J!v" variabletype="">SensemapJson</field>
</block>
</value>
<next>
<block type="variables_set" id="Y3Q#eQY#t@tsyPP$cASP">
<field name="VAR" id="|zrtv-e98n%+)6SmMQGz" variabletype="">Anfang</field>
<value name="VALUE">
<block type="text_indexOf" id="R2W04B_qDzPjtc#LBDe/">
<field name="END">FIRST</field>
<value name="VALUE">
<block type="variables_get" id="-bRF{~mX@pD^XMwb69)H">
<field name="VAR" id="+7xcGWJ647XP265eD.Ll" variabletype="">JSON</field>
</block>
</value>
<value name="FIND">
<shadow type="text" id="LH:VbO]s6~=V]x~HqKM#">
<field name="TEXT">tle":"</field>
</shadow>
</value>
</block>
</value>
<next>
<block type="variables_set" id=".ln4OSn}+rIV8TL*?To5">
<field name="VAR" id="+7xcGWJ647XP265eD.Ll" variabletype="">JSON</field>
<value name="VALUE">
<block type="text_getSubstring" id="MJe{?9Q1|u8lxE_epWer">
<mutation at1="true" at2="true"></mutation>
<field name="WHERE1">FROM_START</field>
<field name="WHERE2">FROM_START</field>
<value name="STRING">
<block type="variables_get" id="w:FhPP}r83^0zJ:JE.KZ">
<field name="VAR" id="+7xcGWJ647XP265eD.Ll" variabletype="">JSON</field>
</block>
</value>
<value name="AT1">
<block type="math_arithmetic" id="q9u?dh1$Q(RA/2HFvdt$">
<field name="OP">MINUS</field>
<value name="A">
<shadow type="math_number" id="uYdt.$Ve!GC|WDs/^5]u">
<field name="NUM">1</field>
</shadow>
<block type="variables_get" id="0dJX?S6|pWC8Oqg~cABf">
<field name="VAR" id="|zrtv-e98n%+)6SmMQGz" variabletype="">Anfang</field>
</block>
</value>
<value name="B">
<shadow type="math_number" id="V7w1T/(|Vphqv}$?8d/o">
<field name="NUM">7</field>
</shadow>
</value>
</block>
</value>
<value name="AT2">
<block type="math_number" id="4TCR*ajRjd%Wl-}OKK)~">
<field name="NUM">100000</field>
</block>
</value>
</block>
</value>
<next>
<block type="controls_repeat_ext" id="`Gx_^#EsfD@%Z3?Z5UV?">
<value name="TIMES">
<shadow type="math_number" id="?H;a}JW1J$2HqpPfi]AS">
<field name="NUM">10</field>
</shadow>
</value>
<statement name="DO">
<block type="procedures_callnoreturn" id="BCR/,j`4mC+mgEX];feQ">
<mutation name="Sensorwerte_auslesen"></mutation>
</block>
</statement>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</next>
</block>
</statement>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defcustomnoreturn" id="wb~:H(f(:]+}syLMNgvt" x="113" y="-137">
<mutation statements="false"></mutation>
<field name="NAME">DP anlegen</field>
<field name="SCRIPT">Y3JlYXRlU3RhdGUoUGZhZCwgMCwge3R5cGU6J251bWJlcicsIHVuaXQ6VW5pdDEsIHJlYWQ6dHJ1ZSwgd3JpdGU6ZmFsc2UsIHJvbGU6J3ZhbHVlJ30pOw==</field>
<comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
</block>
<block type="math_round" id="rx#`?~Kd@o)c3r|HUy@M" x="1901" y="-161">
<field name="OP">ROUND</field>
<value name="NUM">
<shadow type="math_number" id="VCOG@@sI^m[=;uJ*-}XZ">
<field name="NUM">3.1</field>
</shadow>
</value>
</block>
<block type="procedures_defcustomreturn" id="vR$WvEqR.bO)LEm12;J[" x="113" y="-62">
<mutation statements="false">
<arg name="tausch" varid="#UHnaMpV=lSawq.B$u/_"></arg>
</mutation>
<field name="NAME">besserer Punktekiller</field>
<field name="SCRIPT">cmV0dXJuIHRhdXNjaC5yZXBsYWNlKC9bXC5cc1wtXS9nLCAiXyIp</field>
<comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment>
</block>
</xml>
ältere Versionen und ein wenig Diskussion befindet sich in diesem Thread
Durchführung:
Im javascript-Adapter ein neues Skript vom Typ Blockly anlegen
Den oben im Spoiler befindlichen Code kopieren
den "Blockly importieren Button anklicken - ein Fenster öffnet sich
den Code dort hineinkopieren und bestätigen
Im Feld "Station" muss noch die 24-stellige ID der auszulesenden Station eingegeben werden.
Diese erhält man, indem man auf der Karte von opensensemap.org eine Station aussucht und anklickt.
In der Adresszeile befindet sich jetzt z.B.: https://opensensemap.org/explore/5af9f557223bd80019fbd6f4
Das letzte ist die ID der Station.
Diese ID in das Feld Station eintragen
Blockly (unter sinnvollem Namen) speichern.
Skript starten
Das Skript holt alle 10 Minuten die Werte.
Beim ersten mal legt es Datenpunkte unter javascript.0.Luftdaten an (wobei die 0 für die Instanz in der das Blockly ist steht)
Im Moment kommt es beim ersten Auslesen noch zu einer Fehlermeldung, wei das Schreiben der Datenpunkte langsamer geschieht als das Auslesen.
Ab der 20. Minute sollte es aber rundlaufen.
Diskussionen zum Skript bitte hier, allgemeine Diskussionen zur Feinstaub-/Luftdatenmessung bitte weiterhin in dem entsprechenden Thread