SBFspot Bluetooth homeassistant addon

@mjude

Hi there,

Bluetooth setup looks like it is working correctly, so that’s good.

The mqtt error relates to username and password. The username and password in the SBFspot settings is being rejected because it doesn’t exist. You need to setup the user and password in either the mqtt addon or as a user in homeassistant settings.

You haven’t, but don’t use, “homeassistant” as the user either, as that is specific to homeassistant. It needs to be a separately named user.

If you have already setup a user in one of those spots, then you should double check your SBFspot addon settings for any errors.

Hi @HasQT , thanks for your reply.

I assumed it was a user error, but I still don’t understand properly: On the log I provided above, I tried to use the same user as the one used by z2m to communicate with MQTTBroker but no luck (it works between z2m and the broker though). I thought maybe it can’t be the same user. So I tried to create another user in HA users. This time I the user to mqtt_sunnyboy, but I still end with the same error:

MQTT: Publishing (homeassistant/sbfspot_{plantname}/sbfspot_{serial}),"PrgVersion": "3.9.11","Plantname": "SunnyBoyBT","Timestamp": "2024-12-03T14:31:45+0100","SunRise": "2024-12-03T07:57:00+0100","SunSet": "2024-12-03T17:02:00+0100","InvSerial": 2100249991,"InvName": "SN: 2100249991","InvTime": "2014-11-17T06:33:36+0100","InvStatus": "Ok","InvSwVer": "02.08.01.R","InvClass": "Solar Inverters","InvType": "SB 3000TL-20","InvTemperature": 42.640,"InvGridRelay": "Closed","EToday": 3.798,"ETotal": 55017.764,"GridFreq": 49.980,"PACTot": 304.000,"PAC1": 304.000,"UAC1": 230.980,"IAC1": 1.319,"OperTm": 57206.589,"FeedTm": 55544.437,"PDCTot": 309.000,"UDC1": 285.380,"UDC2": 0.000,"IDC1": 1.084,"IDC2": 0.000,"PDC1": 309.000,"PDC2": 0.000,"BTSignal": 72.941,"InvWakeupTm": "2014-11-17T00:07:45+0100","InvSleepTm": "2014-11-17T06:33:36+0100"
Client null sending CONNECT
Client null received CONNACK (5)
Connection error: Connection Refused: not authorised.
Error: The connection was refused.
MQTT: Failed to execute '/usr/bin/mosquitto_pub' mosquitto client installed?
Error 1280 while publishing to MQTT Broker
Reading events: 2024-Dec-01
Tue Dec  3 14:31:45 2024: INFO: Done.

Is it possible that password can’t use specific symbols in sbfspot?
Or maybe I’m forgetting something else? Just creating user through HA users isn’t enough?

Yes complex passwords can be a problem, although that usually relates to characters causing a split in the word, which then breaks the config. Try a fairly plain user and password with no dash or other special characters. Try adding the user in the mqtt broker too.

After some tests its seems users through Home Asssitant weren’t recognized. I created a user under mqtt broker config, but it didn’t worked either. However I finaly had it working by removing any special symbol in the password:

Client null sending CONNECT
Client null received CONNACK (0)
Client null sending PUBLISH (d0, q0, r0, m1, 'homeassistant/sbfspot_SunnyBoyBT/sbfspot_2100249991', ... (776 bytes))
Client null sending DISCONNECT
Reading events: 2024-Dec-01
Tue Dec  3 21:47:12 2024: INFO: Done.

Still, entities only report “Unknown” states, but maybe its because it’s night time.

Again, thanks for your time

1 Like

Hi @HasQT, sorry to bother you again (and for double posting). Sadly even at day time (12h30 right now), entities created through MQTTBroker keep returning “Unknown” state, and this time I absolutely don’t see any reason why this happens. Maybe you’ll have an idea.

The SBFSpot log seems perfect I think:

