NEWS
Kegelstumpf Blockly in Berryscript Tasmota [gelöst]
-
Hallo,
ich hätte gerne mein Blockly script auf den Esp32 ausgelagert.
<xml xmlns="https://developers.google.com/blockly/xml"> <variables> <variable id="`:H;H8V)NI74WMdws*,4">wert-23cm=0</variable> <variable id="*e!Qy+h)MO2flf!XL0It">hoehe_Tonne_bis_Sensor_in_cm</variable> <variable id="G-(dMY)T}f`7@c2malWY">Radius_oben_in_cm</variable> <variable id="HVLq_Zx{?_%{pb_NYC6.">Radius_unten_in_cm</variable> <variable type="timeout" id="timeout">timeout</variable> <variable id="kxN%n/_4vfYXY^W[9.VD">entfernung_invertiert</variable> </variables> <block type="comment" id="xbdQA]p:Rm0!77!u:Uzz" x="-63" y="424"> <field name="COMMENT">Kegelstumpf Regentonne</field> <next> <block type="comment" id="|YNADPJ5k[^ORlh6KlBz"> <field name="COMMENT">Sensor misst bis 23cm</field> <next> <block type="on" id="F~b*#|j@)ipdlQQopt$E"> <field name="OID">sonoff.0.pool_61_regentonne.SR04_Distance</field> <field name="CONDITION">ne</field> <field name="ACK_CONDITION"></field> <statement name="STATEMENT"> <block type="variables_set" id="$?pcIQ[ZklduDkx|)]ok"> <field name="VAR" id="`:H;H8V)NI74WMdws*,4">wert-23cm=0</field> <value name="VALUE"> <block type="math_arithmetic" id="zK|Ksu)dA:3N/uHX8.x`"> <field name="OP">MINUS</field> <value name="A"> <shadow type="math_number" id="(49.@XAbyvYM#sHmcwW9"> <field name="NUM">1</field> </shadow> <block type="on_source" id="~;N)F]CT5G1.sx{8mmm."> <field name="ATTR">state.val</field> </block> </value> <value name="B"> <shadow type="math_number" id="B9a9r.S{_=SEleC]:ct]"> <field name="NUM">22</field> </shadow> <block type="math_number" id="j!7zc`XzAv(o=e7#~!Z4"> <field name="NUM">23</field> </block> </value> </block> </value> <next> <block type="variables_set" id=".iH{PRMOti%`!9C:,$a7"> <field name="VAR" id="*e!Qy+h)MO2flf!XL0It">hoehe_Tonne_bis_Sensor_in_cm</field> <value name="VALUE"> <block type="math_number" id="^?UsQbV8@;@=QeWE_kR#"> <field name="NUM">140</field> </block> </value> <next> <block type="variables_set" id="Wci|;:wXY~@J`VW6G?hL"> <field name="VAR" id="G-(dMY)T}f`7@c2malWY">Radius_oben_in_cm</field> <value name="VALUE"> <block type="math_number" id="wZz#666*ftqLP4kfX-;k"> <field name="NUM">30</field> </block> </value> <next> <block type="variables_set" id="QyC*SpMyQA=D#ubNh6Dx"> <field name="VAR" id="HVLq_Zx{?_%{pb_NYC6.">Radius_unten_in_cm</field> <value name="VALUE"> <block type="math_number" id="*%:nMl~*~r3lZchceG`/"> <field name="NUM">25</field> </block> </value> <next> <block type="timeouts_settimeout" id="Hx-?1TM^O.;}LVPXN#ho"> <field name="NAME">timeout</field> <field name="DELAY">100</field> <field name="UNIT">ms</field> <statement name="STATEMENT"> <block type="variables_set" id=":(iut~5QcavF29$`=1{L"> <field name="VAR" id="kxN%n/_4vfYXY^W[9.VD">entfernung_invertiert</field> <value name="VALUE"> <block type="math_rndfixed" id="rQ`urI8G~mW*up[O}%a-"> <field name="n">2</field> <value name="x"> <shadow type="math_number" id="0TM5Vz5TwC3p%.E*NY4Q"> <field name="NUM">3.1234</field> </shadow> <block type="math_arithmetic" id="1``s!BYJ{3S~_x^|TYH8"> <field name="OP">MINUS</field> <value name="A"> <shadow type="math_number" id="v5PpsZu4PSyAx057^p^9"> <field name="NUM">1</field> </shadow> <block type="variables_get" id="28jwSkT{!_W)Dw2AD:.z"> <field name="VAR" id="*e!Qy+h)MO2flf!XL0It">hoehe_Tonne_bis_Sensor_in_cm</field> </block> </value> <value name="B"> <shadow type="math_number" id="mj{c6)]{U{h|=8AoN-Y!"> <field name="NUM">1</field> </shadow> <block type="variables_get" id="pR)8.rtSV}0RvZe2Q~U3"> <field name="VAR" id="`:H;H8V)NI74WMdws*,4">wert-23cm=0</field> </block> </value> </block> </value> </block> </value> <next> <block type="update" id="}8URLV|N@HzOUvJ=dgWM"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">javascript.0.Regentonne.entfernung_invertiert</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="variables_get" id="$;z][[YW!l]9Np}hH5Q*"> <field name="VAR" id="kxN%n/_4vfYXY^W[9.VD">entfernung_invertiert</field> </block> </value> <next> <block type="update" id="w=,FAsa)^dq!2`9Z|UZX"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">javascript.0.Regentonne.Wasserinhalt</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="math_round" id="n:4L(^03@L;)WKDGKE?d"> <field name="OP">ROUND</field> <value name="NUM"> <shadow type="math_number" id="5F8D1VUX]8%@[!I+U`KP"> <field name="NUM">3.1</field> </shadow> <block type="math_arithmetic" id="G:9I3$=qQ`lixEy`L#)8"> <field name="OP">DIVIDE</field> <value name="A"> <shadow type="math_number" id="8RB]xuYu[)(Hxz9T,h#]"> <field name="NUM">1</field> </shadow> <block type="math_arithmetic" id="(8lz8X_0Yd/HYLs[*iI?" inline="false"> <field name="OP">MULTIPLY</field> <value name="A"> <shadow type="math_number" id="q#+V35)]KK#{%)Hy(}K^"> <field name="NUM">1</field> </shadow> <block type="math_arithmetic" id="cQMs/PeTI:.u)RI.!4LG"> <field name="OP">DIVIDE</field> <value name="A"> <shadow type="math_number" id="`^E[57|rmC4$kCp6;T7l"> <field name="NUM">1</field> </shadow> <block type="math_arithmetic" id="RO_U/wVMG{$3R-[Z(9R@"> <field name="OP">MULTIPLY</field> <value name="A"> <shadow type="math_number" id="z5MVmXmfh($[f+YQ8X)0"> <field name="NUM">1</field> </shadow> <block type="math_arithmetic" id="an)b`B$+-7oWrHKG2nV{"> <field name="OP">MINUS</field> <value name="A"> <shadow type="math_number" id="{x2%9pm8MD#oH!RmvkTS"> <field name="NUM">150</field> </shadow> <block type="variables_get" id="hIZn|]q?sSq06mfMXh2("> <field name="VAR" id="*e!Qy+h)MO2flf!XL0It">hoehe_Tonne_bis_Sensor_in_cm</field> </block> </value> <value name="B"> <shadow type="math_number" id="/{4m/d]]]d62w}G,vF0o"> <field name="NUM">1</field> </shadow> <block type="on_source" id="akt?UxuSJ$Tzttd4;.de"> <field name="ATTR">state.val</field> </block> </value> </block> </value> <value name="B"> <shadow type="math_number" id="8TSK#8[Y^%/D|xoGin8W"> <field name="NUM">1</field> </shadow> <block type="math_constant" id="YAHz2L/9o?rW]S:!~9tG"> <field name="CONSTANT">PI</field> </block> </value> </block> </value> <value name="B"> <shadow type="math_number" id=":fdAXjfwZJ-YfHA)x.`H"> <field name="NUM">3</field> </shadow> </value> </block> </value> <value name="B"> <shadow type="math_number" id="dRp/LRm-wBuL~BJ/X[Hl"> <field name="NUM">1</field> </shadow> <block type="math_arithmetic" id="Axp!Zaz1YfHZO3c_%qq[" inline="false"> <field name="OP">ADD</field> <value name="A"> <shadow type="math_number" id="1:D(5[Ncv0U~Cn%1`D`t"> <field name="NUM">1</field> </shadow> <block type="math_arithmetic" id="=9UZ5%r4Nm@d|/{CTU(z" inline="false"> <field name="OP">ADD</field> <value name="A"> <shadow type="math_number" id="z1J+Pb1N`=0zR.C%n],*"> <field name="NUM">1</field> </shadow> <block type="math_arithmetic" id="_h)Wn3vLrXP-E8WqfoGC"> <field name="OP">MULTIPLY</field> <value name="A"> <shadow type="math_number" id="%1=s}F,x_Q9dUaQ+Im#r"> <field name="NUM">1</field> </shadow> <block type="variables_get" id="j/U;7F@C4#K_$ic_A7h-"> <field name="VAR" id="G-(dMY)T}f`7@c2malWY">Radius_oben_in_cm</field> </block> </value> <value name="B"> <shadow type="math_number" id="B6aH,xuq-QHsC?}92,K$"> <field name="NUM">1</field> </shadow> <block type="variables_get" id="_H$0AsSI7#d*ziJfHZBa"> <field name="VAR" id="G-(dMY)T}f`7@c2malWY">Radius_oben_in_cm</field> </block> </value> </block> </value> <value name="B"> <shadow type="math_number" id="fABi#19`C|Q-}F7d,+pH"> <field name="NUM">1</field> </shadow> <block type="math_arithmetic" id="fm$KD-n9|AU,Dn;Bdaof"> <field name="OP">MULTIPLY</field> <value name="A"> <shadow type="math_number" id="Q#cQ_AM7#1XN61%/]oyV"> <field name="NUM">1</field> </shadow> <block type="variables_get" id="?-k51TG8Woy5}c/oo`yp"> <field name="VAR" id="G-(dMY)T}f`7@c2malWY">Radius_oben_in_cm</field> </block> </value> <value name="B"> <shadow type="math_number" id="E0ow|#WNDvI%Y3%?0-KJ"> <field name="NUM">1</field> </shadow> <block type="variables_get" id="myVd3]C~JZK`?.I9r6Ac"> <field name="VAR" id="HVLq_Zx{?_%{pb_NYC6.">Radius_unten_in_cm</field> </block> </value> </block> </value> </block> </value> <value name="B"> <shadow type="math_number" id="V9JScxR=lN`K~1rn$[$y"> <field name="NUM">1</field> </shadow> <block type="math_arithmetic" id="nkEjUwifV:_jvgF0%Yga"> <field name="OP">MULTIPLY</field> <value name="A"> <shadow type="math_number" id="J9I-31pLT_CR8~r**__k"> <field name="NUM">1</field> </shadow> <block type="variables_get" id=")-Aru@@Rw}6,DkD^-G7a"> <field name="VAR" id="HVLq_Zx{?_%{pb_NYC6.">Radius_unten_in_cm</field> </block> </value> <value name="B"> <shadow type="math_number" id="/UQ-JAZ5+Uu_hg+Ww2wI"> <field name="NUM">1</field> </shadow> <block type="variables_get" id="P2LR1`~mR)#HlZ[zX)|8"> <field name="VAR" id="HVLq_Zx{?_%{pb_NYC6.">Radius_unten_in_cm</field> </block> </value> </block> </value> </block> </value> </block> </value> <value name="B"> <shadow type="math_number" id="qVyeSl:Gu)Q7dFJekEdn"> <field name="NUM">1000</field> </shadow> </value> </block> </value> </block> </value> <next> <block type="update" id="0B,m$6sq^-u!78mgYaR+"> <mutation xmlns="http://www.w3.org/1999/xhtml" delay_input="false"></mutation> <field name="OID">javascript.0.Regentonne.Füllmenge_in_Prozent</field> <field name="WITH_DELAY">FALSE</field> <value name="VALUE"> <block type="math_round" id="D)#U]4czaPL0subb+wTA"> <field name="OP">ROUND</field> <value name="NUM"> <shadow type="math_number" id="x-:C@bh`WB+NYy~{k|VC"> <field name="NUM">3.1</field> </shadow> <block type="math_arithmetic" id="~C7?buZDPnWI,?O)IA1@"> <field name="OP">MULTIPLY</field> <value name="A"> <shadow type="math_number" id="mjU9uL)vyWKthB4*vFzB"> <field name="NUM">1</field> </shadow> <block type="math_arithmetic" id="Qh?#1$X7kEM673SB,}XJ"> <field name="OP">DIVIDE</field> <value name="A"> <shadow type="math_number" id="_hf9SH]1@k[{BEL)8cU%"> <field name="NUM">100</field> </shadow> </value> <value name="B"> <shadow type="math_number" id=")qi:Vc9rY.t^HEE~$|jp"> <field name="NUM">1</field> </shadow> <block type="variables_get" id="hY?MRbdqy=zO[s*JU|%f"> <field name="VAR" id="*e!Qy+h)MO2flf!XL0It">hoehe_Tonne_bis_Sensor_in_cm</field> </block> </value> </block> </value> <value name="B"> <shadow type="math_number" id="3^^./Y-?5C?f??#8rz)o"> <field name="NUM">1</field> </shadow> <block type="variables_get" id="P{o2a}m+eae19f{A,SrZ"> <field name="VAR" id="kxN%n/_4vfYXY^W[9.VD">entfernung_invertiert</field> </block> </value> </block> </value> </block> </value> </block> </next> </block> </next> </block> </next> </block> </statement> </block> </next> </block> </next> </block> </next> </block> </next> </block> </statement> </block> </next> </block> </next> </block> </xml>
mit Blockly bekomme ich das hin aber dann hört es auchschon auf
Kann mir jemand helfen das Blockly in Berry Script umzuwandeln? -
@bishop sagte in Kegelstumpf Blockly in Berryscript Tasmota:
Kann mir jemand helfen das Blockly in Berry Script umzuwandeln?
Umwandeln kann ich dir das nicht, da ich BerryScript nicht kenne. Allerdings kannst Du dir den JS Code des Blockly's anzeigen lassen. ggf. gibt es dafür saubere Umsetzungsanleitungen. Zur Anzeige des JS diesen Button benutzen:
Aufpassen musst du natürlich bei den ioBroker spezifischen Blöcken (Trigger, Timeout, Datenpunkte setzen, Datenpunkte löschen)
A.
-
@asgothian
danke für den Tip, hab aber leider nicht wirklich was gefunden um es um zu schreiben.Hier gibt es ein Script. Funktioniert auch nur wird da alles in inch und gallonen umgerechnet.
-
@bishop Da sind mehrere Skripte hinterlegt. Das geeignete nehmen und umrechnen sollte gehen. 1 Inch sind 2,54 cm. 1 Gallone 4,55 Liter.
-
@peterfido
Ja machts auch nur wie ändere ich das ab
Inch weg und gal in cm3EDIT:
habs mal umgebaut so gut ich es kann!
Vielleicht kann es ja jemand gebrauchen.class FOTank : Driver var tank_data #build an global array-->list to store sensor for filtering static buf = [] # this table is from the manufacturer datasheet, showing total gallons in inches, 44 entries plus a zero-entry. static Tank275 =[0.38,0.76,1.16,1.55,1.96,2.36,2.77,3.19,3.61,4.04,4.47,4.91,5.35,5.8,6.25,6.71,7.17,7.64,8.11,8.59,9.07,9.56,10.06,10.56,11.07,11.58,12.09,12.62,13.14,13.68,14.22,14.76,15.31,15.87,16.43,17,17.57,18.15,18.74,19.33,19.93,20.53,21.14,21.76,22.38,23.01,23.64,24.28,24.93,25.58,26.24,26.91,27.58,28.26,28.94,29.63,30.33,31.03] #- *************************************** -# def tank() var TableLength = self.Tank275.size() # 59 var TableTop = TableLength -1 var tank_offset = -3 # offset from SR04t to top of tank (dead zone...) var MaxBuf = 180 # filtering buffer size #print ("\n") # Read Sensor data import json var sensors=json.load(tasmota.read_sensors()) if !(sensors.contains('SR04')) return end var d = sensors['SR04']['Distance'] #print("Dist: ", d) if (self.buf.size() >= MaxBuf) self.buf.pop(0) end # remove old entry self.buf.push(d) # add new sensor reading to list #print (self.buf) #print ("Size: :", self.buf.size()) d = 0 for i : 0 .. (self.buf.size()-1 ) # let's sum all of the entrys #print ("I: ",i) d = d + self.buf.item (i) end #print("Buf: ", self.buf) d = d / self.buf.size() # average the sensor data #print("Dist-avd: ", d) d = d + tank_offset # adjust for sensor to tank offset (dead zone) # Convert from CM to inch and round up var d1 = d + 0.5 # 2.54 cm to one inch d1 = int(d1) # we want an integer here for table lookup if (d1 > TableTop) d1 = TableTop end # do a bounds check, 0 --> 44 if (d1 <= 0) d1 = 0 end #print("Cm: ",d1) var d2 = self.Tank275.item(TableTop - d1) # do table lookup, from end of table d2 = int(d2) # make sure its an integer #print ("Liter: ",d2) var d3 = (real(d2) / self.Tank275.item(TableTop)) * 100 # calculate percent of full d3 = int (d3) #print ("Prozent:", d3) self.tank_data = [int (d), d1, d2, d3] # return the data return self.tank_data end #- *************************************** -# def every_second() if !self.tank return nil end self.tank() end #- *************************************** -# def web_sensor() import string if !self.tank_data return nil end #- exit if not initialized -# var msg = string.format( "{s}Distanz{m}%.f cm{e}".. "{s}Distanz{m}%.f cm{e}".. "{s}Volumen{m}%.f Liter{e}".. "{s}Prozent Voll{m}%.f %%{e}", self.tank_data[0],self.tank_data[1],self.tank_data[2],self.tank_data[3]) tasmota.web_send_decimal(msg) end #- *************************************** -# def json_append() if !self.tank_data return nil end import string var msg = string.format(",\"Tank\":{\"Distanz cm\":%.f,\"Distanz cm\":%.f,\"Volumen\":%.f,\"Prozent Voll\":%.f}", self.tank_data[0],self.tank_data[1],self.tank_data[2],self.tank_data[3]) tasmota.response_append(msg) end end #- *************************************** -# FOTank = FOTank() tasmota.add_driver(FOTank) #- ************ The Very End ************* -#
-
@bishop Danke fürs teilen.