This project should be used in combination with a server, such as node-velbus-server.
Using Raspbian Jessie Lite (download, installation, expand filesystem, update, static IP address)
# add nodejs repository
echo 'deb https://deb.nodesource.com/node_4.x jessie main' | sudo tee --append /etc/apt/sources.list.d/nodesource.list
# add nodejs repository key
wget -qO- https://deb.nodesource.com/gpgkey/nodesource.gpg.key | sudo apt-key add -
# enable https repositories
sudo apt-get install apt-transport-https
# update installation sources
sudo apt-get update
# install nodejs
sudo apt-get install nodejs
# update installation sources
sudo apt-get update
# install git
sudo apt-get install git
# clone this project
git clone https://github.com/pdpotter/node-velbus-client.git
# install dependencies
$(cd node-velbus-client; npm install)
# install initial config
$(cd node-velbus-client/server; cp config.sample.js config.js)
If node-velbus-client is running as a daemon (see below), stop the daemon before updating and start it again after updating.
# update node-velbus-client
$(cd node-velbus-client; git pull)
# update dependencies
$(cd node-velbus-client; npm install)
The client can be configured by editing the settings in node-velbus-client/server/config.js
. The default settings are:
(function() {
exports.server = {
port: 8080
};
exports.layout = {
'living-room': {
name: 'Living room',
components: [
{
name: 'Lights',
address: '01',
channel: '1',
module: 'VMB4RYNO'
}, {
name: 'Fan',
address: '01',
channel: '2',
module: 'VMB4RYNO'
}
]
},
kitchen: {
name: 'Kitchen',
components: [
{
name: 'Lights',
address: '01',
channel: '3',
module: 'VMB4RYNO'
}, {
name: 'Fan',
address: '01',
channel: '4',
module: 'VMB4RYNO'
}
]
}
};
}).call(this);
The port at which the client will be reachable is can be changed by editing the
server.port
setting (the default value is 8080
).
The available components can be defined by editing the layout
setting.
The components must be organized in categories, which are identified by a
machine name, that will be used as a url path. Each category must have a
(human readable) name
and components
.
Each component must have a (human readable) name
, an address
(the address on
the bus) and a module
(the Velbus module type). If a module has multiple
channels, a channel
must be defined as well.
The server that will receive the commands from the node-velbus-client and
transform them to Velbus commands can be configured by editing
node-velbus-client/public/js/config.js
. The default settings are:
var node_velbus_client_config = {
server: {
protocol: 'ws',
host: '127.0.0.1',
port: 8001
}
};
The server.host
setting should be changed to the IP address op the Raspberry,
which can be obtained by executing
ifconfig eth0 | grep "inet addr:"
The IP address consists of the four decimal numbers (with dots) following inet addr:
.
(based on init-script-template)
If node-velbus-client was not installed in the home directory of the pi user,
update the dir
setting on line 12 in
node-velbus-client/daemon/node-velbus-client
accordingly.
# copy daemon file
sudo cp node-velbus-client/daemon/node-velbus-client /etc/init.d
# make it executable
sudo chmod 755 /etc/init.d/node-velbus-client
To start the daemon, execute
sudo /etc/init.d/node-velbus-client start
To stop the daemon, execute
sudo /etc/init.d/node-velbus-client stop
To run the daemon on startup, execute
sudo update-rc.d node-velbus-client defaults