Rewrite of smatool: OpenSunny

890 views
Skip to first unread message

Christian Simon

unread,
Jun 16, 2012, 2:08:13 PM6/16/12
to sma-bl...@googlegroups.com
Hi,

I just wanna introduce my "litte" rewrite of smatool. It's at very early stage, up to now it's only able to show live values of my 5000TL20/21 inverters. But i'm planning to implement multi inverter mode, value upload, historic value ability.

I started with forking smatool, but ended up rewriting the whole thing since i simply didn't get on with the unstructured few documented code...

I would find it great if someone could test my litte project with his inverters and probably smatool could benefit for my code...

You will find the project on github:
http://www.github.com/simonswine/opensunny

Here is on usage example:

./opensunny -i 00:80:25:22:C6:3B
2012-06-16T11:04:07.885097:INFO:[Value] timestamp=1339837491 power_ac=952W
2012-06-16T11:04:07.962390:INFO:[Value] timestamp=1339837491 yield_total=207.731kWh
2012-06-16T11:04:08.043337:INFO:[Value] timestamp=1339837491 power_dc_1=536W
2012-06-16T11:04:08.043362:INFO:[Value] timestamp=1339837491 power_dc_2=475W
2012-06-16T11:04:08.043373:INFO:[Value] timestamp=1339837491 voltage_dc_1=309.370V
2012-06-16T11:04:08.043387:INFO:[Value] timestamp=1339837491 voltage_dc_2=283.240V
2012-06-16T11:04:08.146788:INFO:[Value] timestamp=1339837487 ac_unkown_1=35??
2012-06-16T11:04:08.146809:INFO:[Value] timestamp=1339837491 ac_unkown_2=303??
2012-06-16T11:04:08.146820:INFO:[Value] timestamp=1339837491 ac_unkown_3=303??
2012-06-16T11:04:08.146829:INFO:[Value] timestamp=1339837487 ac_unkown_4=16777518??
2012-06-16T11:04:08.146838:INFO:[Value] timestamp=1339837487 ac_unkown_5=336??
2012-06-16T11:04:08.146847:INFO:[Value] timestamp=1339837487 ac_unkown_6=16777518??
2012-06-16T11:04:08.146856:INFO:[Value] timestamp=1339837491 ac_unkown_7=16777267??
2012-06-16T11:04:08.146865:INFO:[Value] timestamp=1339837491 ac_unkown_8=557??

Thanks,

simonswine

sbf

unread,
Jun 18, 2012, 6:40:07 AM6/18/12
to sma-bl...@googlegroups.com
Dear Simon,

please tell us you're not rewriting smatool, but you're refactoring another tool you found on github. Stuart will not be happy you're using his work without mentioning his name.
OK, the code isn't copied "as is", but there are enough traces left. 

void in_smadata2plus_level2_trailer(unsigned char * buffer,
struct smadata2_l2_packet *p) {

// FCSChecksum =FCSChecksum ^ 0xffff;
//
// btbuffer[packetposition++]=FCSChecksum & 0x00ff;
// btbuffer[packetposition++]=(FCSChecksum >> 8) & 0x00ff;
// btbuffer[packetposition++]=0x7e; //Trailing byte

}

vs

void writeSMANET2PlusPacketTrailer(unsigned char *btbuffer){
  FCSChecksum =FCSChecksum ^ 0xffff;

  btbuffer[packetposition++]=FCSChecksum & 0x00ff;
  btbuffer[packetposition++]=(FCSChecksum >> 8) & 0x00ff;
  btbuffer[packetposition++]=0x7e; //Trailing byte

    //Serial.print("Send Checksum=");Serial.println(FCSChecksum,HEX);
}

I totally agree, saying "smatool is unstructured" is an understatement. Also, the mess with the invertercodes should come to an end with a new tool based on Stuart's code.
Btw, me too I'm working on such a "new" smatool

Op zaterdag 16 juni 2012 20:08:13 UTC+2 schreef simonswine het volgende:

stuart

unread,
Jun 19, 2012, 3:49:22 AM6/19/12
to sma-bl...@googlegroups.com
Glad my code is coming in useful, but like to point out that I distributed my code under "Attribution-NonCommercial-ShareAlike 3.0 Unported" licences, so not sure you can easily copy and change to another licence type as you have done.

Notice that you still have references to "Inverter Codes" in you're source code - this is completely unnecessary, my code works without modification on at least 6 inverters that I've been told it works upon - including 3000TL/HF, TriPower 8000, 5000TF models.

The SMA protocol is generic across most of its inverter range, so the inverter codes is a legacy of sma-bluetooth codebase and its unintelligent processing of the SMA packets.

janus

