How-To : Install and Run VelServ - a Velbus TCP Gateway

for issues with homeassistant:

or

this is a bit dependant on what th errors exactly is

2 Likes

Just a thought, maybe @cereal can confirm.

Are homeAssistant & VelServ fighting for the same TTY port?

The service file I wrote for VelServ will attempt to restart every few seconds of it canā€™t connect to TTY port.

My thought is that HA is connecting to the TTY port before VelServ can grab it.

@MDAR Thank you for the work on the server & the installation script! Can I take it and save a copy on gitlab, obviously with keeping all authors as authors? Alternatively I can assist with the process of setting up a git repo (very easy). The reason is that the link to http://leachy.homeip.net/velbus/velserv.c is already dead, rest of the code is on mdar.co.uk webpage (you change domain or move server and we have a problem). Keeping the code on gitlab makes it more future proof to some extent. Itā€™s also easier to keep versions tagged, make releases, etc. It also allows external contributors to submit code amendments.

Also, is there a licence attached? Am I allowed to modify the code? :stuck_out_tongue_winking_eye:

P.S. I just become an owner of tiny working velbus installation :heart_eyes: and openHAB integration is most likely a next step.

1 Like

Hi

Thanks for the compliment.

I didnā€™t know the link to @jeroends code is broken, Iā€™m sure heā€™ll chime in and help.

Iā€™ve been thinking about doing something like this for a long time, not just for this script, but for all the things Iā€™ve / weā€™ve created over the years.

For example, the openHAB template files Iā€™ve created have evolved over the years, as the binding has matured.

@cedricb
@Daniel615be

Thereā€™s some more work to be done on it in the future, which will need magic that Iā€™m just not capable of (at this point, although happy to learn how to add modules and functionality to the binding, if someone is willing to teach me).

I totally appreciate that developing the binding is a labour of love, which has to happen in peopleā€™s own time.

That said, with so many people now using the binding maybe itā€™s time to put a bounty on it?

What are peopleā€™s thoughts on this?

I havenā€™t attached a license to my small efforts, can you suggest an appropriate one that enables people to amend and develop?


If you / we can setup a GitHub / GitLab repository, I assume we can assign multiple administrators?

As you suggest with web servers, Iā€™d hate the project to suffer if one person got ā€œhit by a busā€.

Can we continue privately and update this (and other threads) with the links?

1 Like

Someone already did it :slight_smile: GitHub - jeroends/velserv: A TCP to Velbus gateway for Linux

I normally use GPLv3

We can have multiple admins, maintaneers, developers with different access level, no problem.

P.S. github is more popular, but it was taken over by Microsoft, so I moved my stuff to gitlab.

ā€œsomeoneā€ you sayā€¦

Maybe it was our very own @jeroends :grin:

My script pulls updates from that site anyway.

https://raw.githubusercontent.com/jeroends/velserv/master/velserv.c

Excellent, Iā€™m happy to use whatever you suggest, as itā€™s all new to me anyway.

1 Like

Happy to be admin as well on it ā€¦ RZomerman (Roelf Zomerman) Ā· GitHub

2 Likes

Hello,
velserv is idd already on github since a few years :slight_smile: . Thatā€™s the reason I did not repair my little server anymore (will be repaired someday, but other priorities).
Iā€™m not that formiliar with licenses, but as already stated in the code: if you want to change something: let me know because Iā€™d like to have my name associated to it (as it was the last +/-13 years already).
Iā€™d like to avoid having x version of the code, so the only code I support (and is the original code) is on my github (with backups on my PC). If you want to update the code, make it better: certainly be my guest! Iā€™ve already some upgrades in my mind, but since the code is still doing itā€™s thing and my time that I could spend on it is limited (3 kids, pretty busy job and other projects) those arenā€™t implemented.

3 Likes

Hello,

Iā€™m running HA (HAOS 12.1) on an RPi 3 and all my integrations (Velbus, Philips Hue, Zigbee devices) run flawlessly. Home assistant is using the serial connection (USB) from the VMBRSUSB module for the integration of all my Velbus entities. For convenience, I donā€™t want to swap this USB connection to a PC in order to access VelbusLink, so I was thinking of setting up velserv or the Velbus TCP snap package mentioned next to my HA. What would be the easiest and most robust set-up? Can I install the snap package on my already existing HAOS and will this run out-of-the-box?

