This library provides a TypeScript client for interacting with Winix devices. It includes classes for authenticating
with the Winix API (WinixAuth
), managing a user account (WinixAccount
), as well as interacting with Winix devices
(WinixAPI
).
This library is a Node.js module. You can install it using npm:
npm install winix-api
or yarn:
yarn add winix-api
The WinixAuth
class is used for authenticating with the Winix API. You can use it to log in with a username and
password, or to refresh an existing session.
import { WinixAuth, WinixAuthResponse } from 'winix-api';
// Log in with a username and password
const auth: WinixAuthResponse = await WinixAuth.login('<username>', '<password>');
// Refresh an existing session
const refreshedAuth: WinixAuthResponse = await WinixAuth.refresh('<refreshToken>', '<userId>');
The WinixAccount
class is used for managing a user account. You can use it to get a list of devices associated with
the account.
import { WinixAccount, WinixExistingAuth } from 'winix-api';
// Create a WinixAccount from credentials
const account: WinixAccount = await WinixAccount.fromCredentials('<username>', '<password>');
// Create a WinixAccount from existing auth credentials
const existingAuth: WinixExistingAuth = {
username: '<username>',
userId: '<userId>',
refreshToken: '<refreshToken>',
};
const accountFromExistingAuth: WinixAccount = await WinixAccount.fromExistingAuth(existingAuth);
// Get a list of devices associated with the account
const devices = await account.getDevices();
import { Airflow, AirQuality, Mode, Plasmawave, Power, WinixAPI } from 'winix-api'
// Assume this is defined throughout the examples
const deviceId = 'ABCDEF012345_abcde01234';
const power: Power = await WinixAPI.getPower(deviceId);
console.log('off?:', power === Power.Off);
// Set power on
await WinixAPI.setPower(deviceId, Power.On);
const mode: Mode = await WinixAPI.getMode(deviceId);
console.log('manual?:', mode === Mode.Manual);
// Set to auto
await WinixAPI.setMode(deviceId, Mode.Auto);
const airflow: Airflow = await WinixAPI.getAirflow(deviceId);
console.log('turbo?:', mode === Mode.Turbo);
// Set to low
await WinixAPI.setAirflow(deviceId, Airflow.Low);
const airQuality: AirQuality = await WinixAPI.getAirQuality(deviceId);
console.log('quality:', airQuality);
const plasma: Plasmawave = await WinixAPI.getPlasmawave(deviceId);
console.log('plasmawave on?:', plasma === Plasmawave.On);
// Set to off
await WinixAPI.setPlasmawave(deviceId, Plasmawave.Off);
const ambientLight: number = await WinixAPI.getAmbientLight(deviceId);
console.log('ambientLight:', ambientLight);