openHAB co-existing with Asterisk & FreePBX on Raspberry Pi 3B

First post though I’ve been looking at openHAB on an off for some time. It really has come on leaps and bounds, so all credit to those involved.

I’m currently running Asterisk & FreePBX on Raspberry Pi Zero and now thinking of moving it to Raspberry Pi 3B along with openHAB. I think it is best to start with the openHABian and then add the Asterisk & FreePBX importing the config files, plus Mosquito MQTT broker and maybe NodeRED.

Can anyone confirm please if these happily co-exist on the same Rasp Pi? What things do I need to watch out for; for example, would port numbers have to be changed (FreePBX is a web browser interface to Asterisk and uses numerous ports and NodeRED has a browser interface)?

Many thanks

My first impression is that is an awful lot for a machine with only 1GB of RAM. OpenHAB could easily use half that. You might be better off with a 2 GB Pi 4.

Thanks Bruce. The existing Pi Zero has 512MB and according to FreePBX 40% is being used for the app and buffers with the rest taken as cache. So having both might well limit the cache available (I presume openHAB likes/wants some cache).

If I didn’t have a surplus Pi 3B then I would easily pay the extra for a Pi 4 2BG (£44+p&p).


1 Like

Is there any reason you could not leave Free PBX on the Pi Zero abd setup OPenHAB on the Pi3B? I understand using surplus equipment. My current system in on a Pi 3B+ using a surplus laptop SSD and an inexpensive USB case.
In my instance, again because of available equipment, I am migrating to a Debian Hyper-V VM with a better Z-Wave controller obtained for free.

Ah, I thought that might be suggested. I do have other plans for the Zero and need more than one and when I last bought a zero I found them in short supply. Another reason is 2 Pis need 2 PSU bricks and I’m short of sockets and space even with multi-socket extension gang. (I have about 10 items plugged in). And a third reason is that it’s another system to maintain.

Valid question though Bruce.

PS Good to see you are using an SSD - I bought one for my PC but am disappointed (I bought SATA link and should have bought PCIe). So I was thinking of using the SSD on the Pi. Alternatively an ex laptop HD. As the Pi 3B is only USB2 looks like I would need an expansion board like the X820 with a 5V/4A supply to drive the Pi, the expansion board and the SSD/HD. What did you use?


I have an Intel SSD and bought this case

I used the 2.5A power supply that came in my Pi kit. This would be the one.

1 Like

Well I took Bruce’s advice and bought a Pi 4 but thought in for a penny in for a £, so went for 4GB (extra £10), PSU, USB HD adapter, SHIM Fan, Header boost and another Pi Zero with p&p came to £87 (Pimoroni) - don’t tell my other half :wink:

Then I found the old 2.5" hard disk is IDE :frowning: so bought a new 500GB SATA HD for £15 of the bay but I shall use a 240GB SSD in the Pi and the 500GB in the desktop.

With 4MB and logs in memory and no cache it should limit the read/writes to the SSD.

I’ve now read about Docker (Youtube, Andreas Spiess, the guy with the Swiss accent) so could run openHAB, Asterisk/FreePBX and Mosquitto in separate containers. Seems useful but downside is more initial complexity, muddies resolving of issues and both the pre-built openHAB and Asterisk/FreePBX are not official releases and so reliant on quality of the amateur builds.

Any thoughts on using Docker or should I go for the original plan of Rasbian+openHAB image and then install Asterisk/FreePBx. This will be a challenge for me as well as previously I used a Rasbian+Asterisk/FreePBx image.


IO know @rlkoshakwould recommend Docker and I think that may be wise on a Pi 4.

openHAB maybe Docker friendly but this post says it’s near impossible to run Asterisk/FreePBX in a Docker container. I now also recall that installing Asterisk from scratch is for experts only and others are recommended to use the images. So that would mean Rasbian+Asterisk/FreePBX image followed by openHAB install.

The reference above suggests virtualisation using LXC is an alternative and better solution. Each container then gets its own IP address. I’ll look at that next. It LXC seems viable it’s a good job I bought the 4GB PI4 !

Or you could still run OpenHAB in a Docker container to keep it somewhat isolated from the other applications.

Thought I would bring this uptodate with my experience.

I installed the Rasbian+Asterisk/FreePBX image from RasPBX images based on Raspbian 10 Buster and this went well. I started FreePBX OK but have yet to configure it and run it for real.

I then followed this guide Installing Docker and Docker Compose on the Raspberry Pi in 5 Simple Steps changing python and python-pip to version 3 mixing it with this extra steps in this guide Happy Pi Day with Docker and Raspberry Pi. but ignoring the swarm section. All went well.

Next I installed Portainer just the Quick Start section - 2 lines! Portainer is a web based front end to Docker.

Next I tried to install openHAB but ran out of space. I didn’t realise the Raspbian+Asterisk+FreePBX image is 4GB so it only filled 25% of my micro SD card. Anyway I had planned to utilise a 230GB SSD drive so followed this How to Run Raspberry Pi 4 or 3 Off an SSD or Flash Drive splitting the drive into 3 thirds circa 75GB each.

Next I installed openHAB following this guide It’s a bit dated and I stopped before " Create the openHAB conf, userdata, and addon directories" as I was unsure where to create them.

I found that Portainer had created a folder in var/lib/docker/volumes/ so I created a folder openhab_data as well and modified the docker run command -v lines to read:

        -v /var/lib/docker/volumes/openhab_data/openhab_addons:/openhab/addons \
        -v /var/lib/docker/volumes/openhab_data/openhab_conf:/openhab/conf \
        -v /var/lib/docker/volumes/openhab_data/openhab_userdata:/openhab/userdata \

I ran this command and created a openhab container that was listed in Portainer (after reloading the page).

I then followed OpenHAB Docker Containers from section “Running from compose-file.yml” part 2 “for use with Docker Volumes” and created a compose file “openhab-compose-file.yml” in my openhab_data folder

version: '2.2'

    image: "openhab/openhab:2.4.0"
    restart: always
    network_mode: host
      - "/etc/localtime:/etc/localtime:ro"
      - "/etc/timezone:/etc/timezone:ro"
      - "/var/lib/docker/volumes/openhab_data/openhab_addons:/openhab/addons"
      - "/var/lib/docker/volumes/openhab_data/openhab_conf:/openhab/conf"
      - "/var/lib/docker/volumes/openhab_data/openhab_userdata:/openhab/userdata"
      OPENHAB_HTTP_PORT: "8080"
      OPENHAB_HTTPS_PORT: "8443"
      EXTRA_JAVA_OPTS: "-Duser.timezone=Europe/London"

    driver: local
    driver: local
    driver: local

In Portainer I removed the openhab container and then ran this compose script with “docker-compose -f openhab-compose-file.yml up -d”

Only problem is that this creates a container called “openhab_data_openhab_1” which is a bit messy. Still trying to figure out why the run command creates a container named “openhab” but the compose script creates a container named “openhab_data_openhab_1”

Help appreciated.

Docker is definitely the way to go. Haven’t tried Asterisk in it, but I never did do anything with it since I last tried it (still haven’t gotten voip service).

Openhab definitely has official container builds, for all of the release levels too. Stable, milestone, and snapshot.

You need to set the name in your docker compose file. It may be helpful to read through the compose file documentation.

Docker is definitely the way to go. Haven’t tried Asterisk in it, but I never did do anything with it since I last tried it (still haven’t gotten voip service).

I’ve not got VOIP either. I’m using it to filter PSTN calls (linked to Obi110) and to record voice mail which are then forward to my mobile as email. I hope to announce over a speaker who is calling so my wife can pick up her own calls!

You need to set the name in your docker compose file. It may be helpful to read through the compose file documentation.

Just found how to name it:

    container_name: "openhab"

Though when I reran the compose file the Portainer crashed and I had to rebuild it.

Next step is to install Mosquito in a container

That’s odd that it crashed. Maybe because of a name conflict since you already had one called openhab?
I don’t actually use portainer, but I think I might start.

Mosquitto has a container, I’m using that too. Just on my phone now, but it might be done by the Linux Server group.

Also, how slow is all of that running? I quickly moved openhab off the Pi I started with because it was way too slow even when it was the only thing running.

More progress. Installed Mosquitto. Could not see a compose script at the Mosquitto site so found this posting HoTo mqtt with docker 2nd posting by 123 Taras - Example 4. I then heavily modified it.

