Publish an Event
Events are interactions from your device e.g. temperature, humidity, door opened, etc.
To send an event to Wia, connect to the MQTT API and publish it to the events topic.
The events MQTT topic is:
events
or devices/{DEVICE_ID}/events/{EVENT_NAME}
Example code
Publish an Event using the Wia SDK
x
// Create an instance of Wia
// Replace 'd_sk_abcdef' with your device secret key
var wia = require('wia')('d_sk_abcdef');
// Listen for a successful connection to the MQTT API
wia.stream.on('connect', function() {
// Publish an event
wia.events.publish({
name: 'temperature',
data: 21.5
});
});
// Connect to the MQTT API
wia.stream.connect();