Velbus software (OLD info)

AttachmentSize
Binary Data velbus.tar.bz219.78 KB

Update

See https://github.com/StefCoene/velserver

What

Velbus (http://www.velbus.eu/) is domotica hardware made by Velleman, a Belgian company.  I have a Velbus setup at home and this is working flawless.

You can also buy the 'VMBHIS - Home center interface server' so you can use your computer/tablet/smartphone to control Velbus, but I don't want to pay for this. I also want to integrate other hardware and tools in my domotica setup.

OpenRemote (http://www.openremote.com/) has native Velbus support, but I don't like the way how you have to configure the interface between OpenRemote and Velbus.
It's very complex. I also don't like the GUI because for each screen size, you have to redesign the GUI.
So OpenHAB is a beter option in my opinion, but it has no native interface for Velbus.

The protocol information that's used by Velbus is very open, you can download all the pdf's from the Velbus website.
I also found some interesting perl code on http://leachy.homeip.net/velbus/.

Based on the perl code I found, I started my own project.
After some trial and error, I was able to see the messages on the bus and put commands on the bus.

For now, I'm able to process all the messages on the bus. I only parsed the protocol pdf files for the modules I have in my setup.
Adding protocol support for an extra module is not that difficult.
For now, I can record the name of the channels and the status of the blind and relay channels.
I can send some basic commands to the bus: scan, get status of modules, broadcast the date, ...

Goal and next steps

My first goal was to understand the velbus protocol and to create a logger so I can see what's happening on the bus.
I also added basic status messages so I can query the modules and the status of the channels. This is the current fase of this project.

The next step will be to understand how to control the modules. This can't be that hard, I can already put messages on the bus.

I'm no java programmer and I also want this project to be independent as possible. That's why I think the best way for interfacing with OpenHAB (and other projects) will be via a webservice. That's easy to write and to implement.

How

You need to have a TCPIP Velbus server running and connected to your Velbus setup.
I use velserv.c compiled on a linux server.

The scripts are written in perl on a ubuntu 16.04 server.
You need to install some extra perl modules that you need to install with apt or yum:

  • Data::Dumper
  • IO::Socket
  • Time::HiRes
  • DBI
  • mysql

The script logger.pl will report and process all messages on the bus.
Packets on the bus are printed on the console and stored the mysql database.
With commands.pl you can send commands to the bus.

The protocol information is stored in a big perl hash. Per module the possible messages are stored with extra information. This extra information is used to decode the message in something usefull. This is rather complex, but I found something that's flexible enough .
Currently, these modules are defined since that's what I have in my setup:

  • 10: VMB4RYLD = 4-channel voltage-out relay module
  • 11: VMB4RYNO = 4-channel relay module
  • 12: VMB4DC   = 4-channel 0(1)-10V control
  • 1D: VMB2BLE  = 2-channel blind control module
  • 20: VMBGP4   = 4 touch button
  • 22: VMB7IN   = 7-channel input module
  • 28: VMBGPOD  = LED touch
  • 2A: VMBPIRM  = Mini pir motion detector

Known issues

When scanning the bus, there is a lot of messages on the bus. At my setup this means that reading from the velserv sockets can give you more then 1 message. If this is the case, the script will try to detect this and split the messages and parse them 1 by 1. A possible side effect is that the processing of the messages will be delayed. When this mechanisme is not working correctly, the checksum will be wrong and this will be printed by logger.pl
There is no available command in the Velbus protocol to read the name of the module itself. The name of the channels can be read.
The last part of the name of the second channel of the blind module type VMB2BLE can not be read. It returns the last part of the first channel. I think this is a bug in the Velbus firmware.

Directory structure

The main directory I use is '/data/Velbus/perl'. If you change this, you also have to update 2 scripts: logger.pl and commands.pl and point the line that begins with 'use lib' to the new directory.

directory etc: contains config files
  etc/mysql.cfg, default settings:
    host = localhost
    pass = velbus
    user = velbus
    name = velbus
  etc/velbus.cfg, default settings:
    host = localhost
    port = 3788

directory lib: needed libraries
  lib/mysql.pm: some basic functions so we can connect to a mysql database and insert/delete data
  lib/Velbus.pm: basic Velbus module that will load and initialize the rest of the framework
  directory lib/Velbus: Velbus functions
    lib/Velbus/Velbus.pm: main vebus functions
    lib/Velbus/Velbus_helper.pm: basic velus functions
    lib/Velbus/Velbus_data_protocol.pm: Velbus protocol information
    lib/Velbus/Velbus_data.pm: extra information
    lib/Velbus/Velbus_mysql.pm: mysql related Velbus functions
    lib/Velbus/Velbus_www.pm: some functions for the website

directory www: website for basic information
  www/index.pl

directory bin: scripts and executables
  commands.pl: to send commands to the bus
  logger.pl: this logs all information on the bus
  pdf2txt.pl: simple perl scripts that uses the command pdf2txt to extract info from the protocol pdf files
  velserv: compiled from velserv.c

 

Available scripts

bin/logger.pl

When running this script, it will process all messages on the bus. The message is printed in pretty text on standard out. It is also written to the mysql database for further processing.
  output: <date> <prio: HI or lo> <address> = <Module Type> : <message ID (message type)> :: <rest of message>

bin/commands.pl

When you run this script, it will give you the possible options. You can specify the command with -option. Available options:

  •     temp = Query temperature of LED on address 0x31
  •     status = get status off all modules
  •     date = broadcast date and time
  •     scan = scan all modules on the bus
  •     blind = query blind status on address 0x01

MySQL tablespaces

For mysql, create a database with following tables:
  CREATE TABLE `messages` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `date` datetime NOT NULL,
    `address` varchar(2) NOT NULL,
    `prio` varchar(1) NOT NULL,
    `type` varchar(2) NOT NULL,
    `rtr_size` varchar(2) NOT NULL,
    `raw` varchar(50) NOT NULL,
    PRIMARY KEY (`id`)
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
 
  CREATE TABLE `modules` (
    `address` varchar(2) NOT NULL,
    `name` varchar(16) NOT NULL,
    `type` varchar(16) NOT NULL,
    `status` varchar(16) NOT NULL,
    `date` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP,
    PRIMARY KEY (`address`)
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;
   
  CREATE TABLE `modules_channel_info` (
    `address` varchar(2) NOT NULL,
    `channel` varchar(40) NOT NULL,
    `data` varchar(40) NOT NULL,
    `value` varchar(120) NOT NULL,
    `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    UNIQUE KEY `address` (`address`,`channel`,`data`) USING BTREE
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

  CREATE TABLE `modules_info` (
    `address` varchar(2) NOT NULL,
    `data` varchar(40) NOT NULL,
    `value` varchar(120) NOT NULL,
    `date` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
    UNIQUE KEY `address` (`address`,`data`)
  ) ENGINE=InnoDB DEFAULT CHARSET=latin1;