Welcome to the Web API documentation ๐
๐ Learn how to build great integrations for Homey Pro & Homey Cloud.
Creating a Web API Client
Example
const AthomCloudAPI = require('homey-api/lib/AthomCloudAPI');
// Create a Cloud API instance
const cloudApi = new AthomCloudAPI({
clientId: '...',
clientSecret: '...',
});
// Get the logged in user
const user = await cloudApi.getAuthenticatedUser();
// Get the first Homey of the logged in user
const homey = await user.getFirstHomey();
// Create a session on this Homey
const homeyApi = await homey.authenticate();
// Loop all devices
const devices = await homeyApi.devices.getDevices();
for(const device of Object.values(devices)) {
// Turn device on
await device.setCapabilityValue({ capabilityId: 'onoff', value: true });
}
// Connect to receive realtime events
await homeyApi.devices.connect();
homeyApi.devices.on("device.delete", (device) => {
// Device deleted
});
homeyApi.devices.on("device.update", (device) => {
// Device updated
});
homeyApi.devices.on("device.create", (device) => {
// Device created
});๐ฅ Community
Last updated
Was this helpful?