Example on how to access data of a Sunny Boy SMA solar inverter

sbfspot is quite simple, you either choose storage of data in csv or database and then it’s up to you what you’ll do with all the date you have.

I personally did some changes into the sbfspot code so besides all the data are stored in mysql running on my nas server for later use, it’s as well storing choosen data into the memory of RPi which reads them by BT and then I have MQTT script which is monitoring those memory data and propagate them to the mqtt by usual way in homie 4 convention.

it’s very efficient system and not that hard to setup

For someone like me knowing nothing about SBFspot and mqtt, there is no thing such as “usual way” :smiley:

there is tons of guides how to work with mqtt and openhab in this forum :wink:

I find mqtt one of the most usable and most non-harsh technologies in terms of automation ever. It simply just works :wink:

  1. setup mqtt server (usually installing one package)
  2. setup mqtt client
  3. connect openhab to specified topic
  4. profit

I know, I have been reading some of them. But they´re all filled with anything else making it very confusing.
However, I just ordered a few Sonoff devices. So I guess I just have to make it happen some way or another.

if you need, I can do very simple how-to do clean mqtt setup guide for you :wink:

(and if you’ll share your network or infrastructure you running, I can tailor it for you :stuck_out_tongue: )

I would need one for sure, when the devices arrive, (hopefully in a few days).
I have ordered the Sonoff 433mhz bridge. I hope to get my doorbell (433mhz pushbutton) to work with openhab through the Sonoff 433mhz bridge.
And then I have ordered a Sonoff POWR2, just for fun I guess :slight_smile:

I´m not really sure what info you need on the network infrastructure.
I run an Ubiquity UniFi network with a USG gateway, three Access Points (two light and one proff).
Then I have 2 UniFi switches, one with POE, beside af few other brand switches with/without POE.
The controller runs on a UniFi CloudKey.

I guess thats basicly it, or?

actually not, what I need to know basically is where and how you are running OH (rpi? nas? server?) and if you have some kind of nas or something 24/7 which holds your data and can have database and if something is in range of your SMA with BT eg. RPi 3+ (i do not recommend RPi 3 build in BT as it suxx (or use BT dongle))

at the end of the day, it can be RPi running OH itself to suit as data/bridge for your SMA even as mqtt server if you like

and that would be enough to write up something :wink:

Ahh, damn… I did write all that part as well, but dumped it cause you said you needed to know the network infrastructure… Now I see, how come I didn´t quite understand that request :smiley:

Anyway…
I have three Rpi3B´s and a Odroid C2. Then i have an old Windows 2008 server and a VERY old QNAP NAS (TS-110).

One Rpi3 runing my main opehab setup. Another Rpi running an utility to IHC (IHC Captain), and the third Rpi runs a linux for browsing habpanel (my monitoring floorplan) only.
The Odriod C2 is running openhab as well. It´s a new setup (2.5M1) to test some Velbus devices I playing with.
My windows server is actually a WHS2011, but I only use it for mail server, (Hmailserver) and then I have Grafafa running for rendering charts for my main openhab server. My QNAP NAS is hardly ever used. It´s mainly file storage.

Regarding the BT… I´m not sure I have an BT dongle. I kinda hoped I could use the Rpi for this. It´s place right next to the SMA inverter anyway, (aprox 50cm). I can buy a BT dongle if it´s needed.

thanks

maybe you will have some luck, but all rpi3 I’ve tried had frozing bluetooth after like 6-10 requests. rpi3+ does not have those issues at all.
you can definitely try to run sbfspot with built-in bt and if it will work for whole day, you’ll have quite big chance it will run reliably since then, if not … well disable onboard BT and go dongle :wink:

are you running somewhere some sql database for something? as sbfspot is way easier to use that way.
if not, it’s not end of the world.

My Rpi´s are all 3B models, one is actually 3B+ (the one running my main openhab server).

Hmailserver (my mail server) uses Microsoft SQL server compact 3.5 ENU. But I have no idea how to add databases to it. It was all done by Hmailserver installer.

