tuyaha-mqtt
v0.4.0-alpha.1
Published
Interacts with Tuya Cloud for your devices, publishes state changes over MQTT and allows control of device state by sending MQTT messages.
Readme
tuyaha-mqtt
NOTE: UNSTABLE TRIAL VERSION - USING API AS PER HOMEBRIDGE PLUGIN
BREAKING MQTT API CHANGE FROM PREVIOUS VERSION.
Somewhat replicates the homebridge plugin tuya-homebridge, but strips out all the accessory stuff and replaces it with a simple MQTT interface.
Very early version. Quite untested.
Also wanted to look into using https://github.com/tuya/tuya-connector-nodejs but limited documentation.
Configuration
This uses mqtt-usvc which can be configured using a YAML file, environment variables, or using Consul KV.
Example config YML:
mqtt:
# URL to connect to MQTT server on
uri: mqtt://user:[email protected]
# Prefix for inbound/outbound MQTT topic
prefix: tuya
service:
region: "us" # cn, eu, us. choose the closest.
countryCode: "1" # Your account country code, e.g., 1 for USA or 86 for China
bizType: "smart_life" # tuya, smart_life, etc
username: "[email protected]" # Could also be a phone number
password: "yourpassword" # suggest creating a service account for this and not using your main accountNotes
I have to disable IPv6 to use this (or the homebridge plugin). Likely has more to do with my ISP that anything else.
Events Published (Output)
Assuming using a prefix of tuya any device discovered is emitted on tuya/status/{device_id}.
Any status change is emitted on tuya/status/{device_id}/{status_code}.
If the service is started all devices will have their current statuses re-emitted.
Command Events (Input)
Assuming using a prefix of tuya you can change state via commands sent to tuya/set/{device_id}/{command_code}. with a value of the desired new state.
TBD: allow sending multiple commands in a single message.
