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

Hi guys

You have helped me already in another thread: Velbus binding for OpenHAB

Now I’m trying to get velserv running (I used Velbus binding connecting to Velser but it’s similar to this thread).
I get following error when trying to enable velserv.service:
Failed to enable unit: File velserv.service: Bad message

When checking the status I get this:
● velserv.service
Loaded: error (Reason: Bad message)
Active: inactive (dead)

Jan 04 12:34:31 openHABianPi systemd[1]: [/etc/systemd/system/velserv.service:9] Invalid section header

Any idea what’s going wrong?

Hi :slight_smile:

There’s your problem…

“Invalid Section Header”

It doesn’t like something in the service file I wrote.
(Which isn’t surprising, as I’ll happily confess that I know little to nothing about coding)

You could try deleting this “file present” checking Unit?

File velserv.service

Failed to enable unit: File velserv.service: Bad message

So…

Can you start VelServ via a command line ?

something like :

./velserv -p 6000 -d /dev/ttyACM0

Assuming that your USB device is mapped to ttyACM0

Check out this post for more information - USB Problems on linux - #8 by MDAR - Beginners - openHAB Community

Then use

pidof velserv

To confirm that it’s loaded and running.

(Which is all that the service file is doing)

Once you’ve got VelServ running manually, you can look into what’s wrong with the service file.

FYI, the service file is working for me on a number of machines, running Debian or Ubuntu.

It’s very possible that Raspberry Pi needs something different in the velserv.service file to get it running.

I hope this helps you.

FYI

When you say that this topic is “similar” to the one on the openHAB forum, do you mean that it almost looks like someone has “copied” it? :wink:

@MDAR
You did it again :slight_smile:

I tried to start the system with

Then

I got the number 3809, which (I suppose) means that it’s running.
Then I just started “cleaning up” the velserv.service, meaning I put everything on a new line when I felt it should :smile:

I rebooted, and then this is what happened:

