signalk-tuya
v1.0.5
Published
Tuya WiFi sockets as native Signal K — switch state, metering and control over the local LAN protocol 3.3. No MQTT, no cloud in the control path.
Maintainers
Readme
signalk-tuya
Control and monitor Tuya / Smart Life WiFi sockets from Signal K over the local LAN protocol (3.3) — no cloud in the control path.
What it does
- LAN-only control. Switching and reading go direct to the socket (tcp/6668) with its local key; works with the internet unplugged. The cloud is used only to fetch those keys, and only if you give it credentials.
- State + metering. Publishes
<basePath>.state, plus.power/.voltage/.currentfor plugs that meter (only when the device reports them). - PUT control. A Signal K PUT to
<basePath>.statethrows the relay. - Drops cleanly. After a few failed polls a socket's paths go to no-data rather than reading stale.
- Autodiscovery. A LAN scan fills the Device dropdown, so you pick a socket instead of typing an id.
Requirements
- A Signal K server.
tinytuyaon the host.python3andpip3are already in the official Docker image; you only installtinytuya— see INSTALL.md.- A free Tuya IoT Platform developer account (iot.tuya.com) — not your Smart Life login — to fetch each socket's local key. Its cloud project runs on a free trial that expires and must be renewed to keep fetching keys; once keys are cached the plugin runs without it.
- The host must be on the sockets' LAN and able to broadcast to them.
Install
Signal K Appstore (search signalk-tuya), or by hand:
cd ~/.signalk/node_modules && npm install signalk-tuyaInstall tinytuya (INSTALL.md has the per-platform detail) and
restart the server.
Configure (admin UI)
Server → Plugin Config → Tuya WiFi sockets, enable it.
- Tuya IoT cloud. Enter the Access ID, Access Secret and region of a Tuya IoT cloud project — the plugin fetches and caches each socket's local key (see Getting the local keys).
- Sockets. One row each: pick the Device from the dropdown (or paste an
id), and a Signal K path (e.g.
electrical.switches.tuya.fan—.state/.power/.voltage/.currentare appended). Leave IP blank unless the scan can't see it. - python3 executable — blank uses
python3fromPATH; set it for a virtualenv.
The status line says what it is waiting for.
Getting the local keys
A Tuya device needs its local key, which comes from Tuya, not the network. Either:
- Let the plugin fetch them — create a free cloud project at https://iot.tuya.com, link your Smart Life account, and paste its Access ID / Access Secret into the config.
- Run
tinytuya wizard(python3 -m tinytuya wizard) and supply the keys. Its guide covers the cloud project: https://github.com/jasonacox/tinytuya#setup-wizard---getting-local-keys
Keys are cached (mode 0600) in the plugin data directory, so they survive
upgrades. Once cached the cloud credentials are optional.
Architecture
index.js spawns plugin.py and pipes its deltas into Signal K; all Tuya logic
— tinytuya, the per-device lock Tuya's id-less protocol needs, socket rebuild,
stale-echo avoidance — lives in plugin.py. The sk-plugin-python-demo pattern.
Troubleshooting
| Status / symptom | What it means |
| --- | --- |
| Python module 'tinytuya' is not installed… | Install it against the python3 Signal K uses, or set python3 executable. See INSTALL.md. |
| No sockets configured | Add a row under Sockets. |
| … with no local key | Add Tuya IoT cloud credentials, or seed the cache with tinytuya wizard. |
| … not seen by the LAN scan yet | The socket is off, on another subnet, or broadcast is blocked. Set its IP by hand. |
| Tuya cloud rejected the credentials | Check the Access ID/secret, and that the region matches your project's data centre. |
| Device dropdown is empty | No scan has completed yet — wait ~60 s and reload. |
License
MIT.
