Openhab v3 install with cgate on raspberry pi...

Discussion in 'Third-Party Solutions' started by paulon2u, Nov 14, 2022.

  1. paulon2u


    Apr 4, 2017
    Likes Received:

    Some basic raspberry pi / linux skills.

    Openhab can be configured manually in files or via the user interface. The entire process below uses the user interface.


    I haven’t used Home Assistant hence can’t offer a comparison of the two main opensource systems available. I have had v2.4 of openhab running very reliably on my Pi for several years which for me was very important. With v3 of openhab, it takes a bit more to wrap your head around it, but it’s easier to use hence I think is worth giving a try. Plus with the new binding, you don’t need Cgateweb which simplifies things somewhat.

    Openhab has gone to V3.3 and there is now a binding withi openhab for C-Bus. After you set up the initial connection of openhab <=> cgate, I suspect openhab knows where to find the C-Bus project xml file, but it auto finds and very quickly populates the “Things” property which says a lot of time and hassle manually configuring files.


    Useful links:

    This "how to" is probably work the watch before you commence the install to get an understanding of openhab, especially the semantic model and how to integrate this into the “Things”.

    1. Openhab

    I found a headless install on a raspberry pi is pretty painless.

    Follow Openhabs instructions on to download the openHABian image onto a SD card via Etcher. It’s pretty straight forward.

    I run cat 6 to my Pi so connection is easy to my Pi was easy. If you are using WiFi, follow the additional steps OpenHab provides. It creates a temp hotspot for you to talk to your Pi to enter your SSID and password I’m guessing.

    Give the Pi 15 to 45 mins as they say and then open your brower to:

    http://openhabian:8080/ or being the IP address of your Pi.

    You’ll know things are working when you get this.


    Create your account and then region.
    For the location screen I use the map option and pick somewhere close to my house like in a nearby lake on the map for a bit of privacy should anyone ever hack into this info…

    Next is installing the Cbus binding. Click on the “Select Add-ons…”

    Filter on Cbus and install…


    I’ll need MQTT so added it as well…



    You’ll see a

    “Welcome to OpenHAB!! – Get started” screen.

    And the main screen will load.


    OpenHab is now installed and up and running on your Pi. However, there are a few more settings worth tweaking…

    Putty into you Pi. Copy the various commands below and right click into the putty window to paste the command in.

    Username: openhabian

    Default password: openhabian

    to change the password

    Which will load up an interface menu. Have a look around and install / setup as needed for your install.

    I suggest:

    02 – Upgrade – let Openhab check for the latest.

    20 – Optional components, then 21 Log viewer. This is a must have to watch the Openhab log from your PC browser.

    30 – System settings. 33 – Enable NTP time sync, and 37 – disable Wifi if you are using Cat 6.

    Note if you reboot your Pi, it takes a few minutes for Openhab to fire up to your PC brower.

    Go back to openhab in your PC’s browser. (openhab:8080)

    Open a new tab http://openhabian:9001/ to view the Openhab log file, and confirm all is ok...

    2. Ser2Sock

    Now cgate and maybe ser2sock need to also be installed.

    Someone may be able to clarify this for me – there are two options of talking to your Cbus system, serial or ethernet via a CNI or PCI?? If you don’t have a RJ45 type connector, you’ll have a serial connection which could be either serial (9 pin) or USB. If you are talking via Serial, you’ll need to install Ser2Sock which uses a script to turn the serial connection into a socket connection, which makes the PCI module act like a CNI module. This allows Cgate to talk to Cbus.

    A big thanks to the community and for help here.

    Note, the scripts I have below are different to the link above. OpenHab using “openhabian” as the main username for Raspberry Pi, not “Pi” as the default install. The scripts below refer to this username hence need to be updated from the scripts in the above link.

    Install Ser2Sock first, running the following commands.

    Copy this startup script to go into ser2sock (again, from the cbus forums post by cheekymonkey here:

    Finishing setting up the startup script:

    Note in the line:

    “/usr/local/bin/ser2sock/ser2sock -d -p 10001 -s /dev/ttyUSB0 -b 9600”

    /dev/ttyUSB0 refers to which specific USB port on your Pi you are using. I leave as the default USB0 but you must plug into the first USB port of your pi for it to work.

    Be familiar with the following linux commands:

    sudo systemctl status Service

    sudo systemctl start Service

    sudo systemctl stop Service

    sudo systemctl restart Service

    Use them all the time to check and double check that ser2sock, cgate and openhab are running without errors.


    and you should get something like below. This advises ser2sock is healthy and running, and we can move onto install cgate.


    3. CGate

    First up, get Cgate.

    Occasionally Clipsal with update Cgate and then link may not work. If this doesn’t work, go here “” and find the URL link for the latest version of Cgate and replace the above url only, not the "wget" bit.

    Create a startup script for C-Gate. The cbus forums were a help again (particularly this thread)

    Change permissions on cgate folder and on the startup script:

    You can connect remotely from a windows PC running C-Bus Toolkit to configure your C-Bus network on the Pi but this installation as is will not work. Go here for further info. As best I understand it, the latest Java running on the Pi will block the connection from the remote PC (Clipsal are you listening???? :) ). I just connect locally to C-Bus with my laptop, configure the network and then FTP the .xml file across.

    Goto “C:\Clipsal\C-Gate2\tag” on your windows PC after configuring the network and FTP the .xml file of your network to “/usr/local/bin/cgate/tag”. (I use FileZilla).

    For reference, this is the error I get in the cgate event.txt log file when trying to connect remotely.

    20221112-093310 999 sys Selected client cipher: SSL_NULL_WITH_NULL_NULL
    20221112-093310 804 cmd9 - Host:/ closed command interface from port: 0

    If you want to connect remotely follow the configuration instructions on regarding connecting remotely and updating /usr/local/bin/cgate/config/access.txt

    Time to start cgate:

    The first time cgate starts it will create C-GateConfig.txt in /usr/local/bin/cgate/config. Do the following and enter your project name to the project.default and project.start lines within this file.

    i.e. HOUSE.xml is name of file



    Confirm there are no errors in the report.

    Cgate has a log file in /usr/local/bin/cgate/logs to review if things are not working...

    4. Configure openhab to talk to cgate.

    All services are now installed and it’s time to get Openhab talking to cgate.

    From openhab:8080 you should see something like

    Goto Settings => Things


    Click the blue + icon.


    You should see the bindings that were installed before. Click on C-Bus Binding.

    There are two parts to connecting to cgate. The first is at the IP address level so openhab can find cgate. The second is then the configuration within cgate. This is the name of your xml file plus a few other things.

    Click on CGate Connection


    Add the IP address of Cgate in the IP address (

    The Unique ID is added to the Identifier field in the line below. I use IP to infer the hierarchy of the system, Cbus -> Cgate -> IP, with more to come... Click Create Thing.


    The connection will show online – if it doesn’t stop, confirm cgate is working or figure what's missing...

    i.e. if you turn cgate off (systemctl stop cgate) you’ll see the connection go offline…


    Now the sexy part finally starts…

    Click the blue + icon to add another Thing, and select C-Bus Binding.


    This time click the scan button.


    Openhab finds the CGate configuration. My xml file is called ANZAC.


    I change the network name to just the name of the xml file. You don’t need to do this but I find it simpler later on.


    Click the blue + icon to add another Thing, and select C-Bus Binding, and click Scan again.


    I’m guessing Openhab parses the xml file, because very quickly all my lights showed up very quickly.

    Scroll down and select, Add All.

    Whatever is in the XML file gets imported, hence things you might not need also get imported, and the naming convention is the same as the file also. I wouldn’t worry about this, because this is the back end of openhab and you can type up descriptions for the front end.

    You can select individual if you want but I’ve found this to be clunky.


    All your “things” within cgate should now be online within openhab. FYI, my naming convention within Cbus is Dx.x or R x.x where the first x is the number of the Relay or Dimmer block, and the second x is the channel within that block.

    Watch the youtube video at the start of this guide on setting up the sematic model to start controlling (turning on and off lights) things.

    Below I have started setting up my model. Once an area is created you can select “Create equipment from Thing” which will give you the option of selecting the appropriate light etc to that room. I’ve only done the master bedroom below.


    Again, a big thank you to all the community for various posts and helpful information along the way. Please let me know if the above doesn't work or mark sense in any ares. Have fun!!
    paulon2u, Nov 14, 2022
    Ian likes this.
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.