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

@lnowakowski/node-red-contrib-tuya-simple

v1.0.0

Published

Tuya Cloud integration for controlling compatible smart home/IoT devices

Downloads

836

Readme

node-red-contrib-tuya-simple

Node-RED Node.js License: MIT

A set of Node-RED nodes for integrating with the Tuya Cloud OpenAPI to monitor and control compatible smart home / IoT devices.

Features

  • Fetch real-time device status (data points / DPs)
  • Send commands to control devices
  • Supports multiple Tuya data center regions (EU, US, CN, IN)
  • Dynamic Device ID via msg, flow/global context, or environment variables
  • Secure credential storage using Node-RED's built-in credentials system

Prerequisites

  1. A Tuya IoT Platform account with a Cloud Project created
  2. The Access Key (Client ID) and Secret Key (Client Secret) from your project
  3. Devices linked to your Tuya project
  4. Node-RED >= 4.0.0 running on Node.js >= 20

Installation

Install via the Node-RED Manage Palette menu, or from your Node-RED user directory:

npm install @lnowakowski/node-red-contrib-tuya-simple

Restart Node-RED after installation.

Nodes

tuya project config

A configuration node that stores your Tuya Cloud project credentials and API endpoint.

| Property | Description | |----------|-------------| | Access Key | The Access ID / Client ID from your Tuya IoT Platform project | | Secret Key | The Access Secret from your Tuya IoT Platform project | | API endpoint | Regional data center — Central Europe, Western America, China, or India |

Credentials can be found on Tuya Developer Platform under your Cloud ProjectOverview section.


tuya fetch status

Fetches the current status of a device identified by its Device ID.

The Device ID can be provided as a static string or resolved dynamically from msg, flow context, global context, or an environment variable.

Output

msg.payload will contain:

{
    "deviceId": "bfd9163d4d...",
    "status": {
        "result": [
            { "code": "switch", "value": false },
            { "code": "battery_percentage", "value": 100 },
            { "code": "work_state", "value": "idle" }
        ],
        "success": true,
        "t": 1786011909023,
        "tid": "1977bdaa918111f1b7ee..."
    }
}

tuya send commands

Sends one or more commands to a device identified by its Device ID.

The input msg.payload must contain a valid Tuya command object:

{
    "commands": [
        { "code": "switch", "value": true },
        { "code": "weather_delay", "value": "cancel" },
        { "code": "countdown", "value": 0 }
    ]
}

Output

msg.payload will contain the Tuya API response indicating success or failure.

Finding command codes

The proper payload for commands can be discovered by:


Example Flow

An example flow is included in the examples/ folder and is available in the Node-RED editor under ImportExamples@lnowakowski/node-red-contrib-tuya-simple.

The example demonstrates:

  • Fetching device status using a Device ID from msg.topic
  • Sending commands with a JSONata-generated payload

Error Handling

If an API call fails (invalid credentials, unreachable endpoint, unknown device ID, or malformed commands), the node logs the error to the Node-RED debug sidebar. No output message is sent on failure.

To handle errors in your flow, you can use a Catch node scoped to the Tuya nodes.

API Details

This package uses the Tuya Cloud OpenAPI v1.0 endpoints:

| Operation | Method | Endpoint | |-----------|--------|----------| | Get token | GET | /v1.0/token?grant_type=1 | | Fetch status | GET | /v1.0/devices/{deviceId}/status | | Send commands | POST | /v1.0/devices/{deviceId}/commands |

Authentication uses HMAC-SHA256 request signing as per the Tuya API signing documentation.

License

MIT

Links