Skip to content

bbriatte/overkiz-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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)

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published