Advertisement
Guest User

Tasmota TH

a guest
Feb 2nd, 2023
1,083
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.83 KB | None | 0 0
  1. >D 40
  2.  
  3. ; for external ScriptEditor
  4.  
  5. ; Version see >W section
  6.  
  7. IP=192.168.0.50
  8.  
  9. ; SB=6200 only if you have 1M flash
  10.  
  11. ; and compile with #define EEP_SCRIPT_SIZE 6200
  12.  
  13. ; and #define USE_EEPROM
  14.  
  15. ; 6 Arrays, compile with
  16. ;#ifdef MAXFILT
  17. ;#undef MAXFILT
  18. ;#endif
  19. ;#define MAXFILT 6
  20.  
  21. SB=6200
  22.  
  23. ; HowTo:
  24.  
  25. ; Download the ScriptEditor from Tasmota Script page
  26.  
  27. ; Change the IP and maybe the SB (look for EEP_SCRIPT_SIZE Tasmota Script page)
  28.  
  29. ; change the -- SML -- script to your needs
  30.  
  31. ; search for -300 und change it to your needs (I have only 300W PV) or remove it
  32.  
  33. ; First start, go to console and type: script>=#dreset
  34.  
  35. ; This will set the correct day consumption value
  36.  
  37. ; 4h chart is not permament, after restart data is lost
  38.  
  39. ; 24h, month and year chart is permament. Arrays are saved at midnight.
  40.  
  41. ; to save immediately go to console and enter: script>=#save
  42.  
  43. ; to change some values enter e.g.: script >dcon[day]=xxx
  44.  
  45. ; console commands:
  46.  
  47. ; script?var = get variable
  48.  
  49. ; script >var=1 = set variable
  50.  
  51. ; script>=svars = save permament var
  52.  
  53. ; script>=#sub = run sub
  54.  
  55. ; -- ARRAYS --
  56.  
  57. ; 4h chart temp
  58.  
  59. M:t4h=0 240
  60.  
  61. ; 4h chart hum
  62.  
  63. M:h4h=0 240
  64.  
  65. ; 4h chart dew
  66.  
  67. M:d4h=0 240
  68.  
  69. ; 24h power chart temp
  70.  
  71. M:hday=0 96
  72.  
  73. ; 24h power chart hum
  74.  
  75. M:tday=0 96
  76.  
  77. ; 24h power chart dew
  78.  
  79. M:dday=0 96
  80.  
  81. ; -- VARS --
  82.  
  83. ; monthval and dayval
  84.  
  85. p:mval=0
  86.  
  87. p:dval=0
  88.  
  89. tmp=0
  90.  
  91. mtem=0
  92.  
  93. mhum=0
  94.  
  95. mdew=0
  96.  
  97. cstr=""
  98.  
  99. cstr2=""
  100.  
  101. avgval=0
  102. avgvalh=0
  103. avgvald=0
  104. avgvalcnt=0
  105.  
  106. hour=0
  107.  
  108. mont=0
  109.  
  110. minutes=0
  111.  
  112. ; -- BOOT --
  113.  
  114. >B
  115.  
  116. cstr2="cnth"+s(1.0((hours-4)*60)+(mins*1))+"/60"
  117.  
  118. ;disable mqtt at boot prevents sending 0
  119.  
  120. smlj=0
  121.  
  122. ; -- SUBS --
  123.  
  124. ; 24h power chart
  125.  
  126. #dreset
  127.  
  128. for tmp 1 tday[-1] 1
  129.  
  130. tday[tmp]=0
  131. hday[tmp]=0
  132. dday[tmp]=0
  133. next
  134.  
  135. svars
  136.  
  137. ; daily consumption month chart
  138.  
  139. ; !execute this at the first time!
  140.  
  141. ; save
  142.  
  143. #save
  144.  
  145. print saving
  146.  
  147. ;svars
  148.  
  149. ; -- EVERY SECOND --
  150.  
  151. >S
  152.  
  153. hour=hours
  154.  
  155. mont=month
  156.  
  157. ;avoid send 0 via mqtt after boot
  158.  
  159. if (upsecs>15)
  160.  
  161. then
  162.  
  163. smlj=1
  164.  
  165. else
  166.  
  167. break
  168.  
  169. endif
  170.  
  171. ; copy SML values - every 15s
  172.  
  173. if (secs%15==0)
  174.  
  175. then
  176.  
  177. ; MQTT
  178.  
  179. ;=>publish tele/%topic%/SENSOR {"Time":"%tstamp%","MT175":{"daily_con":%2dcon[day]%,"monthly_con":%2mcon[month]%}}
  180.  
  181. endif
  182.  
  183. ; 4h power chart - every 60s
  184.  
  185. if (secs%60==0)
  186.  
  187. then
  188.  
  189. ; temp and hum to array, idx is set automatically
  190.  
  191. t4h=gtmp
  192.  
  193. h4h=ghum
  194.  
  195. d4h=gtmp-((100-ghum)/5)
  196.  
  197. ; sum up power for "24h chart"
  198.  
  199. avgval+=gtmp
  200. avgvalh+=ghum
  201. avgvald+=gtmp-((100-ghum)/5)
  202.  
  203. avgvalcnt+=1;
  204.  
  205. endif
  206.  
  207. ; set x axis index to 4 hours a 30 sec therefore /240, no decimal point
  208.  
  209. hour-=4
  210.  
  211. if (hour<0)
  212.  
  213. then
  214. cstr2="cnth"+s(1.0((24-4+hours)*60)+(mins*1))+"/60"
  215. else
  216. cstr2="cnth"+s(1.0((hours-4)*60)+(mins*1))+"/60"
  217. endif
  218.  
  219. hour=hours
  220.  
  221. ; 24h power chart
  222.  
  223. ; calc avg temp [C] for last 15min and put into array[1-96]
  224.  
  225. mtem=int((((hours*60)+mins)/15)+1)
  226. mhum=int((((hours*60)+mins)/15)+1)
  227. mdew=int((((hours*60)+mins)/15)+1)
  228.  
  229. if ((mins%15==0) and (chg[mtem]>0))
  230.  
  231. then
  232. ;Temperature
  233. [mtem]=int(10*avgval/avgvalcnt)/10
  234. tday[mtem]=int(10*avgval/avgvalcnt)/10
  235. ;Humidity
  236. [mhum]=int(10*avgvalh/avgvalcnt)/10
  237. hday[mhum]=int(10*avgvalh/avgvalcnt)/10
  238.  
  239. ;Dew-Point
  240. [mdew]=int(10*avgvald/avgvalcnt)/10
  241. dday[mdew]=int(10*avgvald/avgvalcnt)/10
  242.  
  243. avgval=0
  244. avgvalh=0
  245. avgvald=0
  246. avgvalcnt=0
  247.  
  248. ;svars save too often will damage flash
  249.  
  250. endif
  251.  
  252. ; set idx (pointer starts from 0!!)
  253.  
  254. tday[0]=mtem
  255. hday[0]=mhum
  256. dday[0]=mdew
  257.  
  258. ; set x axis idx to 24 hours a 15 min therefore /4, no decimal point
  259.  
  260. ; calc minutes for x-axis
  261.  
  262. tmp=hours
  263.  
  264. if (mins<45)
  265.  
  266. then
  267.  
  268. minutes=mins+15
  269.  
  270. else
  271.  
  272. minutes=mins-45
  273.  
  274. if (tmp<23)
  275.  
  276. then
  277.  
  278. tmp+=1
  279.  
  280. else
  281.  
  282. tmp=0
  283.  
  284. endif
  285.  
  286. endif
  287.  
  288. cstr="cnt"+s(1.0(tmp+(int(minutes/15)/4))*4)+"/4"
  289.  
  290. ; WEB INTERFACE
  291.  
  292. >W
  293.  
  294. ; Auto reload
  295.  
  296. ;$<script> setTimeout("location.reload(true);",5000); </script>
  297.  
  298. ; consumption
  299.  
  300. ;Luftfeuchtigkeit:{m}%1(ghum)% &percnt;
  301.  
  302. ;Temperatur:{m}%1(gtmp)% C
  303.  
  304. ; Time/Date
  305.  
  306. Datum:{m}%s(2.0day)%.%s(2.0month)%.%s(2.0year)% - %s(2.0hours)%:%s(2.0mins)%:%s(2.0secs)%
  307.  
  308. Uptime:{m}%0uptime% min
  309.  
  310. $<div style="margin-left:-20px">
  311. ; 4h chart
  312. $<div id="chart1" style="text-align:center;width:390px;height:100%%;padding:0px"></div>
  313. $gc(lt t4h h4h d4h "wr" "Temperatur" "Luftfeuchtigkeit" "Taupunkt" cstr2)
  314.  
  315. $var options = {
  316.  
  317. $chartArea:{left:30,right:30},
  318.  
  319. ;$width:'50%%',
  320.  
  321. $legend:'top',
  322. ;$vAxes:{0:{title:'Außentemperatur'}},
  323. ;$hAxes:{0:{title:'4 Stunden Ãœbersicht'}},
  324.  
  325. $explorer:{actions:['dragToZoom', 'rightClickToReset']},
  326.  
  327. $title:'4 Stunden Ãœbersicht'
  328.  
  329. $};
  330.  
  331. $gc(e)
  332.  
  333. ; 24h chart
  334.  
  335. $<div id="chart2" style="text-align:center;width:400px;height:100%%;padding:0px"></div>
  336.  
  337. $gc(lt tday hday dday "wr" "Temperatur" "Luftfeuchtigkeit" "Temperatur" cstr)
  338.  
  339. $var options = {
  340.  
  341. $chartArea:{left:30,right:30},
  342.  
  343. ;$width:'50%%',
  344.  
  345. $legend:'top',
  346.  
  347. $explorer:{actions:['dragToZoom', 'rightClickToReset']},
  348.  
  349. ;$series: {0: {type: 'area'}},
  350.  
  351. ;$series: {1: {type: 'area'}},
  352.  
  353. ;$series: {2: {type: 'area'}},
  354.  
  355. ;type: „line“, „area“, „bars“, „candlesticks“ und „steppedArea“
  356.  
  357. ;$seriesType: 'bars',
  358.  
  359. $title:'24 Stunden Ãœbersicht'
  360.  
  361. $};
  362.  
  363. $gc(e)
  364.  
  365. ;Einfacher Chart mit 2 Zeilen
  366. ;$<div id="chart5" style="text-align:center;width:400px;height:100%%;padding:0px"></div>
  367. ;$gc(c t4h h4h d4h "wr" "Grad C" "Prozent" "Grad C" cstr2 "4 Stunden")
  368. ;$<div id="chart5" style="text-align:center;width:400px;height:100%%;padding:0px"></div>
  369. ;$gc(c d4h "wr" "C" cstr "Temperatur 24h")
  370.  
  371. $<center><span style="font-size:10px;">
  372.  
  373. $Version 2023.01.22<br>
  374.  
  375. $free heap: %s(0.0heap)% bytes<br>
  376.  
  377. $Hinweis: Die Daten werden immer um Mitternacht gespeichert!<br>
  378.  
  379. $Sofort speichern dies in Console eingeben: "script>=&num;save"<br>
  380.  
  381. $</span></center>
  382. $</div>
  383.  
  384. ; -- END SCRIPT --
  385.  
  386. #
  387.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement