This project uses podman instead of docker. First of all, due to recent docker licensing. Second, podman uses the same command set and is fully compatible with docker, while at the same time deamon-less, eliminating some single point of failures and daemon issues.
Install Podman
Here is a link to the installation of podman on various platforms : https://podman.io/getting-started/installation I use Ubuntu for the project.
Homegear docker image using podman
Homegear user
Create a home directory /home/homegear Create a group for homegear – in my case I use the group named „openhab“ because I also use OpenHAB. Create a user „homegear“ for homegear with the group and home above, set password Add homegear user to additional groups : tty, dialout, docker
Homegear Docker image
Get homegear docker image, create container and run it.
This article is about how to setup an homegear server for controlling Homematic wired homeautomation components, replacing or complementing a CCU2/3.
Results and conclusions first …
After running homegear with an non docker direct installation on Ubuntu for several years with good experience, but having sometimes a hard time with updates, I thought I do it differntly next.
I thought about using SuSE MicroOS for improving updates and stability. Using Docker and the homegear docker image, to improve homegear updates as well, ease the installation and make it more flexible.
In the end, I managed to install it, and basically it works fine, updates going smoothly, automatic and snapshots and rollebacks on MicroOS are low maintenance.
HOWEVER …. Using this setup, the MicroSD card inside the Raspberry Pi seems to be pretty stressed, and I got corrupted filesystems after 3-6 months now using my 3rd sd card, that just died again. I mean, that was outlined already on the Web by several people, that this could be an issue, because the sd cards are not suitable for this type of workload. But I didn’t think it was THAT bad …
To fix the issue, I would have to add some sort of a USB3 ssd, hdd or M2/USB drive. But this requires again some additional power, cost and space.
Therefore I decided to go another way, using a LAN RS485 gateway from Homematic instead, and moving homegear to my home server that also runs Openhab. In addition, I added a Raspi based RaspberryMATIC installation as a CCU equivalent, but I will add my experience with that to another blog article here that follows soon.
Anyway, this was a nice project, with quite a few challenges and plenty of learnings. Maybe the experience is helpful still for one or the other.
Let me know your feedback !
Here’s the story ….
Overview
The Hardware
Raspberry Pi 3 b+
LiIO Battery backup unit shield
RS485 module
DC/DC converter for a wide input power range
Housing and mounting equipment
Software
OpenSuse MicroOS Kubic based on Tumbleweed
Docker
Homegear Docker image
libgpio2
libgpio-tools
python3-gpiod
Prepare Hardware
Install BBU shield
Instll Raspi 3 + BBU shield in housing
Add RS485 module
Add DC/DC converter
OS installation : OpenSuSE MicroOS Kubic based on Tumbleweed
OpenSuSE MicroOS Kubic
This distribution is pretty new, based on Tumbleweed and should fit perfect for Edge devices, like the Homegear RasPi server. The Kubic distribution includes a minimum OS and kubeadm, so it should be perfectly suited for running any container deployments on the Edge.
I actually expect to reduce the effort for maintaining and updating this edge server, and I hope many of the maintainance tasks run smoother and are less time consuming.
However, since this is pretty new, time and experience in the next months will tell, if my expectations are satisfied.
Download the required Version from Kubic Portal Copy to a suitable MicroSD card, using the procedures outlined on the linked site.
Create USB stick with combustion/ignititon –> combustion script used
Get a USB stick, make sure it has sufficient space, a supported Filesystem (I used vfat but e.g. ext4 also works) and the filesystem has a label named „combustion“
The important part is the added „iomem=relaxed“ and notice that we removed ttyS0 as serial console, which is also important to avoid later issues with the serial UART.
On Kubic, you need to call transactional update for the kernel command line changes to apply :
transactional-update grub.cfg
Note : If you do multiple updates and changes at once, you might need the option –continue
Raspi 3 b+ GPIO pins and UART / serial devices
Raspberry Pi 3 b+ has 2 serial devices. There is a PL011 and a mini UART. The later has only reduced capabilities. Unfortunately, compared to the Raspi 2, these 2 devices are switched primary / secondary. Furthermore, Blootooth is by default occuppying the PL011 UART, which is another cause of issues. In some cases, by default, only the mini UART is available on GPIO Pins 8 and 10. The mini UART does not work properly for the RS485 module. Therefore, the GPIO settings have to be changed so that the PL011 UART uses the GPIO pins and the best is to disable BT.
I have not found a similar tool to manage device alternate functions. Since I did not find that tool as a rpm package, I had to compile the latest revision from sources.
If you do opt out to install this tool, it will make it more difficult to troubleshoot any GPIO / UART related issues.
Dependencies : git, make, automake, gcc, …
cd #Change to Root Home
git clone https://github.com/RPi-Distro/raspi-gpio
cd raspi-gpio
./configure #fails if you did not change the kernel parameters above
make
#make install #installed binary manual in /usr/local/bin
mv raspi-gpio /usr/local/bin
#Remove raspi-gpio source and build files for cleanup
Normally, on a Raspi 3, the serial0 is on GPIOs 32 and 33 while serial1 is on GPIOs 14 and 15.
raspi-gpio get #check the output for GPIO 32,33,14 and 15
Here is the compiled file for convenience, might not run on your version and you might need to compile it yourself, using the above procedure.
Modify RasPi configuration for GPIOs,UARTs and Serial devices
Set as needed for our homegear setup.
Change the UART usage in config.txt
Modifications to config.txt are required to fix the UART configuration for homegear.
On OpenSuSE MicroOS it is recommended to use extraconfig.txt for any custom changes to be save for updates.
transactional-update shell
vi /boot/vc/extraconfig.txt
Edit the extraconfig.txt file (should be empty normally) and add the following lines :
#Make sure UART is enable
enable_uart=1
[pi3]
# Use miniUART for BT/WiFi and free the UART for RS485 module
#dtoverlay=pi3-miniuart-bt
dtoverlay=disable-bt
[all]
dtparam=spi=on
dtparam=i2c_arm=on
Remark : I had issues with using „pi3-miniuart-bt“, which occationally worked, providing ttyAMA1 (!!) as devicefile for the PL011 UART. However, suddenly this stopped working and I had no ttyAMA* at all anymore. The ttyAMA1 disapeared suddenly at a reboot after an update. A rollback did not bring it back, so I have no idea what caused this. Maybe some Raspi Firmware update that can not be rolled back with transactional-update. The only way making this consistently work, was using „disable-bt“, which is not a big issue, because BlueTooth shouldn’t be used used anyway. Disabling BT brings back the PL011 UART, but now as ttyAMA0, which I am using further in this article.
Exit the transactional update shell and complete the changes with a reboot
exit
Please reboot your machine to activate the changes and avoid data loss.
New default snapshot is #13 (/.snapshots/13/snapshot).
transactional-update finished
reboot
Set the DE/RE pins for the RS485 module
raspi-gpio set 5 op pn dh
raspi-gpio set 6 op pn dl
Create a home directory /srv/homegear Create a group for homegear Create a user „homegear“ for homegear with the group and home above, set password Add homegear user to additional groups : tty, dialout, docker
Configure systemd docker service
Change the timeout for the docker service, because startup might take some time.
transactional-update run vi /usr/lib/systemd/system/docker.service
Add the following timeout to the [Service] section.
TimeoutSec=900
Docker image
Get homegear docker image, create container and run it.
Modify /srv/homegear/homegear-data/etc/homegear-start.sh … add the lines for adding tty group for tty permissions for homegear … add the lines for modifying gpio ports
Code of homegear-start.sh.sh with modifications, remember the directory mappings : /srv/homegear/homegear-data/etc:/etc/homegear – so, raspi-gpio is to be found there !
#!/bin/bash
# This script is executed before Homegear starts.
#Add group tty to homegear user, to access tty device
usermod -G tty,dialout homegear
#Modify GPIO settings to use proper tty on RasPi3
#Set the GPIOs 32 and 33 as Input and remove the serial functionality
/etc/homegear/raspi-gpio set 32 ip pn
/etc/homegear/raspi-gpio set 33 ip pn
#Change GPIO 14 and 15 from serial1 to serial0 (to use advanced PL011)
/etc/homegear/raspi-gpio set 14 a0 pn
/etc/homegear/raspi-gpio set 15 a0 pn
# Set permissions on interfaces and directories, export GPIOs.
/usr/bin/homegear -u homegear -g homegear -p /var/run/homegear/homegear.pid -pre
Restart docker image
docker restart homegear
Connect to homegear and search actors
docker exec -i homegear homegear -r
Use homegear interactive commands to search for actors and configure homegear. Enter „help“ for help.
See homegear documentation in the links table at the top of this article.