npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

winix-api

v1.5.3

Published

Winix device API client library

Downloads

74

Readme

winix-api

npm

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).

Installation

This library is a Node.js module. You can install it using npm:

npm install winix-api

or yarn:

yarn add winix-api

Usage

Authentication

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>');

Managing a User Account

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();

Interacting with a Device

import { Airflow, AirQuality, Mode, Plasmawave, Power, WinixAPI } from 'winix-api'

// Assume this is defined throughout the examples
const deviceId = 'ABCDEF012345_abcde01234';

Get and set the Power state

const power: Power = await WinixAPI.getPower(deviceId);
console.log('off?:', power === Power.Off);

// Set power on
await WinixAPI.setPower(deviceId, Power.On);

Get and set the Mode

const mode: Mode = await WinixAPI.getMode(deviceId);
console.log('manual?:', mode === Mode.Manual);

// Set to auto
await WinixAPI.setMode(deviceId, Mode.Auto);

Get and set the Airflow speed

const airflow: Airflow = await WinixAPI.getAirflow(deviceId);
console.log('turbo?:', mode === Mode.Turbo);

// Set to low
await WinixAPI.setAirflow(deviceId, Airflow.Low);

Get the Air Quality

const airQuality: AirQuality = await WinixAPI.getAirQuality(deviceId);
console.log('quality:', airQuality);

Get and set the Plasmawave state

const plasma: Plasmawave = await WinixAPI.getPlasmawave(deviceId);
console.log('plasmawave on?:', plasma === Plasmawave.On);

// Set to off
await WinixAPI.setPlasmawave(deviceId, Plasmawave.Off);

Get the Ambient Light

const ambientLight: number = await WinixAPI.getAmbientLight(deviceId);
console.log('ambientLight:', ambientLight);