NEWS
Entfernung (km) zum Haus berechnen (GPS) - Heizungssteuerung
-
Hallo zusammen,
ich habe bereits im Internet geschaut, aber kleine Lösung gefunden.
Ich habe meine GPS Daten alle 5 Minuten in meinem iobroker.Nun möchte ich mittels eines Skripts eine Automation ausführen, wenn ich im Umkreis von 10km bin. (Heizung anschalten)
Dafür muss ich die Distanz zwischen den GPS Koordinaten (Längen und Bereitengrad) ermitteln.Kennt jemand eine Lösung um dies zu berechnen? Gibt es hierfür eventuell ein Adapter?
Viele Grüße
-
Die Position von deinem zu Hause kennst du bestimmt auch. Dann einfach die Formel in ioBroker umsetzen:
distance = sqrt(dx * dx + dy * dy)
mit distance: Entfernung in km
dx = 111.3 * cos(lat) * (lon1 - lon2)
lat = (lat1 + lat2) / 2 * 0.01745
dy = 111.3 * (lat1 - lat2)
lat1, lat2, lon1, lon2: Breite, Länge in Grad -
@00000x Ich habe ein Blockly-Skript wo ich die Distanzen zu mehreren Orten berrechne. Also habe ich mir in Blockly eine Funktion gebaut der ich die beiden Koordinaten übergebe und ich die Entfernung in Metern zurück bekomme:
Die Funktion wir im Skript dann etwa so aufgerufen:
Also Längen- und Breitengrad durch ein Komma getrennt (so wie bei Google-Maps ausgegeben). Im Beispiel oben wird geprüft ob die Entfernung unter 100 Metern ist.
-
@Dr-Bakterius Wow das sieht genau nach dem aus, was ich suche. Kannst du die Funktion als XML exportieren?
-
@00000x Bitte:
<block xmlns="http://www.w3.org/1999/xhtml" type="procedures_defreturn" id="T2aJ0tb9HX@%hW^U!Z+O" x="862" y="1738"> <mutation> <arg name="pos1" varid="@L?GM5iuc/nKas!lg|v("></arg> <arg name="pos2" varid="gH*jS,o2+ycD)[7MEx^~"></arg> </mutation> <field name="NAME">Entfernung</field> <comment pinned="false" h="80" w="160">Beschreibe diese Funktion …</comment> <statement name="STACK"> <block type="comment" id="2[O;MH;_SQ^Zzaoc:WGn"> <field name="COMMENT">Entfernung zwischen 2 Koordinaten berechnen</field> <next> <block type="variables_set" id="[$5QQne3=vP|E{oN*VTu"> <field name="VAR" id="huzpNLp1==YK4TwoO7|r" variabletype="">result</field> <value name="VALUE"> <block type="lists_split" id="EGH*r.Ebsdc-8]/~xt9Z"> <mutation mode="SPLIT"></mutation> <field name="MODE">SPLIT</field> <value name="INPUT"> <block type="variables_get" id="cK}4svwbb6?-D$+$mQ#w"> <field name="VAR" id="@L?GM5iuc/nKas!lg|v(" variabletype="">pos1</field> </block> </value> <value name="DELIM"> <shadow type="text" id="(4[(wy#`DKj$DfZ=vqUf"> <field name="TEXT">,</field> </shadow> </value> </block> </value> <next> <block type="variables_set" id="A.I8^6oW7x{`SoC5^D-u"> <field name="VAR" id="0G0mLGmH3[.Y)Ae54AaS" variabletype="">lat1</field> <value name="VALUE"> <block type="lists_getIndex" id="#i5*9ITFEX!CdOaJg#`["> <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="9sA%[*/ABx-BPqR+PAtc"> <field name="VAR" id="huzpNLp1==YK4TwoO7|r" variabletype="">result</field> </block> </value> <value name="AT"> <block type="math_number" id="qPe8zfF^rn2#go;~Z-1Y"> <field name="NUM">1</field> </block> </value> </block> </value> <next> <block type="variables_set" id="besUzW+Ew0?tMqHoxSz;"> <field name="VAR" id="}z5HG|{ai^o3:iyomfSl" variabletype="">lon1</field> <value name="VALUE"> <block type="lists_getIndex" id=";,K=u!zsvJp@OvJQ1_ow"> <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="I4={ah6ne?*3sw}~,q~9"> <field name="VAR" id="huzpNLp1==YK4TwoO7|r" variabletype="">result</field> </block> </value> <value name="AT"> <block type="math_number" id="(jza0yR)4BJ3}[FBAAS]"> <field name="NUM">2</field> </block> </value> </block> </value> <next> <block type="variables_set" id="oY6[=%SE96KkZEJ65RlR"> <field name="VAR" id="huzpNLp1==YK4TwoO7|r" variabletype="">result</field> <value name="VALUE"> <block type="lists_split" id="MkS!c!Gsz0n@cp*gw6Kl"> <mutation mode="SPLIT"></mutation> <field name="MODE">SPLIT</field> <value name="INPUT"> <block type="variables_get" id="y66evFQ5^8O^-|/.ACN,"> <field name="VAR" id="gH*jS,o2+ycD)[7MEx^~" variabletype="">pos2</field> </block> </value> <value name="DELIM"> <shadow type="text" id="!ahV6xI+*Qz6uz,s,qYI"> <field name="TEXT">,</field> </shadow> </value> </block> </value> <next> <block type="variables_set" id="V}-$z-=!l_[V:%A_`7Ys"> <field name="VAR" id="jOT#/LHb)e7-{Y}t}BVB" variabletype="">lat2</field> <value name="VALUE"> <block type="lists_getIndex" id="q^=L%dCvtrZ7mDDzME4="> <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="M|~p}XW{vx)cd:}OcyrM"> <field name="VAR" id="huzpNLp1==YK4TwoO7|r" variabletype="">result</field> </block> </value> <value name="AT"> <block type="math_number" id="@W,[/HlPvqlMQC=b;-cm"> <field name="NUM">1</field> </block> </value> </block> </value> <next> <block type="variables_set" id="XuP8O^n,]yT~rsNCJX^o"> <field name="VAR" id="-L[Io*#C6G8z|KDd4,fF" variabletype="">lon2</field> <value name="VALUE"> <block type="lists_getIndex" id="ifqU8#ps8)_IQ=G$@t(E"> <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="n#`)KeOuy1Y!-.]w-F7Z"> <field name="VAR" id="huzpNLp1==YK4TwoO7|r" variabletype="">result</field> </block> </value> <value name="AT"> <block type="math_number" id="$4)8J+Ac[;aoiXK-vd-/"> <field name="NUM">2</field> </block> </value> </block> </value> <next> <block type="variables_set" id="$y*EEX75ZdFmp}6|o@~x"> <field name="VAR" id="huzpNLp1==YK4TwoO7|r" variabletype="">result</field> <value name="VALUE"> <block type="math_round" id="-.tn4!-9J4vn;I{uW`8p"> <field name="OP">ROUND</field> <value name="NUM"> <shadow type="math_number" id="QmXZYtjGC^ujr3LZ.j?:"> <field name="NUM">3.1</field> </shadow> <block type="math_arithmetic" id="hT-(QhU{o)Ino]ByQ,W."> <field name="OP">MULTIPLY</field> <value name="A"> <shadow type="math_number" id="G^tm(y4VI4s)st6NsB9F"> <field name="NUM">1</field> </shadow> <block type="math_arithmetic" id="k%r*%B$0ABY3JK7$?Jf_"> <field name="OP">MULTIPLY</field> <value name="A"> <shadow type="math_number" id="i/f3g_7B,k!ITta,BopC"> <field name="NUM">111.324</field> </shadow> </value> <value name="B"> <shadow type="math_number" id="aN90##;n0pXXvH;{|Y#X"> <field name="NUM">1</field> </shadow> <block type="math_trig" id="ljE{kFpfFBHMvo0-Qi[c"> <field name="OP">ACOS</field> <value name="NUM"> <shadow type="math_number" id="ikmVw4d2^(_MXYN)]v1j"> <field name="NUM">45</field> </shadow> <block type="math_arithmetic" id=";xSp^W(ChZZeOVah=%8T"> <field name="OP">ADD</field> <value name="A"> <shadow type="math_number" id="K#l!z7kO[;!qs%=Um5ov"> <field name="NUM">1</field> </shadow> <block type="math_arithmetic" id="7qpTT~}-.Ee,P/iTuh5R"> <field name="OP">MULTIPLY</field> <value name="A"> <shadow type="math_number" id="{:D((C()}/y{AQrCGb2g"> <field name="NUM">1</field> </shadow> <block type="math_trig" id="IvG(t!*n;{t.8S/Baqyi"> <field name="OP">SIN</field> <value name="NUM"> <shadow type="math_number" id="X1n[H=%ziU-rBWH0v;gt"> <field name="NUM">45</field> </shadow> <block type="variables_get" id="q`^eYV=Pcp[l3}+AF|n-"> <field name="VAR" id="0G0mLGmH3[.Y)Ae54AaS" variabletype="">lat1</field> </block> </value> </block> </value> <value name="B"> <shadow type="math_number" id="A(9]a|YA`@nlb[N))[}J"> <field name="NUM">1</field> </shadow> <block type="math_trig" id="NtE}O$nOP7Bkm4FrqVep"> <field name="OP">SIN</field> <value name="NUM"> <shadow type="math_number" id="X1n[H=%ziU-rBWH0v;gt"> <field name="NUM">45</field> </shadow> <block type="variables_get" id="DOMb_=FcM#GOjl=xSVX*"> <field name="VAR" id="jOT#/LHb)e7-{Y}t}BVB" variabletype="">lat2</field> </block> </value> </block> </value> </block> </value> <value name="B"> <shadow type="math_number" id=":]3}I;7rf`r$0hk$7}Uf"> <field name="NUM">1</field> </shadow> <block type="math_arithmetic" id="[)+iKs)1[+tpF1ohL]_m"> <field name="OP">MULTIPLY</field> <value name="A"> <shadow type="math_number" id="1kpB8L9oEKT@95p_?Mf."> <field name="NUM">1</field> </shadow> <block type="math_arithmetic" id="q$]?PprPXy$!Ur|,+_ze"> <field name="OP">MULTIPLY</field> <value name="A"> <shadow type="math_number" id="{:D((C()}/y{AQrCGb2g"> <field name="NUM">1</field> </shadow> <block type="math_trig" id="(XF#NPyZ*uGqINJZF:D%"> <field name="OP">COS</field> <value name="NUM"> <shadow type="math_number" id="X1n[H=%ziU-rBWH0v;gt"> <field name="NUM">45</field> </shadow> <block type="variables_get" id="=~$.Ys+$SrT.RhmsYG45"> <field name="VAR" id="0G0mLGmH3[.Y)Ae54AaS" variabletype="">lat1</field> </block> </value> </block> </value> <value name="B"> <shadow type="math_number" id="A(9]a|YA`@nlb[N))[}J"> <field name="NUM">1</field> </shadow> <block type="math_trig" id="DNgAR4/|g_t)Gx2}MMam"> <field name="OP">COS</field> <value name="NUM"> <shadow type="math_number" id="X1n[H=%ziU-rBWH0v;gt"> <field name="NUM">45</field> </shadow> <block type="variables_get" id="8n{-RBpx[YKsR$AocUxD"> <field name="VAR" id="jOT#/LHb)e7-{Y}t}BVB" variabletype="">lat2</field> </block> </value> </block> </value> </block> </value> <value name="B"> <shadow type="math_number" id="[,h/obEF?,02mPQUC{yj"> <field name="NUM">1</field> </shadow> <block type="math_trig" id="g1D!+/4.$j[s984^ALke"> <field name="OP">COS</field> <value name="NUM"> <shadow type="math_number" id=":!exR3Jd^z9OS8nq{(zk"> <field name="NUM">45</field> </shadow> <block type="math_arithmetic" id="0cF`R:.K^2n}6%gg*t#:"> <field name="OP">MINUS</field> <value name="A"> <shadow type="math_number" id="{:D((C()}/y{AQrCGb2g"> <field name="NUM">1</field> </shadow> <block type="variables_get" id="^_{PS_btayQ+jZqW|2e}"> <field name="VAR" id="-L[Io*#C6G8z|KDd4,fF" variabletype="">lon2</field> </block> </value> <value name="B"> <shadow type="math_number" id="A(9]a|YA`@nlb[N))[}J"> <field name="NUM">1</field> </shadow> <block type="variables_get" id="srvRO~):6H}h.@:T:[Px"> <field name="VAR" id="}z5HG|{ai^o3:iyomfSl" variabletype="">lon1</field> </block> </value> </block> </value> </block> </value> </block> </value> </block> </value> </block> </value> </block> </value> <value name="B"> <shadow type="math_number" id=",46mChF+VJW1ftE!v5Sy"> <field name="NUM">1000</field> </shadow> </value> </block> </value> </block> </value> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </next> </block> </statement> <value name="RETURN"> <block type="variables_get" id="3t3*mh9SjUvoK0?I2Rcj"> <field name="VAR" id="huzpNLp1==YK4TwoO7|r" variabletype="">result</field> </block> </value> </block>