I can organise you a Bluetooth dongle for the C2 if you want one?

Thanks Start. But I think I´ll try go with the LAN connection which is already there, (not sure if it will conflict with the inverter having connection to the SMA Smart Energy Meter at the same time). If it does, a BT dongle might come in hand.

Hi all,
Sounds interesting, but I lost how to being able to gather information from SMA SunnyBoy with Speedwire WebConnect? Do I have to run the Python Script, or simply Mqtt, which is running on my OpenHab to connect to Worx Landroid anyway. I believr/understood I have to do some configuration with Mqtt? But fail to get it working/configured properly.

My OpenHab is running on a Windows Machine :slight_smile:
Regards,
Joerg

It’s certainly interestesting, but is there a simple way to obtain data from the standard modbus binding ?

In my case, there is a connection and I receive data from address 30775 , but I have an issue with the format.

Kind regards,
Pieter

Yep.

Typical problems include register numbering versus addressing. Historically, modbus register number 1 is found at address 0. It is often unclear which variation any given document talks about.
openHAB modbus binding always talks addresses; so sometimes if register NN looks funny it is worth checking register NN-1.

Then modbus has “table” addressing - traditionally, different types of modbus register are distinguished by the numbering i.e. “discrete” are 10001 to 19999, “input” are 30001 to 39999.
The table numbers are not used in the protocol layer - “input 30775” would be configured in the binding as “Input type, 774”. Probably?!

Table number use limits the address range, so “extended addressing” is also used. That just means that 30775 means 30775 (or maybe 30774) and that’s what you’d put in the binding config.

32-bit (or 64-bit etc.) values can highlight another issue. Modbus protocol only knows 16-bit registers, to make a 32-bit value we must use two registers. Usually NN and NN+1 - but which is the “high” part and which the “low”? There is no rule and not even a convention, is it A+B or B+A?
The binding provides two versions of datatypes i.e. int32 and int32swap. It’s up to you to find out which your device uses.

For 32-bit words, they can be signed or unsigned integers. Furthermore, they can be float numbers - at least there is a convention for that using IEEE encoding. But the word-swap dilemma still applies.

So its a bit of a nightmare. “Address 30775” might be 30774 or 775 or 774, the format might be int32 or or uint32 or float32 or int32swap or uint32swap or float32swap.
The manufacturer docs may give more help, sometimes you have to trial and error.

This has so little to do with reading data from a Sunny Boy, you’d be much better off starting a new thread about this control method.

I recognize the formatting/parsing challenges, but have been able to setup a connection to my SMA Sunny Boy over the WiFi via the standard Modbus binding.

I do still have some parsing challenges, where my current config has a Modbus poller for each data field eg. I have 1 poller setup on address 30775, with length 2, type ‘input register’ to pull current power in kWh. Setup of the data field uses the same address 30775, with type 32 bit unsigned integer.

This works, but I get parsing errors if I extend the poller to a length >2 and try to read multiple data fields. Not ideal, but workable.

The bigger issue I have is that the modbus data turns into garbage at night, when the panels are not generating any energy. When I connect to the SMA webpage I do see normal values. Any idea what is causing this and how to solve?

There’s a FAQ here about that

We might be able to help you deal with it gracefully, if you spell out what the problem it causes you is.

Show us working setup and docs for your model (they seem to vary)

hi rossko57, thanks for your quick response. I did not see this in the FAQ and CPU shutdown in case of low voltage explains the behavior as indeed I see NaN values on a few registers.

I managed to use a quick & dirty javascript transformation to “fix” this:

(function(i) {
    if(i == -2147483648) return 0;
    return i;
})(input)

I did some further tests on my earlier issue to read multiple registers at the same time and this does seem to work correctly now. I think that I got confused as I was trying to read multiple Daily Yield registers before (30535-30539) but these always return NaN even though according to the Modbus docs for my SB3.6-1AV-40 they should work (Total Yield at 30529-30533 works fine).

