Chapter 1: Getting Started
I recently set out to create a smart heating controller for my Terma MOA Blue heaters using Python, Docker, and Bluetooth Low Energy (BLE).
There’s currently no native way to communicate between Home Assistant (HA) and my heaters.
I needed precise control over the heaters for my seasonal rental property to:
This post is the first chapter in a series where I’ll walk you through the process—from setting up the Raspberry Pi and Docker to writing Python scripts for direct Bluetooth control.
The Terma MOA Blue is a Bluetooth-enabled heating element designed for electric radiators and towel warmers.
Key features:
While these heaters work seamlessly with the manufacturer’s mobile app, I wanted more flexibility by integrating them directly into a custom Python/Docker setup.
I want to give a big shoutout to the Home Assistant Community for laying the groundwork and sharing insights about connecting to these heaters using BLE.
Their discussions helped clarify how the Bluetooth characteristics are structured and inspired many of the techniques implemented in this project.
We'll cover:
I decided to use a Raspberry Pi as the central controller for this project. Here's how I set it up:
sudo apt update sudo apt install -y docker.io sudo usermod -aG docker $USER
docker --version docker run hello-world
This verifies Docker is installed and running properly.
To simplify updates to the code, I set up SSH keys and Git for remote access from my PC.
ssh-keygen -t ed25519 -C "your_email@example.com"
git clone git@github.com:<username>/<repo>.git
You can check out the full source code in my GitHub repo:
? GitHub - ha-hudsonread-heater-control
Feel free to fork it, suggest improvements, or report any issues!
The Terma MOA Blue heater communicates over Bluetooth Low Energy (BLE), so I used the Bleak library in Python to handle the connection.
Key features implemented so far:
Right now, the controller can:
Stay tuned for Chapter 2, where I’ll dive into the Python code, explain how BLE encoding and decoding works, and share insights from debugging Bluetooth connections.
We’ll also cover manual pairing and connection commands using bluetoothctl for anyone interested in a deeper look into BLE debugging.
Don’t forget to ⭐️ the GitHub repo and let me know in the comments what features you'd like to see added next!
The above is the detailed content of Building a Smart Heater Controller with Python, Docker, and Bluetooth #1. For more information, please follow other related articles on the PHP Chinese website!