A JavaScript library for processing RESOL VBus data

695 views
Skip to first unread message

Daniel Wippermann

unread,
Feb 12, 2014, 2:52:58 PM2/12/14
to Resol Vbus
Hi folks,

although it is far from complete I wanted to introduce you to a project that I have been working on over the last couple of weeks:

„resol-vbus“ is an open-source library for Node.js that enables you to communicate with RESOL’s VBus enabled devices.



What have I done with it already?

- Connects to various RESOL VBus devices

The library aims to support multiple ways of getting in contact with a RESOL device. The currently most tested way of communication is over LAN, the serial port interface lacks behind quite a bit (mostly because I don’t have a VBus/USB adapter at hand).

Most examples are designed to connect to a Datalogger using the „TcpConnection“ class, which works well for VBus/LAN, DL2, DL3 and VBus.net.


- Processes live and recorded VBus data streams

The library contains classes for decoding both live VBus data streams and the recorded file format used by the Dataloggers and the RSC software. It has a quite up-to-date list of RESOL devices and their VBus payload included and can convert the binary VBus data to textual representation.


- Discovers LAN-enabled RESOL devices on the local network

Works like the Device Discovery Tool by searching LAN-enabled RESOL devices like VBus/LAN, DL2, DL3 or LAN-enabled controllers on your local network and listing their IP information.


- Allows to send parameterization commands to a controller

The „ConnectionCustomizer“ takes an existing „Connection“ (like the „TcpConnection“ to a Datalogger mentioned above) and customizes the controller’s settings based on a list of values provided.

My focus is currently on this one. There is a rather old example in https://github.com/danielwippermann/resol-vbus/blob/master/examples/mx-manual-relais/index.js . In the last couple of days the library got the „ConnectionCustomizer“ class that should take care of the heavy lifting done in the example. I’ll try to rewrite that using the new mechanics soon.


- Synchronizes recorded VBus data from a RESOL datalogger to your local file system

The example in https://github.com/danielwippermann/resol-vbus/blob/master/examples/sync-dlx/index.js contacts a Datalogger and syncs any new recorded data to the local hard drive. Taking that example as a starter you could then put the freshly synced data into a database or convert it to text files.


- Converts recorded VBus data into human or machine readable formats, optionally allowing to filter the output

You can see that in action in the node-webkit sample app https://github.com/danielwippermann/resol-vbus/blob/master/nw-apps/logger/index.js . It connects to a Datalogger using a „TcpConnection“. All incoming packets are handed over to a „HeaderSetConsolidator“. That class is responsible for collecting the packets and waiting for a log interval. Once that log interval is reached, it hands the packets from that moment to the „TextConverter“ which will create a CSV file entry of the packets and write them to a file.

The sample app also supports creating filters. Filters currently are JSON objects that allow you to specify which values should be stored in the CSV file and what their name should be (e.g. „Temperature Collector“ instead of „Temperature sensor 1“).

Filters will be extended to support basic calculations as well (e.g. °C -> °F, heat quantity -> CO2 saving etc.)

The GitHub project lacks a build script for the node-webkit sample app, but I hope to include that soon… If you have OSX I can supply you with a link to the most current version.


What is missing?

- Documentation
- Examples

I’m lazy when it comes to those two… If you are missing anything, drop me a line and I’ll try to fill that gap.


I’d like to thank Tom from this Google Group for being courageous enough to be a alpha tester. His feedback has been super helpful.

If you have any question regarding that lib drop me a line.

Happy coding,
    Daniel




Sent with Mail Pilot

Andrew White

unread,
Feb 12, 2014, 4:38:42 PM2/12/14
to resol-vbus

Hi daniel

That looks great!

Can I connect to my serial vbus using ser2net or similar?

Andrew

--
You received this message because you are subscribed to the Google Groups "Resol Vbus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to resol-vbus+...@googlegroups.com.
To post to this group, send email to resol...@googlegroups.com.
Visit this group at http://groups.google.com/group/resol-vbus.
For more options, visit https://groups.google.com/groups/opt_out.

Daniel Wippermann

unread,
Feb 12, 2014, 10:37:03 PM2/12/14
to Resol Vbus
Hi Andrew,

I think it should be possible. I’ll try to perform a run test later and get back to you hopefully with a snippet of code.

Best regards,

Daniel Wippermann

unread,
Feb 13, 2014, 10:32:42 AM2/13/14
to Resol Vbus
Hi Andrew,

after doing some minor changes (already pushed to GitHub) now two ways work in conjunction with serial ports:

1) Using ser2net in combination with TcpConnection class

   var conn = new vbus.TcpConnection({

        host: '0.0.0.0',

        port: 4000,

        rawVBusDataOnly: true,

    });


The „rawVBusDataOnly“ option skips the credentials handshake (which is not necessary over serial ports).

2) Using the SerialConnection class

   var conn = new vbus.SerialConnection({

        path: '/dev/tty.usbmodem1421',

    });


I tested that one with a VBus/USB adapter today and it worked okay (after applying the fixes I mentioned).

Using one of these Connection instances you can build a small VBus decoder. After initializing the Connection you need to listen for events and then open the connection to start receiving data:

   var onConnectionStateChange = function(state) {

        console.log(state);

    };


    var onPacket = function(packet) {

        console.log(packet);

    };


    conn.on('connectionState', onConnectionStateChange);

    conn.on('packet', onPacket);


    conn.connect().done(function() {

        setTimeout(function() {

            conn.disconnect();

        }, 10000);

    });


This example prints raw information about every incoming VBus v1 packet to the console and automatically disconnects after 10 seconds.

Taking this example one step further you can add every incoming packet into a HeaderSet. HeaderSets keep a unique list of packets. A newer packet overwrites its older equivalent stored in the list.

    var headerSet = new vbus.HeaderSet();


    var onPacket = function(packet) {

        headerSet.addHeader(packet);

    };


    conn.on('connectionState', onConnectionStateChange);

    conn.on('packet', onPacket);


    conn.connect().done(function() {

        setTimeout(function() {

            conn.disconnect();


            var packets = headerSet.getSortedHeaders();


            console.log(packets);

        }, 10000);

    });


After ten seconds the list of unique packets is printed to the console. But it is still hard to see information in that raw data.

As the last step you can add a bit of code to decipher the binary VBus v1 payload into human readable form.

   conn.connect().done(function() {

        setTimeout(function() {

            conn.disconnect();


            var packets = headerSet.getSortedHeaders();


            var spec = vbus.Specification.getDefaultSpecification();


            var packetFields = spec.getPacketFieldsForHeaders(packets);


            var packet = null;

            packetFields.forEach(function(packetField) {

                if (packet !== packetField.packet) {

                    packet = packetField.packet;

                    console.log(packetField.packetSpec.fullName);

                }

                console.log('    ' + packetField.name + ' = ' + packetField.formatTextValue());

            });

        }, 10000);

    });


If you have any questions, don’t hesitate to ask :)

Best regards,
Reply all
Reply to author
Forward
0 new messages