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

homebridge-tuya-watering

v1.0.0

Published

Control Tuya watering and irrigation devices locally (tuya-local protocol) with optional cloud fallback.

Readme

homebridge-tuya-watering

A Homebridge plugin that exposes Tuya watering and irrigation devices to HomeKit — local-first over the tuya-local protocol (no cloud round trip for control), with an optional per-device cloud fallback for low-power firmwares that do not support LAN control at all.

Features

  • Local control via tuyapi (protocol 3.1–3.5), with persistent connections, event-driven state, exponential reconnect backoff and automatic IP re-resolution when DHCP moves a device.
  • Cloud fallback through the Tuya OpenAPI for deep-sleep battery devices that never open a local port.
  • Generic DP mapping — no hardcoded models. Any watering device can be described in config: switch DP, duration DP (seconds or minutes), battery, leak/rain sensors, multi-zone selectors.
  • HomeKit-native services: Valve (irrigation type) for single-outlet devices, IrrigationSystem with linked zone valves for multi-zone devices, SetDuration/RemainingDuration with live countdown, battery level and low-battery alerts, leak and rain sensors.
  • Import wizard (custom UI) in Homebridge Config UI X: scans the LAN, enumerates every device on your Tuya account (keys included — you never type a device ID or local key), fetches each device's DP model and auto-generates the config mapping.

Requirements

  • A Tuya IoT Platform cloud project (iot.tuya.com) linked to your Smart Life / Tuya Smart app account. The project's Access ID / Access Secret power the import wizard and cloud-mode devices. This is the only way Tuya exposes device local keys; a plain app login cannot retrieve them.
  • Devices you want to control locally must be reachable on the same LAN as Homebridge.

Installation

npm install -g homebridge-tuya-watering

Then open the plugin settings in Homebridge Config UI X, enter your cloud credentials and run Import devices.

Configuration

The custom UI generates this for you; shown here for reference and manual editing.

{
  "platform": "TuyaWatering",
  "cloud": { "accessKey": "…", "secretKey": "…", "region": "us" },
  "pollInterval": 60,
  "debugMode": false,
  "devices": [
    {
      "id": "…",
      "name": "Balcony",
      "type": "valve",
      "connection": { "mode": "local", "ip": "…", "localKey": "…", "version": "3.5" },
      "switchDp": "1",
      "duration": { "dp": "11", "unit": "seconds", "max": 3600, "defaultSeconds": 240 },
      "battery": { "dp": "7", "lowThreshold": 20 },
      "sensors": [{ "type": "leak", "dp": "101", "activeValue": true }]
    }
  ]
}

Device fields

| Field | Description | |---|---| | type | valve (single outlet) or irrigation (multi-zone system) | | openMode | switch (default): a boolean DP opens/closes. durationTrigger: writing seconds to the duration DP starts a run, 0 stops it; running state derives from the live remaining DP | | connection.mode | local (requires ip, localKey, version) or cloud | | switchDp | Master on/off DP (switch mode) | | zones | Zone list for irrigation; each zone may carry its own switchDp (independent outlets) | | zoneSelector | Shared-pump paradigm: enum DP selecting the outlet(s); map keys are comma-joined 1-based zone indexes ("1", "1,2") | | duration | dp, unit (seconds/minutes), max (device units), remainingDp (live countdown DP), defaultSeconds | | battery | dp, lowThreshold, optional chargingDp | | sensors | type (leak/rain/contact), dp, activeValue, optional name | | beforeOpen / afterClose | Extra DP writes merged into the open/close frames (e.g. switching a dual-pump device to manual mode and back) | | sequentialWrites | Send one DP per frame, in order, for firmwares that mishandle multi-DP frames |

Firmware quirks this plugin handles

  • sfkzq timers: writing the countdown DP (re)starts watering — even in the same frame as switch: false. Close frames therefore never carry the duration DP, and SetDuration changes are only written at open time. These devices also do not decrement their countdown DP while running, so RemainingDuration is driven by a local timer.
  • Dual-pump wk-category controllers: the switch DP only arms the built-in weekly schedule. Manual runs are triggered by writing seconds to the runtime DP (in manual mode) and stopped by writing 0; a separate DP reports the live countdown. Use openMode: "durationTrigger" — the import wizard detects this pattern automatically. The device's own schedule keeps working: the plugin restores auto mode after every run.
  • Deep-sleep battery devices (e.g. LYAI-17): cloud-online but never reachable on the LAN, even when awake. Use connection.mode: "cloud".

Notes

  • HomeKit caps SetDuration at 3600 s; devices accepting longer runs are clamped to one hour.
  • Tuya firmwares accept a single local TCP client. Don't point two local-protocol integrations at the same device.

Development

npm install
npm run build        # tsc → dist/
npm run lint
npm run smoke:local -- --id <id> --ip <ip> --key <key> --version 3.3
npm run smoke:cloud -- --id <id>   # TUYA_ACCESS_KEY / TUYA_SECRET_KEY env

License

Apache-2.0