thanks for the help!

1 Like

Hi all,

There is a python library for home assistant that can read values from a webconnect supported inverter.

It has a basic python script example too:

DEBUG:pysma:grid_power  = 1582 W
DEBUG:pysma:voltage_l1  = 243.19 V
DEBUG:pysma:Sensor voltage_l2: No successful value decoded yet: {'1': [{'val': None}]}
DEBUG:pysma:Sensor voltage_l3: No successful value decoded yet: {'1': [{'val': None}]}
DEBUG:pysma:pv_power    = 1582 W
DEBUG:pysma:pv_gen_meter        = 332.824 kWh
DEBUG:pysma:total_yield = 332.824 kWh
WARNING:pysma:Sensor 6400_00262200: Not found in {'6400_00462500': {'1': [{'val': 0}]}, '6100_00465700': {'1': [{'val': 4998}]}, '6400_00260100': {'1': [{'val': 332824}]}, '6100_00464900': {'1': [{'val': None}]}, '6100_40463700': {'1': [{'val': None}]}, '6400_00462400': {'1': [{'val': 0}]}, '6100_00464800': {'1': [{'val': 24319}]}, '6100_40463600': {'1': [{'val': None}]}, '6100_40263F00': {'1': [{'val': 1582}]}, '6400_0046C300': {'1': [{'val': 332824}]}, '6100_00464A00': {'1': [{'val': None}]}, '6100_0046C200': {'1': [{'val': 1582}]}, '6180_08214800': {'1': [{'val': [{'tag': 307}]}]}}
DEBUG:pysma:Sensor grid_power_supplied: No successful value decoded yet: {'1': [{'val': None}]}
DEBUG:pysma:Sensor grid_power_absorbed: No successful value decoded yet: {'1': [{'val': None}]}
WARNING:pysma:Sensor 6100_00543100: Not found in {'6400_00462500': {'1': [{'val': 0}]}, '6100_00465700': {'1': [{'val': 4998}]}, '6400_00260100': {'1': [{'val': 332824}]}, '6100_00464900': {'1': [{'val': None}]}, '6100_40463700': {'1': [{'val': None}]}, '6400_00462400': {'1': [{'val': 0}]}, '6100_00464800': {'1': [{'val': 24319}]}, '6100_40463600': {'1': [{'val': None}]}, '6100_40263F00': {'1': [{'val': 1582}]}, '6400_0046C300': {'1': [{'val': 332824}]}, '6100_00464A00': {'1': [{'val': None}]}, '6100_0046C200': {'1': [{'val': 1582}]}, '6180_08214800': {'1': [{'val': [{'tag': 307}]}]}}
WARNING:pysma:Sensor 6400_00543A00: Not found in {'6400_00462500': {'1': [{'val': 0}]}, '6100_00465700': {'1': [{'val': 4998}]}, '6400_00260100': {'1': [{'val': 332824}]}, '6100_00464900': {'1': [{'val': None}]}, '6100_40463700': {'1': [{'val': None}]}, '6400_00462400': {'1': [{'val': 0}]}, '6100_00464800': {'1': [{'val': 24319}]}, '6100_40463600': {'1': [{'val': None}]}, '6100_40263F00': {'1': [{'val': 1582}]}, '6400_0046C300': {'1': [{'val': 332824}]}, '6100_00464A00': {'1': [{'val': None}]}, '6100_0046C200': {'1': [{'val': 1582}]}, '6180_08214800': {'1': [{'val': [{'tag': 307}]}]}}
               grid_power           1582 W
                frequency          49.98 Hz
               voltage_l1         243.19 V
               voltage_l2
               voltage_l3
                 pv_power           1582 W
             pv_gen_meter        332.824 kWh
              total_yield        332.824 kWh
              daily_yield
      grid_power_supplied
      grid_power_absorbed
         grid_total_yield            0.0 kWh
      grid_total_absorbed            0.0 kWh
      current_consumption
        total_consumption
                   status            307