[17:56:19] openhabian@openHABianPi:~$ systemctl status velserv
● velserv.service - Velserv
Loaded: loaded (/etc/systemd/system/velserv.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2019-01-04 17:56:11 CET; 42s ago
Process: 475 ExecStartPost=/bin/bash -c /bin/pidof velserv >> /var/log/velserv.log (code=exited, status=0/SUCCESS)
Process: 462 ExecStartPost=/bin/bash -c /bin/echo Velserv Started $(date) >> /var/log/velserv.log (code=exited, status=0/SUCCE
Process: 430 ExecStartPost=/bin/bash -c /bin/touch /var/log/velserv.log (code=exited, status=0/SUCCESS)
Process: 413 ExecStart=/opt/velserv/velserv -d /dev/ttyACM0 -p 6000 (code=exited, status=0/SUCCESS)
Main PID: 426 (velserv)
CGroup: /system.slice/velserv.service
└─426 /opt/velserv/velserv -d /dev/ttyACM0 -p 6000

Jan 04 17:56:11 openHABianPi systemd[1]: Starting Velserv…
Jan 04 17:56:11 openHABianPi systemd[1]: Started Velserv.

[17:57:09] openhabian@openHABianPi:~$ pidof velserv
426

So I guess it works now, I can connect with Velbuslink over TCP/IP, so that’s great.
Just to be sure, I’m gonna reboot the RPi again, and test if I can connect with Velbuslink

I’ll reply if it’s still OK.

1 Like

Yep! Works perfect!

Again, many thanks for the quick help.

About this:

You actually thanked the author for referencing to your website…
But I honestly have to say, his explanation was more understandable than yours :stuck_out_tongue:
I’m pretty sure the problem lies with me, since I know sh*t about linux coding.

Anyway, I got Velserv working, so I’m happy :smiley:

I’ll take that on the chin :slight_smile:

I am very happy that you’ve got it all up and running :slight_smile:

If you’d care to share your modified velserv.service file. I’ll drop it into the zip file so someone else can benefit :smile:

Offcourse! I’m happy if I can help someone else :smile:
Here’s the text to put in velserv.service:

[Unit]
Description=Velserv
ConditionFileIsExecutable=/opt/velserv/velserv.sh
After=network.target
After=network-online.target

[Service]
Type=forking
ExecStart=/opt/velserv/velserv -d /dev/ttyACM0 -p 6000
ExecStartPost=/bin/bash -c “/bin/touch /var/log/velserv.log”
ExecStartPost=/bin/bash -c “/bin/echo Velserv Started $(date) >> /var/log/velserv.log”
ExecStartPost=/bin/bash -c “/bin/pidof velserv >> /var/log/velserv.log”
ExecStop=/bin/kill $MAINPID
TimeoutSec=0
RemainAfterExit=yes
StandardOutput=journal+console
StandardError=journal+console

[Install]
WantedBy=multi-user.target

This works for me. I hope someone else can test it and confirm it works for them too.

Greets!

1 Like

Hello all.

If assigning USB devices to the same ttyACM port at boot up in Linux is an issue, give this a try :

./velserv -d /dev/serial/by-id/usb-Velleman_Projects_VMB1USB_Velbus_USB_interface-if00

Please post your results, as this is just something we’re experimenting with.

Hi guys.

I just wanted to let you guys know that I have disabled the Velserv service, as it interfered with the status-updates in Habpanel. Statuses weren’t shown correct when I pushed a button, temperatures were N/A.
So I disabled the service, and stopped it. Now, whenever I need it, I just start the service, and then stop it again after I have used it.

Still very happy that I don’t have to use a USB-cable anymore to change something with Velbuslink. :grinning::+1:

That’s not a condition that I’ve seen before.

Are you still trying to use a Velbus Serial Bridge in openHAB2?

Or have you created a Velbus Network Bridge in openHAB2 and pointed it to VelServ?

FYI

I haven’t used a direct USB connection (serial bridge) in openHAB2 since Cédric added the Network Bridge.

It’s easy enough to swap your Velbus Things over to a new bridge in openHAB2.

  • Just set up the new Velbus Network Bridge in paperUI. Using the correct IP and port (don’t use localhost, its better to use 127.0.0.1 on the same machine)

  • Edit each Thing so that it uses the Network Bridge.

  • Delete the Serial Bridge once you’ve migrated all the Velbus Things.

You might need to restart openHAB2 (after starting the VelServ service) just so that openHAB2 can re-initialise each Thing)

Good luck

Are you still trying to use a Velbus Serial Bridge in openHAB2?

I am…

I have now installed the Velbus Network Bridge in paper UI. Not sure how to point it to Velserv. I use 127.0.0.1, and port is 8080 (which is the standard openhab port I think).
–>*EDIT: should be port 6000 I suppose, gonna change that and let you know.
–>*EDIT2: nope, 6000 gives an error, 8080 says it works.

Updating each Thing to use the network bridge as we speak. I get a “thing updated” notification, but in the list of Things, everything looks the same. I’m gonna update each thing, then start the velserv service, and reboot the RPi, hoping everything works, and then I’ll delete the serial bridge.

I’ll post an update when I’m done.

Hi

The port to point the Velbus network bridge to is whichever port VelServ is outputting to. (My service file tells VelServ to use port 6000, but the default port for VelServ is 3788)

Until you remove the serial bridge in openHAB2 and start VelServ, it won’t work :slight_smile:

(I’ve got no idea why pointing it to port 8080 suggests that it’s working, as port 8080 is the html server)

(Hence suggesting that you complete the changes, then reboot before deciding if it’s working)

Delete the serial bridge before rebooting, as you’ll never know if the serial bridge locks the USB interface before VelServ gets a chance to connect.

I changed the network binding port setting tot 3788, I get a reply “offline, communication error”
When I change it to 6000, the binding is online. (Velserv is running)

I did remove the serial bridge before rebooting…
When I look at the settings of any of my things, it shows the new network binding, but in the overview with all the things, they still show the old serial binding.

Maybe reboot the RPi again?

That sounds like you’re in the right track now :smile:

Where do you mean?

My bridge looks like this in PaperUI / Configuration / Things …

And here’s a Velbus Thing as an example

Just rebooted the RPi again

This is my network bridge:

And here’s a thing:

So far so good
But here’s the problem:


The 10370302 is the serial binding (which is deleted before reboot)
That’s what I was trying to explain, while changing the settings for each thing to the network bridge, in the settings it changed, I even got a notification that settings were saved, but in the overview nothing changed…

I can even still switch every output in Habpanel (which uses the outputs with the serial binding)

Oooooooo I see :smile:

That makes sense.

I thought that number was just a (random) unique ID for each Thing. I never noticed that it was the ID for the bridge (that was in play when the Thing was first created).

Either way, if the Things are working…

“Who cares which number it is” :wink:

Yeah I guess you’re right.
That’s just something autistic I can’t handle :wink:

Anyway, again a big thank you for your help. :+1: :+1:

Status updates work perfect now (which they didn’t as I mentioned before)

1 Like

Excellent news all round.

Other than the bridge number issue.

I’m not sure what to suggest if it’s really bugging you.

Other than suggest that is a nice reminder of how you got it all working in the first place.

Our software evolves like the rest of us?

The only thing to consider is if you do work out how to change the number, wouldn’t it negatively affect all the rules you’ve created?

That’s probably right.

The thing is, Habpanel is working fine on my phone, but on my laptop it doesn’t. Status updates aren’t correct, it’s like I need to push a button again to have it updated.
Same goes with basic UI, which I recently started playing around in. I had a few thinks working, but now they don’t work anymore. Maybe that has something to do with the new network bridge.

I’ll search on that another time. Since it’s Sunday, maybe I should spend some attention to my girlfriend now :wink:

Always :slight_smile:

Hi

To make life even easier to setup Velserv, I’ve created a script to download and setup.

http://www.mdar.co.uk/dl/velserv-setup.sh

Use a terminal and try these commands…

wget http://www.mdar.co.uk/dl/velserv-setup.sh

cat velserv-setup.sh

sudo sh velserv-setup.sh

When the script has completed it’s final step, you should see something like this :

user@Linux_MiniServer:/# systemctl status velserv
● velserv.service - Velserv
   Loaded: loaded (/opt/velserv/velserv.service; enabled; vendor preset: enabled)
   Active: active (running) since Sun 2019-03-24 17:55:34 GMT; 47s ago
  Process: 2345 ExecStartPost=/bin/bash -c /bin/pidof velserv >> /var/log/velserv.log (code=exited, status=0/SUCCESS)
  Process: 2338 ExecStartPost=/bin/bash -c /bin/echo Velserv Started $(date) >> /var/log/velserv.log (code=exited, status=0/
  Process: 2334 ExecStartPost=/bin/bash -c /bin/touch /var/log/velserv.log (code=exited, status=0/SUCCESS)
  Process: 2327 ExecStart=/opt/velserv/velserv -d /dev/serial/by-id/usb-Velleman_Projects_VMB1USB_Velbus_USB_interface-if00
 Main PID: 2332 (velserv)
    Tasks: 4
   Memory: 104.0K
      CPU: 86ms
   CGroup: /system.slice/velserv.service
           └─2332 /opt/velserv/velserv -d /dev/serial/by-id/usb-Velleman_Projects_VMB1USB_Velbus_USB_interface-if00 -p 6000

Mar 24 17:55:34 Ubuntu-Home systemd[1]: Starting Velserv...
Mar 24 17:55:34 Ubuntu-Home systemd[1]: Started Velserv.

It will stay in that state until you press q

Good luck

If you want to keep an eye on the amount of times Velserv is started at boot up, take a look at the log file it appends

cat /var/log/velserv.log

I can’t remember what inspired me to write this script, ahem… @CobleS @RossJe

4 Likes