1 Like

Hello and welcome to the community.

Simplyā€¦

YES, this is the easiest and most robust solution.

The only thing to watch for is changing the /dev/serial/ references.

In HA that needs to change to tls: password @ IP_Address_of_RPi:27015

and I would recommend changing the /dev/serial/ttyUSB to something like /dev/serial/by-id/velleman_VMB1USB

The script I created for installing the SNAP package will do this for you.

1 Like

Maybe I should rephrase my question. Iā€™m currently using the hass.io operating system, which makes it apparently not possible to execute apt commands. I will probably need to install HA on another OS to install the SNAP package? Which OS is best recommended for my RPi running only HA?

Hi

That should be okay, itā€™s based on Debian.

As long as you can get to an OS level command prompt, you should be able to install Snap on the root.

@cereal was talking about creating a Docker specially for Velbus-tcp

Maybe thatā€™s something you can use?

If a separate machine is your only option (which Iā€™m sure it isnā€™t), any small machine with a Debian OS will do the trick.

Iā€™ve got an image for a BeagleBone black if you want it.

@csoete I didnā€™t have time to proofread my own step-by-step instruction, but if you hit any problems check this: Installing OpenHAB ā€“ Velbus binding ā€“ Core Dump
I use OpenHAB, so I canā€™t tell what system is the best, but HAOS 12.1 is the officiad HA system, so why look for something else if you only want to run HA?
We can help with the velbus-tcp, even manual install is an option. Ot the MDAR script. If it doesnā€™t work - come back - I did some debugging, itā€™s very easy when youā€™re guided. Some details will be different on your system than on mine, so the below is only an example.

Make sure your system detects the bridge

openhabian@openhabian:~ $ lsusb 
Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
Bus 001 Device 003: ID 10cf:0b1b Velleman Components, Inc. VMB1USB Velbus USB interface
Bus 001 Device 002: ID 2109:3431 VIA Labs, Inc. Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub

Check if you have it in the udev tree:

openhabian@openhabian:~ $ udevadm info  -n /dev/ttyACM0 | grep Velbus
E: ID_USB_MODEL=VMB1USB_Velbus_USB_interface
E: ID_USB_MODEL_ENC=VMB1USB\x20Velbus\x20USB\x20interface
E: ID_USB_SERIAL=Velleman_Projects_VMB1USB_Velbus_USB_interface

Check that the velbus-tcp works:

openhabian@openhabian:~ $ systemctl status velserv
ā— velserv.service - Velserv
     Loaded: loaded (/etc/systemd/system/velserv.service; enabled; vendor preset: enabled)
     Active: active (running) since Sun 2024-03-17 18:41:45 CET; 24h ago
    Process: 731 ExecStart=/opt/velserv/velserv -d /dev/serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.3:1.0 -p 6000 (code=exited, status=0/SUCCESS)
    Process: 746 ExecStartPost=/bin/bash -c /bin/touch /var/log/velserv.log (code=exited, status=0/SUCCESS)
    Process: 764 ExecStartPost=/bin/bash -c /bin/echo Velserv Started $(date) >> /var/log/velserv.log (code=exited, status=0/SUCCESS)
    Process: 789 ExecStartPost=/bin/bash -c /bin/pidof velserv >> /var/log/velserv.log (code=exited, status=0/SUCCESS)
   Main PID: 742 (velserv)
      Tasks: 4 (limit: 4531)
        CPU: 4.607s
     CGroup: /system.slice/velserv.service
             ā””ā”€742 /opt/velserv/velserv -d /dev/serial/by-path/platform-fd500000.pcie-pci-0000:01:00.0-usb-0:1.3:1.0 -p 6000

Mar 17 18:41:45 openhabian systemd[1]: Starting Velserv...
Mar 17 18:41:45 openhabian systemd[1]: Started Velserv.

FYI

Thatā€™s VelServ

Rather than the Snap Velbus-TCP package

But you are on the right lines.

One interesting note that I have requested that the Velbus-TCP snap package follows is that when VelServ fails (mainly due to the absence / removal of the USB connection), the Service fails and it reported.

however, if the Snap package fails, it will never tell you, nor will it recover automatically.

snap status velbus-tcp

snap get velbus-tcp -d to get the connection details

snap restart velbus-tcp

1 Like