SBFspot V3.9.11
Yet another tool to read power production of SMA solar inverters
(c) 2012-2024, SBF (https://github.com/SBFspot/SBFspot)
Compiled for Linux (LE) 64 bit with MySQL support
Commandline Args: -v -ad1 -am0 -ae0 -mqtt
Reading config '/usr/bin/sbfspot/SBFspot.cfg'
Wed Dec  4 12:25:00 2024: INFO: Starting...
DEBUG: Retrieving new datapoints from DB...
sunrise: 07:58
sunset : 17:02
Connecting to 00:80:25:xx:xx:xx (1/10)
Initialising...
SUSyID: 125 - SessionID: 956303024
SMA netID=01
Serial Nr: 7D2F4587 (2100249991)
BT Signal=73.3%
Logon OK
SUSyID: 113 - SN: 2100249991
Device Name:      SN: 2100249991
Device Class:     Solar Inverters
Device Type:      SB 3000TL-20
Software Version: 02.08.01.R
Packet status: 21
SUSyID: 113 - SN: 2100249991
Device Status:      Ok
SUSyID: 113 - SN: 2100249991
Device Temperature: 44.0°C
SUSyID: 113 - SN: 2100249991
GridRelay Status:      Closed
SUSyID: 113 - SN: 2100249991
Energy Production:
	EToday: 2.958kWh
	ETotal: 55021.168kWh
	Operation Time: 57212.92h
	Feed-In Time  : 55550.37h
SUSyID: 113 - SN: 2100249991
DC Spot Data:
	MPPT 1 Pdc:   1.521kW - Udc: 293.85V - Idc:  5.179A
	MPPT 2 Pdc:   0.000kW - Udc:   0.00V - Idc:  0.000A
	Calculated Total Pdc:   1.521kW
AC Spot Data:
	Phase 1 Pac :   1.473kW - Uac: 231.77V - Iac:  6.359A
	Phase 2 Pac :   0.000kW - Uac:   0.00V - Iac:  0.000A
	Phase 3 Pac :   0.000kW - Uac:   0.00V - Iac:  0.000A
	Total Pac   :   1.473kW - Calculated Pac:   1.473kW
	Efficiency  :   96.84%
SUSyID: 113 - SN: 2100249991
Grid Freq. : 49.98Hz
SUSyID: 113 - SN: 2100249991
Current Inverter Time: 2014-11-18T04:27:18+0100
Inverter Wake-Up Time: 2014-11-18T00:16:15+0100
Inverter Sleep Time  : 2014-11-18T04:27:22+0100
MQTT: Publishing (homeassistant/sbfspot_{plantname}/sbfspot_{serial}),"PrgVersion": "3.9.11","Plantname": "SunnyBoyBT","Timestamp": "2024-12-04T12:25:32+0100","SunRise": "2024-12-04T07:58:00+0100","SunSet": "2024-12-04T17:02:00+0100","InvSerial": 2100249991,"InvName": "SN: 2100249991","InvTime": "2014-11-18T04:27:18+0100","InvStatus": "Ok","InvSwVer": "02.08.01.R","InvClass": "Solar Inverters","InvType": "SB 3000TL-20","InvTemperature": 43.960,"InvGridRelay": "Closed","EToday": 2.958,"ETotal": 55021.168,"GridFreq": 49.980,"PACTot": 1473.000,"PAC1": 1473.000,"UAC1": 231.770,"IAC1": 6.359,"OperTm": 57212.915,"FeedTm": 55550.366,"PDCTot": 1521.000,"UDC1": 293.850,"UDC2": 0.000,"IDC1": 5.179,"IDC2": 0.000,"PDC1": 1521.000,"PDC2": 0.000,"BTSignal": 73.333,"InvWakeupTm": "2014-11-18T00:16:15+0100","InvSleepTm": "2014-11-18T04:27:22+0100"
Client null sending CONNECT
Client null received CONNACK (0)
Client null sending PUBLISH (d0, q0, r0, m1, 'homeassistant/sbfspot_SunnyBoyBT/sbfspot_2100249991', ... (775 bytes))
Client null sending DISCONNECT
********************
* ArchiveDayData() *
********************
startTime: 04/12/2024 00:00:00
Wed Dec  4 12:25:32 2024: INFO: Done.
[12:25:45] INFO: [SBFspot Upload Log Latest]

And the MQTT Broker log don’t seems to return any error:

2024-12-04 12:25:32: New connection from 172.30.xx.xx:50228 on port 1883.
2024-12-04 12:25:32: New client connected from 172.30.xx:xx:50228 as auto-6AD68BB6-DD6C-F12E-5485-EEE2BC3A8D67 (p2, c1, k60, u'mqtt_sunnyboy').
2024-12-04 12:25:32: Client auto-6AD68BB6-DD6C-F12E-5485-EEE2BC3A8D67 disconnected.

Yet, every entities still return “Unknown” (in french sorry, “Inconnu” = “Unknown”):

I feel so close to the goal it’s so annoying. Have you any idea about what I am doing wrong?

@mjude

Try deleting the sensors and recreate them. It’s probably created the first sensors incorrectly due to the password problem.

You can check that the topics match if you click on “mqtt info” on that mqtt page, and compare to your SBFspot log(which indeed does look correct)

Edit: you can also check with MQTT explorer (on windows or the addon)
mqtt-explorer

@HasQT

Still no luck. Tried to Purge from SBFspot, tried to delete whole topic homeassistant/sensor/sbfspot_SunnyBoyBT from MQTT Explorer, then chose Create from SBFspot. Entities came back as expected, but still returning “Unknown”.

However I looked on MQTT Info as you suggested, and I think you were right, there is a mismatch between the topic shown here and the one shown on SBFspot log:

MQTT Info:

SBFSpot log:

MQTT: Publishing (homeassistant/sbfspot_{plantname}/sbfspot_{serial}),"PrgVersion": "3.9.11","Plantname": "SunnyBoyBT","Timestamp": "2024-12-04T14:35:33+0100","SunRise": "2024-12-04T07:58:00+0100","SunSet": "2024-12-04T17:02:00+0100","InvSerial": 2100249991,"InvName": "SN: 2100249991","InvTime": "2014-11-18T06:37:20+0100","InvStatus": "Ok","InvSwVer": "02.08.01.R","InvClass": "Solar Inverters","InvType": "SB 3000TL-20","InvTemperature": 46.350,"InvGridRelay": "Closed","EToday": 5.990,"ETotal": 55024.199,"GridFreq": 49.990,"PACTot": 1196.000,"PAC1": 1196.000,"UAC1": 230.910,"IAC1": 5.178,"OperTm": 57215.082,"FeedTm": 55552.533,"PDCTot": 1231.000,"UDC1": 289.550,"UDC2": 0.000,"IDC1": 4.253,"IDC2": 0.000,"PDC1": 1231.000,"PDC2": 0.000,"BTSignal": 72.941,"InvWakeupTm": "2014-11-18T00:16:15+0100","InvSleepTm": "2014-11-18T06:37:25+0100"
Client null sending CONNECT
Client null received CONNACK (0)
Client null sending PUBLISH (d0, q0, r0, m1, 'homeassistant/sbfspot_SunnyBoyBT/sbfspot_2100249991', ... (775 bytes))
Client null sending DISCONNECT

If i’m reading correctly, the topic from MQTTBroker is:
/homeassistant/sensor/sbfspot_SunnyBoyBT/
while SBFspot try to publish under
homeassistant/sbfspot_SunnyBoyBT/

I’ll try to modify MQTT topic from SBFspot config

The mqtt info state_topic is showing /sbfspot_
It is missing the serial number.

Copy your SBFspot options, so you can copy and past them back in. Delete the the addon. Delete the sensors from mqtt. Reinstall the addon, paste your config back in. Recreate the sensors.

Looks like a stuck file(fairly common) in the addon that gets created to read the serial number from your inverter. I should have said that in the last post. I should put a warning in the readme to not create the sensors until the mqtt setup is working.

Edit: the

homeassistant/*sensor*/sbfspot_SunnyBoyBT

Topic is for the discovery topic. The actual sensors topic doesn’t use the /sensor/ part

Oh, ok got it. I misunderstood the topic thing.
So I did what you said, copied my sbfspot config, uninstalled completely the addon, made sure MQTTBroker wasn’t showing SBFspot entities anymore (double checked inside MQTTExplorer), rebooted the host, pasted my SBFspot config then recreated sensors… But still no luck, entites kept reporting “Unknown”.
BUT. I did noticed a difference in behavior: MQTTBroker was reporting a correct serial number this time, both in MQTT info and in MQTTBroker Devices list. Everything looked strong this time.
Then I remembered earlier today when I thought it was a good idea to add /sensor/ in the MQTT Topic through SBFSpot config. I removed sensors again, corrected MQTT Topic path as it was earlier, recreated sensors, and BOOOOOM

Thanks again for your time and your patience, you’re a king

1 Like

Hello, I have an SMA STP8000TL-10 inverter from which I can retrieve data (current and historical) via Bluetooth with Sunny Explorer on my laptop.
Now I have had Home Assistant (HA-OS @ raspy 4) for some time and have stumbled across SPFspot.
Is it possible to retrieve the actual values in HA? I only have the user password though.
I have installed the add-on but can’t get to grips with the configuration. How do I find out the BT-MAC of the inverter? I can’t find it in Sunny Explorer.
And is there an explanation of the setup somewhere that is also suitable for beginners?

@Eisbaer2

Hi Wolfgang, Yes it sounds like you should be able to use SBFspot if you can connect to your inverter with Sunny Explorer via bluetooth. I am not familiar with your Inverter.

I usually find the bluetooth Mac using my mobile phone bluetooth connection (Sunny Explorer doesn’t list the BT mac that I have seen, ALSO make sure Sunny explorer is NOT running, you can’t have 2 connections to the inverter). Just scan for BT devices on your phone while standing near your inverter and you should be able to find the MAC in the list. Your inverter should have a Blue BT led light up if you actually connect to it.

The Bluetooth password for SBFspot will the be the same as your sunny explorer password.

The Readme on the addon or github is good place to start for setup instructions.

The other main thing you really need is the MQTT Addon and also Integration, and a dedicated User/password for MQTT, that is not your Homeassistant MQTT user. Homeassistant needs it’s own User that cannot be used for SBFspot. MQTT explorer can be useful for troubleshooting here.

Once you have MQTT working and sending data, you should be able to change the SBFspot options to create Sensors and they will be adding to Homeassistant. It is important that MQTT works prior to trying to create sensors as SBFspot needs MQTT working to detect your inverters serial number to create the correct sensors in homeassistant.

Once you have connected SBFspot to your inverter over MQTT, you can setup mariaDB database for SBFspot data storage and PVoutput if you want.

Hope that helps and happy new year.

Thank you @HasQT. And there beginns my problem. Tried with two different Android Smartphones with same result: I can see my inverter in Bluetooth. To pair I’m asked for a password (0000 and 1234 are suggested by Android). Neither 1234 nor my Sunny Explorer user password are accepted, only 0000 works. So my inverter is paired but I’m not able to connect to it. The blue LED doesn’t light up. And because of that I also can’t see a BT MAC address.

Once the inverter is saved in your Bluetooth devices list you should be able to click the cog :gear: to see it’s BTmac. I can do that on android 14 using 0000, you don’t actually need to connect beyond that with your phone.

You could also try doing that from your windows PC Bluetooth settings.it should be a similar process.

You could also try SBFspot for windows it may have inverter detection. Although I can’t confirm that as it’s been many many years since I used the windows version. It wouldn’t hurt running that to familiarise yourself with SBFspot config settings.

With a new Android App I can see all BT MACs. My both Samsung smartphones didn’t show any MACs in the system settings. So first problem solved.
I also could start SBFspot as a HA addon. When the inverter is alive, I usually get values (I get new values about every 5-10 min).
More questions:

1a) I don’t use MariaDB so far. Aren’t all values stored in the internal DB of HA (and I also have Influx DB activated)?

