Title
Message
Create new category
What is the title of your new category?
Edit page index title
What is the title of the page index?
Edit category
What is the new title of your category?
Edit link
What is the new title and URL of your link?
Subscribe to Events
Copy Markdown
Open in ChatGPT
Open in Claude
To subscribe to events from a device, connect to the MQTT API and subscribe it to the events topic for that device.
To subscribe to all events the MQTT topic is:
devices/{device.id}/events/+
To subscribe to a specific event the MQTT topic is:
devices/{device.id}/events/{event.name}
Replace {device.id} with your device ID (should begin with dev_) and {event.name} with the name of the event you wish to subscribe to.
Example Code
Subscribe to all events using the Wia SDK
Javascript
x
// Create an instance of Wia// Replace 'd_sk_abcdef' with your device secret keyvar wia = require('wia')('d_sk_abcdef');// Subscribe to all events for a device// Replace 'dev_abc123' with your device IDwia.events.subscribe({ device: 'dev_abc123'}, function(event) { console.log(event);});// Connect to the MQTT APIwia.stream.connect();Subscribe to only temperature events using the Wia SDK
Javascript
// Create an instance of Wia// Replace 'd_sk_abcdef' with your device secret keyvar wia = require('wia')('d_sk_abcdef');// Subscribe to just 'temperature' events for a device// Replace 'dev_abc123' with your device IDwia.events.subscribe({ device: 'dev_abc123', name: 'temperature'}, function(event) { console.log(event);});// Connect to the MQTT APIwia.stream.connect();Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard
Last updated on
Next to read:
Publish a LocationDiscard Changes
Do you want to discard your current changes and overwrite with the template?
Archive Synced Block
Message
Create new Template
What is this template's title?
Delete Template
Message