SBMS and Home Assistant integration.

814 views
Skip to first unread message

Jarno Orasmäe

unread,
Jan 26, 2022, 7:03:32 AM1/26/22
to electrodacus
Hi to all.

I use Home Assistant for my smarthome stuff and I would like to connect my SBMS to it. It probably can achived multiple ways(UART, wifi, bluetooth, mqtt) but what I'm thinking is using ESPHome software for the ESP32. Right now we have Robert's firmware with MQTT support, but ESPHome would be better and simpler for Home Assistant. ESPHome supports Daly BMS, it uses UART to get  info from BMS. It's similar how our SBMS works (correct me if I'm wrong). Maybe we could modify the Daly ESPHome code and make it work with our SBMS. Daly BMS uses it's own communication protocol but the main difficulty would get our protocol implemented and make the variables and sensors work.

I think it would be simpler than writing it from scratch.
Or what you think, an we achive this?


Jarno Orasmäe

unread,
Jan 27, 2022, 5:54:25 PM1/27/22
to electrodacus

Hi,

I made a github repo, and started work. I have building envoirment up and running. Soon I'll try to flash simple ESPHome firmware(clean ESPHome without sensors and UART listening part) to my SBMS120.

Dacian Todea

unread,
Jan 27, 2022, 6:47:53 PM1/27/22
to electrodacus
Jarno,

I have not looked in to Home Assistant or anything similar.  I'm basically always at home so I do not need to monitor my home from outside.
If ESPHome is open so that you can add the UART data it should work fine. I think there are still closed source code parts on the ESP32 so it will never be something you can make sure is doing what you want.
I guess you need a computing device ruining home assistant and the ESPHome will be just one of the sensors.  Not sure I get the usefulness of Home Assistant as it looks more like a universal remote control.


David Burton

unread,
Jan 27, 2022, 8:01:50 PM1/27/22
to electrodacus
Hey Jason,
That looks like a great project.  Just sharing as I'm using SBMS0, InfluxDB, Grafana, and Home Assistant with Node Red.  It was one step at a time for me as I first wanted SBMS historic data, this was done with python and the serial bus as I didn't want to rely on wifi for the data capture.  Then I was able to do all sorts with the data in Grafana and Home Assistant can pull data from Influx easily.  This now allows me to react to solar/battery status or events, like dim my lights when I hit 50% or whatever.  I also send push notifications through HA for temperature issues (battieres aren't indoors yet as I'm still building my house).  Anyway, lots more automation coming once my house is done this spring.  https://familyburton.com/solar-battery-testing-with-electrodacus-part-2, all my code is out on GitHub.

Jarno Orasmäe

unread,
Jan 29, 2022, 2:52:21 PM1/29/22
to electrodacus
Hi,

I run Home Assistant on an old laptop. I have some temp and humidity sensors in my flat and some lamps what it controls. Not much just an hobby. What it's good at is data collection and automations. Like I fetch electricity price from Nordpool(pan-European power exchange) and it gives me nice 48h graph of electricity prices and then I know when it's cheaper to use. Soon I add an smartswitch to my water heater, so it can heat more when the electricity is cheapest.
And It can do so much more, what ever is the case.

But yeah, ESPHome is a platform of building sensors, and it's super easy to use with Home Assistant.

Jarno Orasmäe

unread,
Jan 29, 2022, 2:55:52 PM1/29/22
to electrodacus
Hi David,

Your approach is nice, I like it :) If I can't make the ESPHome work then I'll use Influx and Grafana over usb uart. Nice :)

Jarno Orasmäe

unread,
Jan 29, 2022, 3:06:38 PM1/29/22
to electrodacus
Hi,

Today I flash ESPHome to my SBMS120. And it went well.
I added UART text senor also and I saw some info what it received. At least it's a start :)

IMG_18182.jpg

Nicky Ivy

unread,
Jan 30, 2022, 4:12:26 PM1/30/22
to electrodacus
I have been using my SMBS0 with ESPhome/Home Assistant for a while, was just about to to share my work now that it's been running smoothly for a few months, was going to make a new thread but saw yours so I'll just post here.

Some interesting things I had to deal with. Maybe I do not have the best ways to deal with them...but in the end they worked.
  • With the normal SBMS software, the STM32 controls the ESP more, but over the same UART that the data travels over. So the data gets interrupted by these commands, and with the compression scheme it's hard to tell what is actual data and what is ESP command. It must be possible since the normal ESP code can do it, but I had a STLink and the original SBMS software so I figured it was easier to just make a modified version of the STM32 software that does not send these ESP control commands, since ESPhome is more autonomous. I've attached this zip. 
  • With the compression, a certain value ends up as a backslash over UART, which ESPhome seems to insert a second backslash into the buffer, which throws off all the careful character spacing in the compressed data. So in the decompression function I keep track of the number of these backslashes and have an offset.
  • Since the readings from the SBMS can be a bit noisy, I added filters to many of the data channels.
I've attached my files. A lot of my commented out debugging stuff is still in there, hopefully it's not too much of a mess...
Here is the stm code: https://drive.google.com/file/d/1ryfDRpLAClOwHVSxlo2vpCrYtNXYHoT2/view?usp=sharing
solar-uart.h
sbms.yaml

Jarno Orasmäe

unread,
Jan 31, 2022, 3:45:27 PM1/31/22
to electrodacus

Hi

Thanks for your post :) I'll test your code now. I flashed ESPHome part first and when it boots it goes online for a bit but then it goes offline, probably stm32 firmware crashes  it. Now I'll try to flash stm32 with your modified code. 

Nice to that I'm not only one to use ESPHome with SBMS :)

Thanks again :)

Jarno Orasmäe

unread,
Jan 31, 2022, 5:01:53 PM1/31/22
to electrodacus
Hi, Nicky

I compiled the modified sbms firmware and now ESPHome stays up  and seams to work nicely :) I don't have the sbms installed so I do not see real data from all sensors but all seams to be good. Only changed I made was varible SBMSmodel to 120, becouse after first flashing SBMS120 reported that it was SBMS0. 
Thanks again :)
Reply all
Reply to author
Forward
0 new messages