Tuya
Tuya is a provider of smart devices such as LED lamps, power switches and other devices. These devices can be controlled by a Tuya app but Tuya also supports an API for controlling these devices by other applications. The Tuya integration is a bi-directional integration allowing you to read values from sensors and controls switches and lights. The integration is implemented as a Docker web service and uses the open source @tuya/tuya-connector-nodejs package.
Web service
To install the Tuya web service on your local cluster run:
helm install tuya spacetime/tuya
Datasource
For the Tuya service you need an access key and a secretKey. You can obtain these keys via a free registration as a Tuya cloud developer. In the field service
enter the hostname of where the Tuya webservice is running locally. The field baseUrl
specifies the data center where your devices are registered.
Connector
In the connector specify the secret that contains the Tuya data source and add a mapping for each device. The object ID is the ID of the device, which can be obtained via the Tuya app or developer web site. The mapping for the color maps a JSON object {h: <number>, s:<number>, v:<number>}
to the internal color representation of an array of three numbers.
The exporter maps the intenal value of 0
and 1
for the switch to the values switch_1: true
and switch_1: false
. The interal color definition of an array of three numbers representing hue, saturation and brightness is converted to a JSON object {h: 100, s: 200, v: 300}
for the field colour_data
.
Form
To test changing the color of a Tuya enabled light bulb create the following form:
Reception panel
led.color:Color
|12
Search for item office.htc.reception
and click on the item. If you change the color on the color wheel the color of the light should change.
Wifi and Zigbee
By default Tuya supports devices via WiFi but this is less suited for battery operated devices such as motion detectors or temperature sensors. Zigbee offers a more energy efficient alternative to WiFi. You can integrate Zigbee devices within Tuya via a Tuya Zigbee gateway. First register the Gateway with the Tuya App by connecting to the Gateway to a LAN. Make sure you enable the local network in the app, otherwise the gateway will not be discovered. After the gateway is installed you can add Zigbee 3.0 devices. When these are set in pairing mode they can automatically be discovered via the Tuya app.