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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@caseman72/tuya-api

v1.1.0

Published

Simple Tuya API client for local LAN control of smart climate devices

Readme

@caseman72/tuya-api

Simple Tuya API client for local LAN control of smart climate devices (mini-splits, AC units). No cloud dependency — communicates directly with devices over your local network using the Tuya protocol.

Installation

npm install @caseman72/tuya-api

Setup

Create a .tuya-devices.json file with your device configurations:

cp .tuya-devices.example.json .tuya-devices.json

Each device needs:

  • id — Tuya Device ID (from Tuya IoT Platform)
  • name — Friendly name
  • key — Local encryption key (from Tuya IoT Platform device details)
  • ip — Local LAN IP (optional, auto-discovered if omitted)
  • version — Protocol version ("3.4" for most modern devices)

The file is searched in:

  1. Current working directory
  2. ~/.config/tuya-api/.tuya-devices.json

Usage

import Tuya from '@caseman72/tuya-api';

const tuya = new Tuya();

// Get all device statuses
const statuses = await tuya.getAllStatuses();

// Control by name or ID
const status = await tuya.getStatus('Living Room');
await tuya.setPower('Living Room', true);
await tuya.setTemperature('Living Room', 72);
await tuya.setMode('Living Room', 'cool');     // 'heat' or 'cool'
await tuya.setFanSpeed('Living Room', 'auto');  // 'low', 'medium', 'high', 'auto'

// Raw DPS access
await tuya.setDps('Living Room', '4', 'cold');

// Scan device to discover DPS mapping
const scan = await tuya.scan('Living Room');

// Clean up
await tuya.disconnectAll();

Constructor Options

const tuya = new Tuya({
  devicesPath: '.',        // Path to search for .tuya-devices.json
  devices: [...]           // Or pass device configs directly
});

DPS Mapping

Tuya climate devices use numbered data points (DPS). The defaults work for most mini-splits:

| DPS | Function | Values | |-----|----------|--------| | 1 | Power | true/false | | 24 | Target Temp °F | Integer × 10 (e.g., 690 = 69.0°F) | | 23 | Current Temp °F | Integer | | 4 | Mode | "cold" / "hot" | | 5 | Fan Speed | "low" / "mid" / "high" / "auto" | | 19 | Temp Unit | "f" / "c" |

Override per-device in .tuya-devices.json with a dps object and temp_scale value.

License

MIT