overkiz-api
TypeScript icon, indicating that this package has built-in type declarations

2.0.1 • Public • Published

overkiz-api

npm version npm downloads

overkiz-api is a Node.js library that implements the Overkiz IoT API

Installation

npm install --save overkiz-api

Some usage

Retrieves all house

async function fetchAllHouse(): Promise<Setup> {
    const api: API = new API({
        host: 'ha110-1.overkiz.com', // Cozytouch host
        platformLoginHandler: new CozytouchLoginHandler(
            'XXX', // your user account
            'XXX'  // your password
        ),
        polling: {
            always: false,
            interval: 1000
        }
    });
    return api.getSetup();
}

// Execute the task
fetchAllHouse()
    .then(console.log)
    .catch(console.error)

Get all devices of type 'WaterHeatingSystem'

async function getAllWaterHeatingSystem(): Promise<APIObject[]> {
    const api: API = new API({
        host: 'ha110-1.overkiz.com', // Cozytouch host
        platformLoginHandler: new CozytouchLoginHandler(
            'XXX', // your user account
            'XXX'  // your password
        ),
        polling: {
            always: false,
            interval: 1000
        } 
    });
    const objects: APIObject[] = await api.getObjects();
    return objects.filter((o) => o.uiClass === 'WaterHeatingSystem');
}
// Execute the task
getAllWaterHeatingSystem()
    .then(console.log)
    .catch(console.error)

Change device name

async function changeName(): Promise<boolean> {
    const objects: APIObject[] = await getAllWaterHeatingSystem(); // call the previous function
    const obj = objects.find((o) => o.hasCommand('setName'));
    if(obj !== undefined) {
        return obj.exec({
            name: 'setName',
            parameters: [
                'HelloWorld'
            ]
        });
    }
    return false;
}
// Execute the task
changeName()
    .then(console.log)
    .catch(console.error)

Readme

Keywords

Package Sidebar

Install

npm i overkiz-api

Weekly Downloads

19

Version

2.0.1

License

BSD

Unpacked Size

84.1 kB

Total Files

67

Last publish

Collaborators

  • bbriatte