Anyone know howto read SMA Sunny Beam data into HA?

Hi,

I have an SMA solar inverter, that outputs production data to a little device called Sunny beam.

You can connect it to a PC via a USB, and read solar production data via an SMA software for windows.

Can this device be connected to HA in order to monitor and make automations based on solar production ?

Would like to know this myself… or maybe existing workarounds…

There are basically two different types of these Sunny Beam devices with either Bluetooth or 868 MHz connection. If you have bluetooth, you could try SBFSpot to MQTT

If your device uses a 868 MHz connection, like mine, there is a command line tool, written in C, that can fetch relevant data via USB.

I am currently working on adding a MQTT bridge for that.

1 Like

How do you tell the difference between the 2 types ?
Mine says it is version D with serial nr 14365

When I switch on Bluetooth scanning on my laptop, it only sees my TV, so I guess it will be a 868 MHz version.

I have seen some pictures with a Bluetooth symbol on the front of the Sunny Beam, there is also a brochure showing the difference. I also figured it out with not finding the inverters via Bluetooth scan.

Thanks for your post, I tried the sunnybeamtool, it works when I connect the sunnybeam to my laptop, now how to get this in HA ?

Can you post something here if you finished your MQTT bridge ?

$ ./sunnybeamtool -l
Dev #3: 1587 - 002D -SMA Technologie AG - 
Serial Number: 00014365
pac: 93.00 W
e-today: 4.83 kWh
e-total: 32791.53 kWh
resu=845

today:
2021-05-15 05:00:00:      0 W
2021-05-15 05:10:00:      0 W
2021-05-15 05:20:00:      0 W
2021-05-15 05:30:00:      0 W
2021-05-15 05:40:00:      3 W
2021-05-15 05:50:00:     86 W
...
2021-05-15 15:30:00:   1347 W
2021-05-15 15:40:00:   1088 W
2021-05-15 15:50:00:    985 W
2021-05-15 16:00:00:    709 W
2021-05-15 16:10:00:    364 W
2021-05-15 16:20:00:      5 W
2021-05-15 16:30:00:      4 W

last month:
2021-04-14:    7.920 kWh
2021-04-15:    8.020 kWh
2021-04-16:   10.730 kWh
2021-04-17:   14.600 kWh
...
2021-05-14:    7.750 kWh

I will push updates here, once I have something up and running. I decided to port the sunnybeamtool from C to python so that it can be used directly as custom integration. ~20% done.

Fantastic, thx

Hi all,
I created a custom component that fetches the data from the Sunny Beam device via USB. Feel free to test it and give me feedback. In order to get it working, you need to add a udev rule on your host so that non-root users can access the device (details in the readme file). In case you run Home Assistant in docker you also need to allow access of the docker container to the device.

Hi, I would like to test your custom component.

When I ssh into home assistant, there is no /etc/udev directory, I’ll look further tomorrow and connect a keyboard and a monitor directly to the device.
Probably ssh does not connect me directly into the underlying OS.

My HA runs on an O-droid XU4, and to install it, I used the SD card disk image from the HA download site. Is HA also running in a docker file ?
If so, can you tell me howto allow access of the docker container to the device, and add this to the installation instructions in the read.me file on your Github page ?

Have you tried the custom component without the udev rule first? If it is not working, could you send me the error log?
It might be that the home assistant OS is already taking care of all that stuff. (I cannot test it as I run my HA in docker on my Synology NAS).

If I understood it correctly there are two modes for ssh: one using the addon including web console to enter the home assistant core docker container and one (you first need to put your ssh key on a prepared USB Stick for integration) on the host system.

Hi, thx for your development effort, it works :smiley:

It creates 3 sensors

sensor.sunnybeam_energy_today 7.83 unit_of_measurement: kWh friendly_name: sunnybeam_Energy_today icon: mdi:gauge
sensor.sunnybeam_energy_total 32871.09 unit_of_measurement: kWh friendly_name: sunnybeam_Energy_total icon: mdi:gauge
sensor.sunnybeam_power 0.744 unit_of_measurement: kW friendly_name: sunnybeam_Power icon: mdi:flash

Here is what I did to get it working, it gives some extra info for people that are not so familiar with the linux command line:
Please add some extra comments if there is an easier way to do the same thing.

  • Download and unzip the code from github

  • copy the sunnybeam directory to the HA config/custom_components directory

  • Put the sunnybeam configuration into your configuration.yaml file
    sunnybeam:
    scan_interval: 10

  • Add the udev rule

To add the udev rule that allows non root users, you really need to be an the OS of the device that runs Home Assistant, and to be able to access that, I needed to connect a keyboard and a screen to my raspberry.
You cannot get there if you use the HA Terminal & SSH addon, because that will bring you to the command line of the HA docker container.

Login as root on the HA raspberry pi (by default there is no password)
Then type login, this will bring you to the linux command line.
Then issue following commands
Don’t type things behind the # sign, it is a comment I add to explain what the command does.

cd /etc/udev/rules.d             #  goto the directory where you need to create the rule
touch 99-sma-sunny-beam.rules    # this creates the rule file
vi 99-sma-sunny-beam.rules       # open the file with the vi text editor
i                                # Type i to put the editor in insert mode
SUBSYSTEMS=="usb", ATTRS{idVendor}=="1587", ATTRS{idProduct}=="002d", MODE="666"    # type the rule
push the escape key, followed by :wq   # to save the file and exit the text editor

  • Connect the sunnybeam

  • Reboot Home Assistant

1 Like

Every few days HA stops reading data from Sunnybeam.

Disconnecting and reconnecting the sunnybeam does not help, a HA reboot fixes it for a few days.
Any ideas on how to solve this ?

I find this in the HA log

Traceback (most recent call last):
File "/config/custom_components/sunnybeam/__init__.py", line 73, in update
self._data = await self._s_beam.get_measurements()
File "/usr/local/lib/python3.8/site-packages/sunnybeamtool/sunnybeamtool.py", line 47, in get_measurements
if not self.__connected or not await self.__do_syn_online():
File "/usr/local/lib/python3.8/site-packages/sunnybeamtool/sunnybeamtool.py", line 250, in __do_syn_online
resu = await self.__send_raw_message(cmd_syn_online, False)
File "/usr/local/lib/python3.8/site-packages/sunnybeamtool/sunnybeamtool.py", line 164, in __send_raw_message
return self.__dev.write(endpoint=0x02, data=msg, timeout=1000)
File "/usr/local/lib/python3.8/site-packages/usb/core.py", line 979, in write
return fn(
File "/usr/local/lib/python3.8/site-packages/usb/backend/libusb1.py", line 837, in bulk_write
return self.__write(self.lib.libusb_bulk_transfer,
File "/usr/local/lib/python3.8/site-packages/usb/backend/libusb1.py", line 938, in __write
_check(retval)
File "/usr/local/lib/python3.8/site-packages/usb/backend/libusb1.py", line 604, in _check
raise USBError(_strerror(ret), ret, _libusb_errno[ret])
usb.core.USBError: [Errno 19] No such device (it may have been disconnected)