1b) What is the advantage of using MariaDB?

1c) How can I deactivate the use of MariaDB? In the log file I see several times “Error: Can’t open MySQL db [SBFspot] : Unknown server host ‘core-mariadb’ (-5)”

  1. What does “* ArchiveDayData() *” in the log file mean?

  2. I have one internal and one external BT adapters. Are both used (I can see both BT MACs in the log no matter which of the both MACs I use in the config)?

  3. Today I had a lot of failed connection attempts:
    Connecting to 00:80:25:1E:78:59 (1/5)
    Connecting to 00:80:25:1E:78:59 (2/5)
    Connecting to 00:80:25:1E:78:59 (3/5)
    Connecting to 00:80:25:1E:78:59 (4/5)
    Connecting to 00:80:25:1E:78:59 (5/5)
    Mon Jan 6 15:51:20 2025: CRITICAL: bthConnect() returned -1

I could connect to the inverter with Sunny Explorer without any problems at these times. Does anyone have any tips on what I can improve?

  1. I see the blue LED (BT LED) on the inverter only when the values are updated every 5-10 mins. Is it possible to leave the connection permanently on (as long as the inverter is alive)?

Thanks in advance

The values received via MQTT in Home Assistant should indeed be stored in the HA database. Any missing values would have to manually adjusted using statistics adjust feature or manually editing the HA database(not recommending that)

