Open GoogleCodeExporter opened 9 years ago
I tried http://code.google.com/p/sma-bluetooth/issues/detail?id=91&sort=-id
Going to see what happens tomorrow.
Original comment by Filip.Sm...@gmail.com
on 3 Mar 2013 at 12:22
Seems to fix the problem ;)
Original comment by Filip.Sm...@gmail.com
on 3 Mar 2013 at 9:28
Ill Also post my Inv codes I used for my sma:
Inverter code SMA STP 8000TL latest firmware 2.54 (European)
Inverter 8000TL
Code1 0x3e
Code2 0x70
Code3 0xf9
Code4 0x39
InvCode 0x80
Also I made an modification to my smatool.c
I commented out the Date error lines:
Cause it gave me trouble sometimes:
if( idate != prev_idate+300 ) {
printf( "Date Error! prev=%d current=%d\n", (int)prev_idate, (int)idate );
//error=1;
//break;
}
Next i didn't want to run a script to clean the Database of false data, so i
made a modification that only valid data can go in my database:
if ((mysql ==1)&&(error==0)){
/* Connect to database */
OpenMySqlDatabase( conf.MySqlHost, conf.MySqlUser, conf.MySqlPwd, conf.MySqlDatabase );
for( i=1; i<archdatalen; i++ ) //Start at 1 as the first record is a dummy
{
//convert into year earase 1970
struct tm *tempdate = gmtime( &(archdatalist+i)->date);
if (debug == 1) printf( "Year = %d\n", tempdate->tm_year+1900);
//print data
if (debug == 1) printf("CurrentPower %0.f\n",(archdatalist+i)->current_value);
if (debug == 1) printf("Currentdate %ld\n",(archdatalist+i)->date);
// remove wrong data
if ((((archdatalist+i)->current_value) < 9000) && (((archdatalist+i)->current_value) >= 0) && (tempdate->tm_year+1900 > 1970))
{
sprintf(SQLQUERY,"INSERT INTO DayData ( DateTime, Inverter, Serial, CurrentPower, EtotalToday ) VALUES ( FROM_UNIXTIME(%ld)$
if (debug == 1) printf("%s\n",SQLQUERY);
if (debug == 1) printf("Valid data\n");
DoQuery(SQLQUERY);
}
}
mysql_close(conn);
}
enclosed is my smatool.c.
Hope it can help someone in the future!
Original comment by Filip.Sm...@gmail.com
on 3 Mar 2013 at 9:51
Attachments:
Also i like to notice, i get allot of date errors when i run smatool -d -v BUT
when i run smatool -v there are almost none!
Repost also doesn't work for me like i want, pvoutput only allows 60 updates in
one hour. repost posts everything separated so it doesn't combine the outputs.
I fixed repost with bash script at the moment, by setting PVoutput back to NULL
and running ./smatool again:
#!/bin/bash
#
cat << EOF | mysql --password=raspberry -u Pi1 smatool | tee -a logfile.log
SELECT * FROM DayData WHERE DateTime LIKE "2013-03-04 %%:%%:%%" ORDER BY
DateTime DESC;
UPDATE DayData SET PVOutput = NULL WHERE DateTime LIKE "2013-03-04 %%:%%:%%"
ORDER BY DateTime DESC;
#SELECT * FROM DayData WHERE CurrentPower>9000;
#DELETE FROM DayData WHERE CurrentPower>9000;
#SELECT * FROM DayData WHERE CurrentPower<=0;
#DELETE FROM DayData WHERE CurrentPower<=0;
#SELECT * FROM DayData WHERE DateTime LIKE "1970-%%-%% %%:%%:%%";
#DELETE FROM DayData WHERE DateTime LIKE "1970-%%-%% %%:%%:%%";
EOF
Original comment by Filip.Sm...@gmail.com
on 5 Mar 2013 at 12:12
Next i changed
sprintf(SQLQUERY,"INSERT INTO DayData ( DateTime, Inverter, Serial,
CurrentPower, EtotalToday, PVOutput ) VALUES (
FROM_UNIXTIME(%ld),\'%s\',%ld,%0.f, %.3f,FROM_UNIXTIME(%ld) ) ON DUPLICATE KEY
UPDATE DateTime=Datetime, Inverter=VALUES(Inverter), Serial=VALUES(Serial),
CurrentPower=VALUES(CurrentPower), EtotalToday=VALUES(EtotalToday),
PVOutput=VALUES(PVOutput)",(archdatalist+i)->date, (archdatalist+i)->inverter,
(archdatalist+i)->serial, (archdatalist+i)->current_value,
(archdatalist+i)->accum_value, NULL );
I set PVoutput to NULL when new data is added, in this case if data get's
overwritten by new data it will be updated to PVoutput. This is needed when a
date error gives an value of 0, gets posted to pvoutput and next run it will be
updated in the DB but will not be updated in PVoutput cause the DB says that it
is already added to PVoutput.
Original comment by Filip.Sm...@gmail.com
on 5 Mar 2013 at 12:25
Original issue reported on code.google.com by
Filip.Sm...@gmail.com
on 2 Mar 2013 at 8:01