Created folder /var/lib/docker/volumes/mosquitto_data and moved to it and within folder created: nano mosquitto-compose-file.yml

version: '2.2'

    image: "arm32v6/eclipse-mosquitto:1.6"
    container_name: "mosquitto"
    restart: always
      - 1883:1883
      - 9001:9001
      - "/etc/localtime:/etc/localtime:ro"
      - "/etc/timezone:/etc/timezone:ro"
      - /var/lib/docker/volumes/mosquitto_data/data:/mosquitto/data
      - /var/lib/docker/volumes/mosquitto_data/config:/mosquitto/config
      - /var/lib/docker/volumes/mosquitto_data/log:/mosquitto/log
    network_mode: "host"
      - TZ=Europe/London

This started but was none responsive. A docker ps showed it was continuously restarting. Solution was an empty file mosquitto.conf in the config sub-folder. Now running.

Tested first by running in Putty window: docker exec -it mosquitto mosquitto_sub -d -t exampleTopic

Then opened another Putty windows and ran: docker exec -it mosquitto mosquitto_pub -d -t exampleTopic -m “Hello world!” and the first window shows: “Hello World”. Ctrl-C ends the sessions.

Then installed MQTT.fx client in Windows and connected and tested OK. Always apprehensive about installing s/w but this program is heavily mentioned and the link is to the author’s site. Lots of open issues but it worked for me.

Now to try to configure OpenHAB. I’m hoping (presuming!) I can monitor GPIO pins.

Too early to say but this is a Pi 4 with 4GB and an SSD. Moving all the 4GB files from the SD card to the SSD went I recall in under a minute. Feels as responsive as my 3.4Ghz / 8GB desktop PC.

Ah yes, the Pi 4 was not out when I was starting with openhab, I was running a Pi 3B+ off the SD card.

I’ve seen a lot of people with issues getting the GPIO binding to work, and I don’t know how the docker container will affect that. You might want to try my MQTTany software. You’d have to run it directly on the Pi though, no docker container. It is also able to control GPIOs on remote Pis if you need to (which is why I made it).

Many thanks Michael. It did cross my mind that I might need to have a separate app communicating via mqtt, in the same way as when I used a sonoff esp8266 with tasmota. Or alternatively use NodeRed (I’m sure I’ve seen refs to NodeRed under OpenHAB ) as I know NodeRed can reference GPIO pins via node-red-node-pi-gpio

MQTTany looks very useful. Do you have a link to a page with examples?

No examples, but each module’s page shows the available options. I’ll add some examples soon, as you aren’t the first to ask. Message me on Gitter (link on the github repo page) if you need a hand setting it up.

1 Like

Not so good progress over the last 24 hours. First I decided to install Eclipse as my editor of the configuration files. I think I mistakenly installed the OH developers add-ins. It was 3.4GB of data and took hours! I then found out I should have installed Eclipse Smart Home Designer but while hunting for the download page discovered it was End of Life. So instead installed Visual Studio Code. I try to avoid being tied too much to MS but I must say installing VSC and the openhab extensions was quick and smooth.

Now I have a problem getting Windows access to the config files which of course with containers are in the Volumes directory and no Samba shares are automatically set up. I found this OH installation page and modified the Samba conf file to add/change:

# Changed from workgroup = WORKGROUP to
workgroup = XXXXXX
# Added after workgroup
wins support = yes
# Changed from valid users = %$ to
valid users = pi, openhab
# Added at end
  only guest=no
  create mask=0777
  directory mask=0777

This was followed by

sudo service smbd restart
sudo smbpasswd -a openhab
sudo smbpasswd -a pi
sudo chown -hR openhab:openhab /var/lib/docker/volumes/openhab_data/

When I enter my local IP address for the Rasp Pi into Windows Network I get icons for
- OpenHAB share (cannot access) - this icon comes and goes
- OpenHAB2 share (get Windows you do not have permission to access)
- pi share (can access folder of system files e.g .bash_history)

Before installing openHAB in a container I
sudo useradd -r -s /sbin/nologin openhab
sudo usermod -a -G openhab pi

and the stat command shows openhab user and group does have access to /var/lib/docker/volumes/openhab_data/

the Volumes folder has sub-folders of metadata.db mosquitto_data openhab_data portainer_data

Suggestions welcome please