TASMOTA Stromzähler; MQTT Problem #23087
Unanswered
Mark-Gro
asked this question in
scripter / SML
Replies: 1 comment
-
Other Tasmota commands are usually executed with prefix |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello guys,
I have Tasmota 14.2.0 (ottelo.jimdo.de) by Theo Arends](https://bit.ly/tasmota) running with an electricity meter.
It works fine. It send MQTT messages to my raspbery and here I react and send new limits to my inverter.
Now i would like to do it without raspberry.
When i type directly into the Tasmota-console:
publish ahoidtu_mg75/ctrl/limit/0 300W
=> this works.
But If I do it in my script the publish command will be ignored. I don't understand why.
The print command in the next line works and the right values appears in the log.
Any ideas?
Here is the script if you would like to check:
; Description:
; Version see >W section
; Tasmota SML Script with Google Chart Support
; 4h, 24h Consumption Line Charts
; Month and Year Consumption (from grid) Tables
; Month and Year PV Production (to grid) Table
; Optional: Switch second esp if enough energy flows to grid (e.g. pool pump)
; charts need 30/60s to show correctly after boot
; Tasmota needs correct working NTP (internet) otherwise script dont start
; HowTo:
; Download the ScriptEditor from Tasmota Script page or remove all comments manually
; https://www.dropbox.com/sh/0us18ohui4c3k82/AACcVmpZ4AfpdrWE_MPFGmbma?dl=0
; Change the IP
; change the -- SML -- script to your needs but dont change the order!
; hml_neu und hml_alt hinzu für Einspeisen von Marstek=>Ahoy-DTU=>Wechselrichter
; 4h chart are not permament, after restart data is lost
; 24h, month and year chart is permament and saved at midnight to flash
; First start, go to console and type:
;backlog script >dval=EnFrGrid; script >dval2=EnToGrid; script >dcon={0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0}; script >dprod={0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0};
;backlog script >mval=EnFrGrid; script >mval2=EnToGrid; script >mcon={0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0};
;script >=#rst24h
;script >svars
; 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 all permament vars
; script >=#sub = run sub
; -- ARRAYS --
; 24h power chart
M:p:sday=0 288
; daily energy from grid table day 1-31
M:p:dcon=0 31
; daily energy to grid table day 1-31
M:p:dprod=0 31
; monthly energy table
; from grid 1-12
; to grid 13-24
M:p:mcon=0 24
; 4h power chart, value every 30s
M:s4h=0 480
; -- VARS --
; energy from grid [kWh]
EnFrGrid=0
; energy to grid [kWh]
EnToGrid=0
; actual power from or to grid [W]
power=0
; monthval and dayval
p:mval=0
p:dval=0
p:mval2=0
p:dval2=0
tmp=0
m5=0
cstr="cnt0/12"
cstr2="cnth0/120"
utm="00d 00h 00m"
avgv=0
avgv2=0
avgvc=0
avgvc2=0
hour=0
da=1
; Einspeisen von Marstek=>Ahoy-DTU=>Wechselrichter Hoymiles HM-600
hml_neu=0
hml_alt=0
; -- BOOT --
; -- SUBS --
; reset 24h chart
#rst24h
for tmp 1 sday[-1] 1
sday[tmp]=0
next
; daily consumption month table
#daysub
wcs
wcs <script language="JavaScript">function drawChart(){
wcs var cssc={'headerRow':'hRow','rowNumberCell':'hCol','tableCell':'tCell'};
wcs var data=google.visualization.arrayToDataTable([['Tag','Energie [kWh]',{role: 'style'}],
for tmp 1 dcon[-1] 1
if (tmp==day)
{
wcs [%tmp%,%dcon[tmp]%,'red'],
}
if (tmp<day)
{
wcs [%tmp%,%dcon[tmp]%,'green'],
}
if (tmp>day)
{
wcs [%tmp%,%dcon[tmp]%,''],
}
next
wcs ]);
wcs var options={chartArea:{left:40,width:'86%%'},legend:'none',title:'Tagesverbräuche Monatsansicht',vAxis:{format:'# kWh'},hAxis:{title:'Tag',ticks:[1,5,10,15,20,25,30]}};
wcs var chart=new google.visualization.ColumnChart(document.getElementById('day'));
wcs chart.draw(data,options);}google.charts.setOnLoadCallback(drawChart);</script>
; daily production month table
#dayprod
wcs
wcs <script language="JavaScript">function drawChart(){
wcs var cssc={'headerRow':'hRow','rowNumberCell':'hCol','tableCell':'tCell'};
wcs var data=google.visualization.arrayToDataTable([['Tag','Energie [kWh]',{role: 'style'}],
for tmp 1 dprod[-1] 1
if (tmp==day)
{
wcs [%tmp%,%dprod[tmp]%,'red'],
}
if (tmp<day)
{
wcs [%tmp%,%dprod[tmp]%,'green'],
}
if (tmp>day)
{
wcs [%tmp%,%dprod[tmp]%,''],
}
next
wcs ]);
wcs var options={chartArea:{left:40,width:'86%%'},legend:'none',title:'Tageseinspeisung Monatsansicht',vAxis:{format:'# kWh'},hAxis:{title:'Tag',ticks:[1,5,10,15,20,25,30]}};
wcs var chart=new google.visualization.ColumnChart(document.getElementById('dayp'));
wcs chart.draw(data,options);}google.charts.setOnLoadCallback(drawChart);</script>
; monthly consumption & production year table
#monthsub
wcs
wcs <script language="JavaScript">function drawChart(){
wcs var cssc={'headerRow':'hRow','rowNumberCell':'hCol','tableCell':'tCell'};
wcs var data=google.visualization.arrayToDataTable([['Monat','Energie [kWh]',{role: 'style'}],
for tmp 1 12 1
if (tmp<month)
{
wcs ['%is[tmp]%',%mcon[tmp]%,'green'],
wcs ['%is[tmp]% (PV)',%mcon[tmp+12]%,'green'],
}
if (tmp==month)
{
wcs ['%is[tmp]%',%mcon[tmp]%,'red'],
wcs ['%is[tmp]% (PV)',%mcon[tmp+12]%,'red'],
}
if (tmp>month)
{
wcs ['%is[tmp]%',%mcon[tmp]%,''],
wcs ['%is[tmp]% (PV)',%mcon[tmp+12]%,''],
}
next
wcs ]);
wcs var options={chartArea:{left:40,width:'86%%'},legend:'none',title:'Monatliche Verbräuche / Solareinspeisungen Jahresansicht',vAxis:{format:'# kWh'}};
wcs var chart=new google.visualization.ColumnChart(document.getElementById('month'));
wcs chart.draw(data,options);}google.charts.setOnLoadCallback(drawChart);</script>
;-- SML --
; -- EVERY SECOND --
;check if NTP works, otherwise arrays can be corrupted
if (year<2020)
{
print NTP not ready
break
}
; every 3s
if (secs%3==0)
{
; actual power [W]
;power=rnd(1000)-500 for google chart testing
; copy SML value
power=sml[1]
; sum up power sml[1] for 4h and 24h chart
avgv+=power
avgv2+=power
avgvc+=1
avgvc2+=1
}
; every 30s
if (secs%30==0)
{
; 4h chart. idx is set automatically
s4h=avgv/avgvc
avgv=0
avgvc=0
}
; every 60s
if (secs%60==0)
{
hour=hours
;uptime in days hours minutes
utm=s(2.0(int(uptime/1440)))+"d "+s(2.0(int(uptime/60)%24))+"h "+s(2.0(uptime%60))+"m"
}
; WEB INTERFACE
; web button
; switch second ESP if power flows to grid, see >S section
;bu(swesp "switch ESP ON" "switch ESP OFF")
; consumption
Tagesverbrauch:{m}%2(EnFrGrid-dval)% kWh
Monatsverbrauch:{m}%2(EnFrGrid-mval)% kWh
; production
Tageseinspeisung:{m}%2(EnToGrid-dval2)% kWh
Monatseinspeisung:{m}%2(EnToGrid-mval2)% kWh
; Time/Date
Datum:{m}%s(2.0day)%.%s(2.0month)%.%s(2.0year)% - %s(2.0hours)%:%s(2.0mins)%:%s(2.0secs)%
Uptime:{m}%0utm%
$
; 4h power chart - new value every 30s
$
$gc(lt s4h "wr" "Leistung [W]" cstr2)
$var options = {
$chartArea:{left:60,width:'83%%'},
$legend:'none',
$vAxis:{format:'# W'},
$explorer:{actions:['dragToZoom', 'rightClickToReset']},
$series: {0: {type: 'area'}},
$title:'Verbrauch 4 Stunden [Watt]'
$};
$gc(e)
; 24h power chart
$
$gc(lt sday "wr" "Leistung [W]" cstr)
$var options = {
$chartArea:{left:60,width:'83%%'},
$legend:'none',
$vAxis:{format:'# W'},
$explorer:{actions:['dragToZoom', 'rightClickToReset']},
$series: {0: {type: 'area'}},
$title:'Verbrauch 24 Stunden [Watt]'
$};
$gc(e)
; simply chart with 2 rows
;$
;$gc(c dprod "wr" "kWh" "cnt1" "Tägliche Einspeisung")
; daily energy consumption month chart
%=#daysub
%=#dayprod
; monthly energy consumption year chart
%=#monthsub
$
$Version 2023.02.28 (PV) by ottelo.jimdo.de & Dennis
$Hinweis: Die Daten werden immer um Mitternacht gespeichert!
$Sofort speichern dies in Console eingeben: "script >svars"
$
; -- END SCRIPT --
Beta Was this translation helpful? Give feedback.
All reactions