unread,
Jun 26, 2012, 2:42:23 AM6/26/12
to sma-bl...@googlegroups.com
Hi Guys,
great that some people are working on smatool or new and better implementations. What i do not understand is why so many people seem to think that the linix principle is wrong.

What i mean is: Release often...

At a minimum 4 people i know are working but there is little working together and a minimum at documentation for the reverse engineered SMA2+ protocol. Maybe we could find a place and a wiki to document the protocol so that not everybody has to do this work again and again.

Just my 2 cents, Greetings

Janus

Blokker_1999

unread,
Jun 26, 2012, 8:05:57 AM6/26/12
to sma-bl...@googlegroups.com
"Glad my code is coming in useful, but like to point out that I distributed my code under "Attribution-NonCommercial-ShareAlike 3.0 Unported" licences, so not sure you can easily copy and change to another licence type as you have done."

You are right, it isn't possible. While Share Alike is a requirement of the GPLv3 that it was licensed under, the other 2 are not. While code under these licenses could function together, you can not swap one licence with another.

Christian Simon

unread,
Oct 12, 2012, 6:28:40 AM10/12/12
to sma-bl...@googlegroups.com
Hi Dieter,

i'm sure i can include this, but i'm pretty busy until mid november, the probably ask again. If you know howto sniff on bluetooth. A dump of setting or getting the relay state will be pretty helpful!

cheers


Am 09.10.2012 16:22, schrieb Dieter Vanwijnsberghe:
> Hi Simon,
>
> can you please include control for the multifuntional relay ?
>
> thanks
>
> On Saturday, June 16, 2012 8:08:13 PM UTC+2, simonswine wrote:
>
> Hi,
>
> I just wanna introduce my "litte" rewrite of smatool. It's at very early stage, up to now it's only able to show live values of my 5000TL20/21 inverters. But i'm planning to implement multi inverter mode, value upload, historic value ability.
>
> I started with forking smatool, but ended up rewriting the whole thing since i simply didn't get on with the unstructured few documented code...
>
> I would find it great if someone could test my litte project with his inverters and probably smatool could benefit for my code...
>
> You will find the project on github:
> http://www.github.com/simonswine/opensunny <http://www.github.com/simonswine/opensunny>

Dieter Vanwijnsberghe

unread,
Oct 15, 2012, 8:30:16 AM10/15/12
to sma-bl...@googlegroups.com
Hi Simon,
thanks for the reply
I'll try to get a dump!

greets
Dieter

Stephen More

unread,
Oct 19, 2012, 1:03:18 PM10/19/12
to sma-bl...@googlegroups.com
I tried opensunny on a Marvell SheevaPlug today,

FYI here is my output:

timestamp=5999 total=1350665.812 kWh
timestamp=5999 total=5.999 kWh
timestamp=1350665812 total=4857.601 kWh
timestamp=80 total=0.080 kWh
timestamp=0 total=0.001 kWh
timestamp=0 total=20012.767 kWh
timestamp=0 total=20012.767 kWh
timestamp=0 total=20012.767 kWh
timestamp=0 total=20012.767 kWh
timestamp=0 total=20012.767 kWh
timestamp=0 total=20012.767 kWh
timestamp=0 total=20012.768 kWh
timestamp=0 total=20012.768 kWh
timestamp=0 total=20012.768 kWh
timestamp=0 total=20012.768 kWh
timestamp=0 total=20012.768 kWh
timestamp=0 total=20012.768 kWh
Message has been deleted

skij

unread,
Jan 29, 2013, 5:17:59 AM1/29/13
to sma-bl...@googlegroups.com
My output on a SB3300TLHC

root@raspberrypi:~/opensuny/
opensunny# ./opensunny -i 00:80:25:0B:EA:59
2013-01-29T11:15:50.203466:INFO:[Value] Inverter found serial=1100216672 model=%dTL
timestamp=0 total=11964.232 kWh
timestamp=0 total=11964.232 kWh
timestamp=0 total=11964.232 kWh
timestamp=0 total=11964.232 kWh
timestamp=0 total=11964.232 kWh
timestamp=0 total=11964.232 kWh
timestamp=0 total=11964.232 kWh
etc...

Dieter Vanwijnsberghe

unread,
Mar 27, 2013, 4:04:32 AM3/27/13
to sma-bl...@googlegroups.com
okay , I finally got a dump using USBlyzer trial (usbsnoopy didn't seem to work on win7)

I have attached it as a text file
You need to set the mode of the relay to "communication controlled" first, using sunnyboy

I guess the "4" and "/" are the distinguishing chars (not sure)

would be great feature to control this from a linux cli


cheers
D
capture smatool.txt
Reply all
Reply to author
Forward
0 new messages