-
-
Notifications
You must be signed in to change notification settings - Fork 20
VSCP Demo server
The demo server is located at https://demo.vscp.org You gave some simple demos here.
The VSCP demo MQTT server is located at mqtt.vscp.org It is to be used for demo purposes only. It can't be used for mission-critical tasks. Also https://test.mosquitto.org is available. A mirror is available at the test.mosquitto.org server )same topics as described below). Follow the link info about ports etc.
mqtt.vscp.org
tcp/ip port 1883 - no TLS, need authentication
tcp/ip port 8883 . TLS, need authentication
websocket port 9001 - no TLS, need authentication
websocket port 9901 - TLS, need authentication
username: vscp
password: secret
On Linux install mosquitto client package with
sudo apt install mosquitto-clients
After installation, you can subscribe to events published on all VSCP topics with
mosquitto_sub -u vscp -P secret -h mqtt.vscp.org -p 1883 -t vscp/#
or use
mosquitto_sub -u vscp -P secret -h mqtt.vscp.org -p 1883 -t vscp/25:00:00:00:00:00:00:00:00:00:00:00:06:01:00:01/1040/6/1/2/#
to get the current fridge temperature in our kitchen (60 second update interval).
Another command line alternative is to use MQTT.js. Install with
npm install mqtt --save
Info is here. Easy to use tool but (as it looks) apparently not developed anymore.
Not released yet but will have both general MQTT support and VSCP specific support.
Each VSCP daemon that publish events to the demo server is listed here. The GUID for the server identifies it and drivers and discovery gives information about running drivers on the daemon and nodes discovered by the daemon respectively. See the VSCP daemon documentation for more information about this content.
Under this topic events from nodes are available. The format for a typical measurement topic is
vscp/guid/vscp-class/vscp-type/node-id/data-byte-0
This give maximum flexibility for the client to filter out the events it is interested in. Byte zero of the data is set because for Level II measurements this byte holds the sensor index for the sensor on the remote node that the measurement value comes from. For other events - that is non measurement events - data byte zero may have some other meaning so check the VSCP spec when interpreting event.
For the demo server the Grodans Paradis AB assigned GUID
25:00:00:00:00:00:00:00:00:00:00:00:Y1:Y2:XX:XX
is used as a basis for all GUID's. A driver use the two LSB bytes (XX:XX above) for it's own use as node id's (nickname id's). The Y1:Y2 byte s are used for devices and drivers. Y1 is server specific, each server has a different value here. The Y2 byte is zero for the server itself and 1-255 for drivers. Btw you can request your own GUID series by sending a mail to [email protected] or use one of the available series.
note: The above is the schema we use in our house. You are free to setup any schema you like in your own setup of course. There is millions of possibilities.
So here is a list of the events and GUID's you may see on the vscp/# topic. I will add to this list as we go.
The following is a python sample using the paho.mqtt library. It subscribes to events from some PIR and door sensors that send CLASS1.INFORMATION ON/OFF events when triggered. Sensor index is in the first byte, and you can find more information about which sensor is which here
If you subscribe to
client.subscribe("vscp/25:00:00:00:00:00:00:00:00:00:00:00:0D:02:00:01/15/1/#", 0)
you will get a CLASS1.DATA, I/O event each second that holds the current state for the sensors.
Two ways to get the same information.
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
A simple VSCP demo server MQTT subscriber
"""
import paho.mqtt.client as paho
def on_message(mosq, obj, msg):
print("%-20s %d %s" % (msg.topic, msg.qos, msg.payload))
mosq.publish('pong', 'ack', 0)
def on_publish(mosq, obj, mid):
pass
if __name__ == '__main__':
client = paho.Client()
client.on_message = on_message
client.on_publish = on_publish
client.username_pw_set(username="vscp", password="secret")
#client.tls_set('root.ca', certfile='c1.crt', keyfile='c1.key')
client.connect("mqtt.vscp.org", 1883, 60)
client.subscribe("vscp/25:00:00:00:00:00:00:00:00:00:00:00:0D:02:00:01/20/3/#", 0) // ON
client.subscribe("vscp/25:00:00:00:00:00:00:00:00:00:00:00:0D:02:00:01/20/4/#", 0) // OFF
#client.subscribe(""vscp/25:00:00:00:00:00:00:00:00:00:00:00:0D:02:00:01/15/1/#",0) // Sensor state
while client.loop() == 0:
pass
# vi: set fileencoding=utf-8 :
This sample subscribes to a temperature event for the garage that is sent from the sensor every minute. See the code for mor info.
/*
This sample connects to the VSCP demo mqtt server and subscribe to events from a
sensor located in the upper floor of the garage.
GUID info is here https://github.com/grodansparadis/vscp/wiki/VSCP-Demo-GUID%27s#raspberry-pi-3
https://www.npmjs.com/package/paho-mqtt
https://www.emqx.com/en/blog/how-to-use-mqtt-in-nodejs
https://www.hivemq.com/blog/ultimate-guide-on-how-to-use-mqtt-with-node-js/
*/
/*
if using browser
import fs from 'fs';
import mqtt from 'mqtt';
*/
const fs = require('fs');
const mqtt = require('mqtt');
const options = {
username: "vscp",
password: "secret",
protocol: 'mqtt',
host: 'mqtt.vscp.org',
port: 1883
/*
If using SSL
ca: [fs.readFileSync('/path/to/ca.crt')],
cert: fs.readFileSync('/path/to/client.crt'),
key: fs.readFileSync('/path/to/client.key')
*/
};
// Temperature garage upper (~every minute)
// 25:00:00:00:00:00:00:00:00:00:00:00:05:01:00:02 = GUID for sensor
// 1040 = measurements
// 6 = temperature
// 2 = node id (nickname, same as GUID LSB)
// 0 = sensor index
const topic = "vscp/25:00:00:00:00:00:00:00:00:00:00:00:05:01:00:02/1040/6/2/0/#";
console.log("Connecting to MQTT broker...");
const client = mqtt.connect(options);
client.on('connect', () => {
console.log('Connected to MQTT broker.')
client.subscribe([topic], () => {
console.log(`Subscribe to topic '${topic}'`)
})
})
client.on('message', (topic, payload) => {
console.log('Received Message:', topic, payload.toString())
})
// called when the client loses its connection
client.on('connectionlost', (responseObject) => {
if (responseObject.errorCode !== 0) {
console.log("onConnectionLost:"+responseObject.errorMessage);
}
})
// client.on('auth', (packet, cb) => {
// console.log('Authenticating with certificate...');
// // Check the certificate properties and perform the authentication logic here.
// // Call cb() with an error if authentication fails or null if it succeeds.
// cb(null);
// });
Live data is currently pushed from the following sources.
- VSCP events from Pi1 - Misc sensing (inside/outside temperature).
- VSCP events from Pi2 - Misc sensing (inside/outside temperature).
- VSCP events from Pi3 - Weather station data.
- VSCP events from Pi4 - Fridge and refrigerator control in our kitchen.
- VSCP events from Pi5 - Furnace control and water usage in our house.
- VSCP events from Pi6 - Electrical usage.
- VSCP events from Pi11 - Door and PIR sensors.
The VSCP Project (https://www.vscp.org) - Copyright © 2000-2024 Åke Hedman, the VSCP Project