The main purpose of MariaDB is for uploading to PVoutput, SBFspotUpload uses the database to send the figures to PVoutput. MQTT uses the direct figures without the database. You don’t need to set up MariaBD or PVoutput if you don’t want/need them.
The Error will be remain though, The MQTT portion works fine with the error( it is just a text notification). The error will just continue to show up every 5 mins. I’d need to learn to program to have a dynamic setup capable of switching these features On of Off. There may be forks of this addon around that do this or using SBFspot directly is more configurable.

This is an SBFspot command which collects any missing data from the day and adds it to MariaDB, there is a Monthly command also. It is then used to adjust PVoutput.

The addon will show both MACs as it is detecting both MACs. It should use the one that is set in the options under LocalBTAddress.

The inverters are only capable of a single BT connection. Running Sunny Explorer will block the addon trying to make a connection. BT on raspberryPI’s(although I don’t know what device you are using) is pretty prone to interference. You could try a usb extension on the dongle BT adapter, or moving your device closer.

No, not with this addon. Even with running SBFspot directly without the addon and setting your own polling times (of say 10 seconds) you still wouldn’t achieve permanent connection as SBFspot it designed to disconnect between requests. This is not how SBFspot is written (to explore that further you would need to contact the authors of SBFspot, I only wrote the addon to interface Home Assistant.)

1 Like

@HasQT: Thanks a lot!

1 Like

After my first connection successes some days ago something has changed. I get no more connection. Here the log:

[09:18:43] INFO: 
[09:18:43] INFO:  Linux 6.6.62-haos-raspi #1 SMP PREEMPT Thu Dec 19 12:58:10 UTC 2024 aarch64
[09:18:43] INFO: 
|   INITIALISE MQTT SENSOR CREATION   |
XXX
core-mosquitto
XXX
homeassistant/sbfspot_{plantname}/sbfspot_{serial}
PrgVersion,Plantname,Timestamp,SunRise,SunSet,InvSerial,InvName,InvTime,InvStatus,InvSwVer,InvClass,InvType,InvTemperature,InvGridRelay,EToday,ETotal,GridFreq,PACTot,PAC1,UAC1,IAC1,OperTm,FeedTm,PDCTot,UDC1,UDC2,IDC1,IDC2,PDC1,PDC2,BTSignal,InvWakeupTm,InvSleepTm
[09:18:45] INFO: 
[09:18:45] INFO: 
[09:18:45] INFO:  ||    Generating HA Sensors    ||
SBFspot V3.9.11
Yet another tool to read power production of SMA solar inverters
(c) 2012-2024, SBF (https://github.com/SBFspot/SBFspot)
Compiled for Linux (LE) 64 bit with MySQL support
Commandline Args: -v -finq -mqtt -cfg/usr/bin/sbfspot/SetConfig.cfg
Reading config '/usr/bin/sbfspot/SetConfig.cfg'
Wed Jan  8 09:18:45 2025: INFO: Starting...
sunrise: 08:17
sunset : 16:42
Connecting to 00:80:25:1E:XX:XX (1/10)
Connecting to 00:80:25:1E:XX:XX (2/10)
Initialising...
SUSyID: 125 - SessionID: 961637948
SMA netID=01
Serial Nr: XXX
BT Signal=70.6%
Wed Jan  8 09:19:45 2025: CRITICAL: Logon failed. Reason unknown (-1)
Wed Jan  8 09:19:45 2025: INFO: Done.
[08:19:45] WARNING: Halt add-on with exit code 1
s6-rc: info: service legacy-services: stopping
s6-rc: info: service legacy-services successfully stopped
s6-rc: info: service legacy-cont-init: stopping
s6-rc: info: service legacy-cont-init successfully stopped
s6-rc: info: service fix-attrs: stopping
s6-rc: info: service fix-attrs successfully stopped
s6-rc: info: service s6rc-oneshot-runner: stopping
s6-rc: info: service s6rc-oneshot-runner successfully stopped

And here my configuration:

Connection_Type: Bluetooth
Sensors_HA: Create
BTAddress: XXX
Password: XXX
LocalBTAddress: XXX
IP_Address: 55.255.255.255
Plantname: PV
Latitude: "49"
Longitude: "9"
Timezone: Europe/Brussels
DateTimeFormat: "'%H:%M:%S %d-%m-%y'"
SQL_Password: fake
MQTT_User: XXX
MQTT_Pass: XXX
MQTT_Topic: homeassistant/sbfspot_{plantname}/sbfspot_{serial}
MQTT_Data: >-
  PrgVersion,Plantname,Timestamp,SunRise,SunSet,InvSerial,InvName,InvTime,InvStatus,InvSwVer,InvClass,InvType,InvTemperature,InvGridRelay,EToday,ETotal,GridFreq,PACTot,PAC1,UAC1,IAC1,OperTm,FeedTm,PDCTot,UDC1,UDC2,IDC1,IDC2,PDC1,PDC2,BTSignal,InvWakeupTm,InvSleepTm
PVoutput_SID: "0123456789:12345"
PVoutput_Key: fake
LogLevel: debug

Anyone has an idea what to change to have more success? I have the current version: 2025.1.0, HAOS 2025.1.1 on a Raspi 4

Looks like you are putting the wrong password. This is the first password in configuration. It should be the same as Sunny Explorer. Double check you don’t have a typo.

I’m absolutely sure using the right password and have no more idea what ton change. The BT quality seems good enough with >70%.

Today all my further connection trials failed. Maybe something changed with last update?

Do you have “quotes” wrapping the password?

The addon is particularly troublesome with “quote mark” as the text is converted from HA to the addon and then to the SBFspot config file. Especially when swapping from UI config mode to YAML config mode.

The password should be showing as “password” in the YAML config

I doubt the update of HA will be the problem, but I haven’t updated yet to confirm.