Homey Web API Client

3.18.2 · active · verified Tue Apr 21

homey-api is the official JavaScript client for Athom's Homey Web APIs, providing programmatic access to Homey Pro and Homey Cloud devices. It is actively maintained with the current stable version being 3.18.2, and new releases typically coincide with API updates or bug fixes. The library supports various JavaScript environments including Node.js (requiring Node.js >=24), browsers (via CDN or bundlers), and React Native, as well as specialized in-app usage for Homey Pro. Key differentiators include its official status, comprehensive TypeScript type definitions, and direct support for both local network (Homey Pro) and cloud-based (Homey Cloud) API interactions. Developers must obtain OAuth2 client credentials from Athom to interact with the Web API.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates how to connect to a local Homey Pro device using a personal access token and list all connected devices. This requires a `.env` file with `HOMEY_ADDRESS` and `HOMEY_TOKEN`.

import { HomeyAPI } from 'homey-api';
import 'dotenv/config'; // For loading environment variables

const HOMEY_ADDRESS = process.env.HOMEY_ADDRESS ?? 'http://192.168.1.100'; // e.g., 'http://192.168.1.100:80'
const HOMEY_TOKEN = process.env.HOMEY_TOKEN ?? ''; // Personal Access Token from Homey Web App

if (!HOMEY_TOKEN) {
  console.error('HOMEY_TOKEN environment variable is not set. Please create a .env file or set it directly.');
  process.exit(1);
}

async function connectAndListDevices() {
  try {
    console.log(`Attempting to connect to Homey at ${HOMEY_ADDRESS}...`);
    const homeyApi = await HomeyAPI.createLocalAPI({
      address: HOMEY_ADDRESS,
      token: HOMEY_TOKEN,
    });

    console.log('Successfully connected to Homey!');

    const devices = await homeyApi.devices.getDevices();
    console.log('--- Connected Devices ---');
    if (Object.keys(devices).length === 0) {
      console.log('No devices found.');
    } else {
      for (const deviceId in devices) {
        const device = devices[deviceId];
        console.log(`ID: ${deviceId}, Name: ${device.name}, Class: ${device.class}`);
      }
    }

    await homeyApi.disconnect();
    console.log('Disconnected from Homey.');

  } catch (error) {
    console.error('Failed to connect or retrieve devices:', error instanceof Error ? error.message : error);
    console.error('Please ensure Homey is reachable at the specified address and the token is valid.');
  }
}

connectAndListDevices();

view raw JSON →