SMASpot Monitoring in Domoticz

From Domoticz
Jump to: navigation, search

Some SMA inverters[1] contain a built-in Bluetooth module that allows reading out power generated, including (years of) historical data.

Enabling Bluetooth

Ensure that Bluetooth is enabled on your inverter. To check whether this is enabled, use

hcitool scan

If you cannot find your inverter, try the following (continue at your own risk, only for Sunny Boy 2000/2500/3000)[2]:

  1. Disconnect inverter from AC and DC
  2. Remove the bottom black cover
  3. Slide down the box labeled COM
  4. Open the COM box
  5. Set 3rd potmeter to position 1

Installing SBFspot

N.B. There are excellent instructions with updated paths here:

First install bluetooth and SBFspot.

It is important that you log in use the following commands with the user that owns domoticz (for example the 'pi' users)

Things to remember:

  1. - Do not use a windows editor, just use 'vi' [ or the simple nano ] to edit the config file
  2. - Always login with the same user as domoticz (pi user for raspberry pi)
  3. - Follow the wiki to the letter
  4. - If you upgrade from an older version, check if you have all parameters from the latest configuration file in your config file, if needed, add the missing parts
  5. - the wiki is for a unix installation, the output path can not be C:\Temp
  6. - first test if it works, check if you get have data files (cvs/spot files)
  7. - if you change something in the configuration file, disable/enable SMASpot in domoticz to read the new configuration file

Installation Requirements

sudo apt-get install bluetooth libbluetooth-dev

From version 3.0 no longer uploads to This functionality is now in the hands of an upload service (Windows) or daemon (Linux). So libcurl3-dev is needed only if you are uploading data to

sudo apt-get install libcurl3-dev

DataBase Installation Requirements

SBFspot V3.1.2 uses database to store data from SMA inverter. It can be choosen the database to be used between MySQL and SQLite. To install SQLlite database execute:

sudo apt-get install sqlite3
sudo apt-get install libsqlite3-dev

While if you want to install MySQL the following code shall be executed:

sudo apt-get install libmysqlclient-dev

Creating Output Path

mkdir sbfdata

Compiling SBFspot

mkdir SBFspot
cd SBFspot
tar -xvf SBFspot_SRC_331_Linux_Win32.tar.gz

sudo apt-get install libboost-all-dev

SQLite: sudo make install_sqlite or
MySQL: sudo make install_mysql

Compilation Only: make release_sqlite or
make release_mysql

Installation Only:

sudo make install_release_sqlite or
sudo make install_release_mysql
In the following paragraph SQLite database has been considered

Configuring SMAspot

Run the bluetooth scan tool to get the mac address from your inverter.

Use your SMA inverter speedwire IP adress in the Ëdit config file" step.
hcitool scan

Edit config file (SBFspot.cfg)
vi SBFspot.cfg

Fill in the BT_Address=xx:xx:xx:xx:xx:xx

Opt out the BT_Address= like this: #BT_Address=
And opt in the IP_Address= and change it to your inverters IP Address
Set the OutputPath
in this case OutputPath=/home/pi/smadata/%Y

Move SBFspot.cfg to /home/pi/SBFspot/SBFspot/bin/Release_SQLite
mv SBFspot.cfg bin/Release_SQLite

cd /home/pi/SBFspot/bin/Release_SQLite/

chmod 644 SBFspot.cfg

Creating Database

cd /home/pi/SBFdata
sqlite3 SBFspot.db < /home/pi/SBFspot/SBFspot/CreateSQLiteDB.sql

Test SMASpot

cd /home/pi/SBFspot/SBFspot/bin/Release_SQLite
./SBFspot -v

If it's already dark, use ./SBFspot -v -finq

Create crontab to run it scheduled every 5 minutes

crontab -e

Add the following line:
*/5 5-23 * * * /home/pi/SBFspot/SBFspot/bin/Release_SQLite/SBFspot -v > /dev/null

Change '/5' with '/1' if you want to run every minute

Add SBFspot to Domoticz

In Domoticz hardware section, add "SBFSpot (SMA)", for location, enter the SBFspot.cfg path (e.g. /home/pi/SBFspot/SBFspot/bin/Release_SQLite/SBFspot.cfg)

Note that since the 19th November 2015 build it is possible to use SBFSpot files that record logs for multiple inverters by suffixing the configuration line with a colon, followed by the inverter serial number. For example:


Data retrieval method

Internally, domoticz relies on SBFspot to generate logfiles in the spot format. It is therefore important that SBFspot is kept running in the background (e.g. as cronjob). See SBFspot.cpp for details.

  1. Search for 'OutputPath', 'Plantname', 'DateFormat', and 'TimeFormat' in the config file
  2. Build output path filename from given config strings (sprintf(szLogFile, "%s%s-Spot-%s.csv", strftime_t(m_SBFDataPath.c_str(), atime), m_SBFPlantName.c_str(), szDateStr);)
  3. Read the output file SMA_POLL_INTERVAL per minute (default once per minute), but only if the seconds in current time are >20 (probably to give SBFspot time to query)
  4. Check if the last line is newer than the one we have, if so, store and update power data