Buderus/Bosch/Sieger EMS bus component - using the host's serial

This project is about connecting to the Buderus / Bosch / Sieger / Netfix EMS bus and monitoring/controlling your heating unit with it.

It features reading many many values from the boiler and attached devices and also changing values on them like setting heating temperature and drink water heating or changing settings on the thermostat.

It uses the native serial port of a RPi for example for communicating to the bus. And this is where it differs from the great project from Proddy (Thermostat and Boiler controller for EMS based boilers (Nefit, Buderus, Bosch) using ESP).

The serial bus interface part is written in C, transmitting and receiving messages through a Posix message queue.
The higher protocol (messages, fields and units) are implemented in a Python library.

It initially started as a little project after detecting the EMS bus on my heating unit, purchasing an interface unit from BBQKees, and experimenting with the bus.
But it now ended up in a full blown protocol stack that could also be used outside of Home Assistant.
The messages and the fields within are written as Python classes. I took the idea from Django, I was working with in a project.
Proddy, if you’re reading this - I did not mean compete with your project.

The Home Assistant code adds the devices as sensors, input_numbers, input_selects and switches.

It can be found at https://github.com/CreaValix/ems_bus


Great project!

I’ve added a link in my EMS Wiki repository

1 Like

This is really nice work Alexander and great that your open-sourced it for everyone. Your approach to reading the EMS bus using the serial port is well thought out, plus using an async posix message queue for both Rx and Tx is clever. They were the toughest part of my project using an single-threaded ESP8266 with a single UART, 4MB flash and only 50K of available RAM

1 Like

Hello proddy and bbqkees,
thank you both!
I totally understand you, Paul, with the difficulties you’ve had reading the bus. At first, I implemented it all in Python. It worked, until I added it into Home Assistant. It was running in it’s own asyncio worker (a separate thread) and writing the messages to a asyncio queue, but the delay was too high. I didn’t investigate, but maybe Python and asyncio have too many semaphores that block the code too much. I still have the Python code, if someone needs it.

I quickly decided to write the “OSI Data Link Layer” in C in a separate thread.
First idea was to write to a Python Queue from C, but I wanted to have this part now independent of Python. So I came up with the POSIX queues. The UART (termios) stuff is POSIX anyway, and the message queues are even supported under BSD (including MacOS), Solaris and Windows using Cygwin. So, in theory, it could be used from a standard MAC or Windows desktop, a serial port assumed.
I almost saw the termios man page also in my dreams…

The heater is actually at my parent’s place, next time I visit them I’ll check the delays with a logic analyzer. Especially the writing part is a little bit different from proddy, my code writes a single byte and immediately reads and compares the master’s echo. The ESP project writes the whole packet, and compares the whole packet later.
But hey - it works!

When I have time (currently not), I have some further improvements in the github list.
And I want to use the climate component of HA. I’ll check out Proddy’s code how he matched the HVAC modes.