I gained access to the OS-level CLI with the login command. Similarly, the install of the snap Velbus-TCP package also fails here due to apt not being found. I did some research and apparently my OS (Home Assistant OS 12.1) is buildroot which means it is not possible to install packages. This is based on:

Which means Iā€™ll probably have to install HA on top of another OS (possibly debian based), which is a shame because I liked having the ease-of-use installation of HAOS.

1 Like

If I understand how itā€™s made, youā€™d have to make changes to the container, thatā€™s a different story. Is the HA forum providing any help?

P.S. Looks like the ease of installation comes with a price tag. Removed flexibilityā€¦

2 Likes

if you want something like this you have to build an addon, its on my todo list, but no idea when i will get it finished.

1 Like

Thank you all for your replies, I have since advanced a bunch.
However, I still have some difficulties connecting my RPi server through VelbusLink.
Iā€™m currently running Home Assistant Container on a Raspberry Pi 3B using the (Raspberry Pi Lite) OS:

Operating System: Debian GNU/Linux 11 (bullseye)
Kernel: Linux 6.1.21-v8+
Architecture: arm64

I then ran the following Docker run command which set up Home assistant on the following internal LAN url: http://harpi.local:8123/ (harpi.local being the hostname of my RPi):

sudo docker run -d \
--name homeassistant \ 
--privileged \ 
--restart=unless-stopped \
-e TZ=Europe/Brussels \
-v /config/ha:/config \
-v /run/dbus:/run/dbus:ro \
--network=host \
--device=/dev/ttyUSB0:/dev/ttyUSB0 \
--device=/dev/ttyACM0:/dev/ACM0 \
ghcr.io/home-assistant/home-assistant:stable

Note that USB0 is the connection to my Sonoff_Zigbee_3.0_USB_Dongle_Plus and ACM0 is my Velleman VMB1USB interface.

I can access HA perfectly and all integrations (Zigbee dongle and Velbus USB) show up, meaning the mounting in Docker was done successfully. I then installed the velbus-tcp snap package using MDARs script:

mkdir /opt/velbus-tcp
cd /opt/velbus-tcp
wget www.mdar.co.uk/dl/velbus/velbus-tcp.sh -O /opt/velbus-tcp/velbus-tcp.sh
sh velbus-tcp.sh

This was also executed successfully and gave me this output:

Velbus-TCP is now running with these settings
{
        "logging": {
                "output": "stream",
                "type": "info"
        },
        "ntp": {
                "enabled": true,
                "synctime": ""
        },
        "serial": {
                "autodiscover": false,
                "port": "/dev/serial/by-id/usb-Velleman_Projects_VMB1USB_Velbus_USB_interface-if00"
        },
        "tcp": {
                "auth": "true,false",
                "authkey": "velbus,",
                "cert": "/var/snap/velbus-tcp/common/certificate.pem",
                "host": "0.0.0.0,127.0.0.1",
                "pk": "/var/snap/velbus-tcp/common/privkey.pem",
                "port": "27015,6000",
                "relay": "true,true",
                "ssl": "true,false"
        }
}

Now I want to connect to VelbusLink on other devices within the network using the network connection (TCP/IP) using the following Server details:

Host address: harpi.local
Port: 27015
Authentication key:
TLS/SSL connection: Unchecked
Remember password (unsafe): Unchecked

I think Iā€™m connected to the gateway when I press ā€œFinishā€. However, I canā€™t seem to find any modules as it instantly gives me an error when pressing the ā€œScanā€ button:

An unexpected error occured, we've disconnected you from the bus.

Does anyone have a solution for this or encountered this error? I hope I provided enough details to replicate my setup.

Nevermind, I did not see that an authentication key was set during MDARs script. I now connect using:

Host address: harpi.local
Port: 27015
Authentication key: velbus
TLS/SSL connection: Checked
Remember password (unsafe): Unchecked

I can now interact with my modules using VelbusLink. Should I still mount the VMB1USB interface using the docker run command (ā€“device) or connect via the integration on HA?

For a TCP/IP device: 127.0.0.1:6000

Is it even useful to mount the Velbus USB port in my Docker container?

Congratulations :partying_face:

Iā€™m glad youā€™ve got it all working.

I know very little about dockers and HA, I find them all far too confusing.

However, I would say that youā€™re right, there is little point in mounting the Velbus port for the HA docker, in fact probably risking some misconfiguration.