Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- >D 40
- ; for external ScriptEditor
- ; Version see >W section
- IP=192.168.0.50
- ; SB=6200 only if you have 1M flash
- ; and compile with #define EEP_SCRIPT_SIZE 6200
- ; and #define USE_EEPROM
- ; 6 Arrays, compile with
- ;#ifdef MAXFILT
- ;#undef MAXFILT
- ;#endif
- ;#define MAXFILT 6
- SB=6200
- ; HowTo:
- ; Download the ScriptEditor from Tasmota Script page
- ; Change the IP and maybe the SB (look for EEP_SCRIPT_SIZE Tasmota Script page)
- ; change the -- SML -- script to your needs
- ; search for -300 und change it to your needs (I have only 300W PV) or remove it
- ; First start, go to console and type: script>=#dreset
- ; This will set the correct day consumption value
- ; 4h chart is not permament, after restart data is lost
- ; 24h, month and year chart is permament. Arrays are saved at midnight.
- ; to save immediately go to console and enter: script>=#save
- ; to change some values enter e.g.: script >dcon[day]=xxx
- ; console commands:
- ; script?var = get variable
- ; script >var=1 = set variable
- ; script>=svars = save permament var
- ; script>=#sub = run sub
- ; -- ARRAYS --
- ; 4h chart temp
- M:t4h=0 240
- ; 4h chart hum
- M:h4h=0 240
- ; 4h chart dew
- M:d4h=0 240
- ; 24h power chart temp
- M:hday=0 96
- ; 24h power chart hum
- M:tday=0 96
- ; 24h power chart dew
- M:dday=0 96
- ; -- VARS --
- ; monthval and dayval
- p:mval=0
- p:dval=0
- tmp=0
- mtem=0
- mhum=0
- mdew=0
- cstr=""
- cstr2=""
- avgval=0
- avgvalh=0
- avgvald=0
- avgvalcnt=0
- hour=0
- mont=0
- minutes=0
- ; -- BOOT --
- >B
- cstr2="cnth"+s(1.0((hours-4)*60)+(mins*1))+"/60"
- ;disable mqtt at boot prevents sending 0
- smlj=0
- ; -- SUBS --
- ; 24h power chart
- #dreset
- for tmp 1 tday[-1] 1
- tday[tmp]=0
- hday[tmp]=0
- dday[tmp]=0
- next
- svars
- ; daily consumption month chart
- ; !execute this at the first time!
- ; save
- #save
- print saving
- ;svars
- ; -- EVERY SECOND --
- >S
- hour=hours
- mont=month
- ;avoid send 0 via mqtt after boot
- if (upsecs>15)
- then
- smlj=1
- else
- break
- endif
- ; copy SML values - every 15s
- if (secs%15==0)
- then
- ; MQTT
- ;=>publish tele/%topic%/SENSOR {"Time":"%tstamp%","MT175":{"daily_con":%2dcon[day]%,"monthly_con":%2mcon[month]%}}
- endif
- ; 4h power chart - every 60s
- if (secs%60==0)
- then
- ; temp and hum to array, idx is set automatically
- t4h=gtmp
- h4h=ghum
- d4h=gtmp-((100-ghum)/5)
- ; sum up power for "24h chart"
- avgval+=gtmp
- avgvalh+=ghum
- avgvald+=gtmp-((100-ghum)/5)
- avgvalcnt+=1;
- endif
- ; set x axis index to 4 hours a 30 sec therefore /240, no decimal point
- hour-=4
- if (hour<0)
- then
- cstr2="cnth"+s(1.0((24-4+hours)*60)+(mins*1))+"/60"
- else
- cstr2="cnth"+s(1.0((hours-4)*60)+(mins*1))+"/60"
- endif
- hour=hours
- ; 24h power chart
- ; calc avg temp [C] for last 15min and put into array[1-96]
- mtem=int((((hours*60)+mins)/15)+1)
- mhum=int((((hours*60)+mins)/15)+1)
- mdew=int((((hours*60)+mins)/15)+1)
- if ((mins%15==0) and (chg[mtem]>0))
- then
- ;Temperature
- [mtem]=int(10*avgval/avgvalcnt)/10
- tday[mtem]=int(10*avgval/avgvalcnt)/10
- ;Humidity
- [mhum]=int(10*avgvalh/avgvalcnt)/10
- hday[mhum]=int(10*avgvalh/avgvalcnt)/10
- ;Dew-Point
- [mdew]=int(10*avgvald/avgvalcnt)/10
- dday[mdew]=int(10*avgvald/avgvalcnt)/10
- avgval=0
- avgvalh=0
- avgvald=0
- avgvalcnt=0
- ;svars save too often will damage flash
- endif
- ; set idx (pointer starts from 0!!)
- tday[0]=mtem
- hday[0]=mhum
- dday[0]=mdew
- ; set x axis idx to 24 hours a 15 min therefore /4, no decimal point
- ; calc minutes for x-axis
- tmp=hours
- if (mins<45)
- then
- minutes=mins+15
- else
- minutes=mins-45
- if (tmp<23)
- then
- tmp+=1
- else
- tmp=0
- endif
- endif
- cstr="cnt"+s(1.0(tmp+(int(minutes/15)/4))*4)+"/4"
- ; WEB INTERFACE
- >W
- ; Auto reload
- ;$<script> setTimeout("location.reload(true);",5000); </script>
- ; consumption
- ;Luftfeuchtigkeit:{m}%1(ghum)% %
- ;Temperatur:{m}%1(gtmp)% C
- ; Time/Date
- Datum:{m}%s(2.0day)%.%s(2.0month)%.%s(2.0year)% - %s(2.0hours)%:%s(2.0mins)%:%s(2.0secs)%
- Uptime:{m}%0uptime% min
- $<div style="margin-left:-20px">
- ; 4h chart
- $<div id="chart1" style="text-align:center;width:390px;height:100%%;padding:0px"></div>
- $gc(lt t4h h4h d4h "wr" "Temperatur" "Luftfeuchtigkeit" "Taupunkt" cstr2)
- $var options = {
- $chartArea:{left:30,right:30},
- ;$width:'50%%',
- $legend:'top',
- ;$vAxes:{0:{title:'Außentemperatur'}},
- ;$hAxes:{0:{title:'4 Stunden Ãœbersicht'}},
- $explorer:{actions:['dragToZoom', 'rightClickToReset']},
- $title:'4 Stunden Ãœbersicht'
- $};
- $gc(e)
- ; 24h chart
- $<div id="chart2" style="text-align:center;width:400px;height:100%%;padding:0px"></div>
- $gc(lt tday hday dday "wr" "Temperatur" "Luftfeuchtigkeit" "Temperatur" cstr)
- $var options = {
- $chartArea:{left:30,right:30},
- ;$width:'50%%',
- $legend:'top',
- $explorer:{actions:['dragToZoom', 'rightClickToReset']},
- ;$series: {0: {type: 'area'}},
- ;$series: {1: {type: 'area'}},
- ;$series: {2: {type: 'area'}},
- ;type: „line“, „area“, „bars“, „candlesticks“ und „steppedArea“
- ;$seriesType: 'bars',
- $title:'24 Stunden Ãœbersicht'
- $};
- $gc(e)
- ;Einfacher Chart mit 2 Zeilen
- ;$<div id="chart5" style="text-align:center;width:400px;height:100%%;padding:0px"></div>
- ;$gc(c t4h h4h d4h "wr" "Grad C" "Prozent" "Grad C" cstr2 "4 Stunden")
- ;$<div id="chart5" style="text-align:center;width:400px;height:100%%;padding:0px"></div>
- ;$gc(c d4h "wr" "C" cstr "Temperatur 24h")
- $<center><span style="font-size:10px;">
- $Version 2023.01.22<br>
- $free heap: %s(0.0heap)% bytes<br>
- $Hinweis: Die Daten werden immer um Mitternacht gespeichert!<br>
- $Sofort speichern dies in Console eingeben: "script>=#save"<br>
- $</span></center>
- $</div>
- ; -- END SCRIPT --
- #
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement