Anyone know howto read SMA Sunny Beam data into HA?

Thx, I changed your code on my running HA system, rebooted afterwards, and it works just fine.
so every time there is an update, I’ll have to remember to add the change myself.

Hi,

I was struggling to make the smbtool working with my sunnybeam, it was always returning 0160.
It was the case with the python code, but as well for original C version that I compiled. Same in the rPi and on my mac.
I was able to connect to the sunnybeam via a windows virtual machine and the old SDC software.
So, as I was being able to read the data from SDC , I decided to go further and sniff the USB messages !

I saw that the message to get the device id was different than the tool.
SDC is sending

7EFF03404100000000900003D2F45808D4F58B7B7E

But the SunnyBeamTool (SBT) is sending:
7EFF0340410000000090000280854F2DB2E67E

Quite different. SBT is hardcoding the first byte with 7EFF03404100000000900002 while SDC is sending 7EFF03404100000000900003
The message submitted by SDC is 21 bytes while SBT is 19 bytes. I don’t really know why there is this difference and I didn’t really investigate it yet BUT I hardcoded the byte array in search_device_id() to the one sent by SDC and … Voila !
It is now working with the compiled C version, the device id is now returned by the sunnybeam and all other methods are working correctly so I can now retrieve my data !

I’m not very fluent with python, but any idea how I could have a custom version of your library, to change that part of the code so I can make it work for my sunnybeam ?
Thanks !

Hey there,

@dannerph
Thanks for the Integration.
I never thought that somebody would really implement this old hardware for homeassistant. My search was almost desperate and i couldn’t believe that somebody actually did it. Nevertheless, i did all the steps but i can’t make it work.

My Setup:
Proxmox installed on a Homeserver
I have a virtual machine on the proxmox for Home Assistant.

I passthrough the usb device with gui setting and by changing /etc/pve/qemuserver/xxx.conf

When i check for usb devices on the virtual machine itself, the device is found.
image

When i check the entities, it only says unknown though. I don’t think i have to set the udev rules cause i pass it through to the virtual machine ?

Is there any troubleshooting i can do ?

I’d really appreciate any help

Greetings Michael

Hi @Robin61,
sorry for answering late (you need to either tag me with @dannerph or open a github issue in the repository).

Which version of sunnybeam do you have? The bluetooth version? Whould be interesting to get to know, how the different models are working. Could you provide me more information of your USB sniffing (here or via private message) so that I can have look on it?

I recently accepted a pull-request fixing escaping of certain characters in CRC calculation, which was not a problem for my device thus I have not found this bug.

Hi @Hafenmeister
you could enable debug logging for the integration and the library by adding the following to your config yaml file:

logger:
  default: warning
  logs:
    sunnybeamtool.sunnybeamtool: debug
    custom_components.sunnybeam: debug

If you run home assistant in a docker container within the virtual machine, the udev rule is most likely required, as docker containers are usually unprivileged.

Thanks for the fast reply @dannerph,

My log looks like this and goes on like this forever:

2023-03-05 14:53:16.905 WARNING (MainThread) [custom_components.sunnybeam] New data could not be fetched, try again next time.
2023-03-05 14:53:16.906 DEBUG (MainThread) [custom_components.sunnybeam] Notifying all listeners
2023-03-05 14:53:16.906 DEBUG (MainThread) [custom_components.sunnybeam.sensor] received: 0
2023-03-05 14:53:16.906 DEBUG (MainThread) [custom_components.sunnybeam.sensor] received: 0
2023-03-05 14:53:16.906 DEBUG (MainThread) [custom_components.sunnybeam.sensor] received: 0
2023-03-05 14:53:26.907 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] Sent: 7eff0340410000000080000a000000002d2e7e
2023-03-05 14:53:27.481 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:27.553 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:27.626 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:27.698 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:27.770 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:27.770 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read processed: 
2023-03-05 14:53:27.770 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] Sent: 7eff0340410000ff0010000b0f090007ac7e
2023-03-05 14:53:28.346 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:28.419 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:28.491 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:28.563 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:28.635 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:28.707 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:28.780 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:28.852 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:28.924 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:28.996 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:29.068 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:29.140 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:29.213 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:29.285 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:29.357 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:29.429 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:29.502 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:29.574 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:29.647 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:29.720 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:29.792 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:29.864 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:29.937 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:30.009 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:30.081 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:30.154 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:30.226 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:30.298 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:30.371 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:30.443 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:30.516 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:30.589 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:30.661 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:30.734 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:30.806 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:30.878 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:30.952 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:31.025 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:31.098 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:31.170 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:31.243 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:31.315 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:31.387 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:31.460 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:31.532 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:31.604 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:31.677 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:31.750 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:31.822 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:31.895 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160
2023-03-05 14:53:31.895 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read processed: 
2023-03-05 14:53:31.895 WARNING (MainThread) [custom_components.sunnybeam] New data could not be fetched, try again next time.
2023-03-05 14:53:31.896 DEBUG (MainThread) [custom_components.sunnybeam] Notifying all listeners
2023-03-05 14:53:31.896 DEBUG (MainThread) [custom_components.sunnybeam.sensor] received: 0
2023-03-05 14:53:31.896 DEBUG (MainThread) [custom_components.sunnybeam.sensor] received: 0
2023-03-05 14:53:31.896 DEBUG (MainThread) [custom_components.sunnybeam.sensor] received: 0
2023-03-05 14:53:41.896 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] Sent: 7eff0340410000000080000a000000002d2e7e
2023-03-05 14:53:42.471 DEBUG (MainThread) [sunnybeamtool.sunnybeamtool] raw_read: 0160

Hi @Hafenmeister,
have you tried to run the underlying python (GitHub - dannerph/SunnyBeamToolPython: Python port of SunnyBeamTool) or C (GitHub - SBFspot/SunnyBeamTool: Get solar data out of your SunnyBeam) library from your computer, in order to check in a first place, if your device is compatible?
If yes, which libusb version do you have in your setup? I remember that I was not able to get it working on my Synology NAS because of an outdated version of libusb. From within the docker container of Home Assistant core, it is working.
If above steps are find, I would start investigating, why your proxmox setting is not forwarding data to libusb.

Hi Thanks a lot fpr providing such a solution. Unfortunately I cannot get this working. I have the HA running in a docker on a synology NAS with a Conbee II Zigbee stick. I followed the instructions in the readme file copy the files to custom_components, restart HA, plugged in the Sunnybeam restart HA and edit the config yaml file. After editing the yaml file the check was not good - Integration Sunnybeam not found. I also added the 99-SMA rule to lib/udev/rules.d. After replugging the sunny beam no success and also the conbee was not working anymore. The Sunnybeam is shown at the NAS Info/USB devices with full name so seam to be working. After removing the rule and reboot of the NAS the HA and conbee worked fine. Do anybody have an idea how get this working? Thanks in advance.

Hi @mbbs1024 @kefjevl
I have a installation from 2009 with SMA inverter Sunny boy 3000TL

I never used the Bluetooth as I was not aware that I could use without a Sunny beam. In the beginning I was taking note manual about the production…after some time not any more.
Recently I came across a program from SMA, Sunny explorer, and tried to make connection with Bluetooth via laptop. And it worked…!!! It was able to download all the data from the past.
This triggered the idea to get this data in HA via Bluetooth…

Did you have some info on that?

Hello All,
I found this thread a few days ago. I also have a Sunny Beam and want to connect my SMA inverter SB3300 (year 2008 version) to HA. I have not tried implementing the Sunny Beam yet because the place where my RPi4 with HA is placed is a very bad place for the Sunny Beam regarding reception of the inverter signal. Maybe there are smarter people than me that can convert the Sunny Beam to a network device (ESP32, Tasmota regarding MQTT facilities?) which has wifi access to the home network? If this is possible, the Sunny Beam can be placed at every place where wifi and the SM3300 inverter signal are in sight of the Sunny Beam and as a bonus it could be powered via the 5V PSU of the coupled device (fed in the USB port, batteries removed) while a sunny place is not mandatory anymore. I’m not a software guy but can hold a soldering station… . I hope someone can help me and others with a solution like this?

Hello, sorry for my very late reply as well :smiley:

I have a Sunnybeam radio version, not the bluetooth one. I don’t have the data packets anymore unfortunately.
It has been working for the last 18 months, even if it is not 100% stable.
For example, if there is small electricity instability (like if I turn on an electric heater on the same outlet as my machine running HA), it will stop being able to fetch new data from usb unless I reboot the computer.
Quite weird.

I just built a small rest service that provides me the data, so I can externalise data extraction from my HA machine.

@Hafenmeister it looks like the same issue as I had. Maybe try to change the hardcoded bytes from 7EFF03404100000000900002 to 7EFF03404100000000900003