!! THIS REPOSITORY IS NOT ACTIVELY MAINTAINED ANYMORE, PLEASE FEEL FREE TO CREATE FORK !!
CLI tools for using Tuya Web API
This tool is created to extend the implementation of Homebridge plugin homebridge-tuya-web
as there are issues and request to implement more devices. The Tuya firmware is implemented in thousands of devices and therefor it is impossible that one person has all the devices to test/debug. This tool will help with understanding which output is generated by the Tuya Web API to test and debug new features.
To use this tool you need to do the following actions:
- Download or clone this repository.
- Open folder in a termimal containing the downloaded or cloned repository.
- Run
npm i
to install dependency modules.
- Discover devices
- Get device state
node <function> --username <username> --password <password> [--country <countrycode>] [--platform <platform>] [<params>]
- function: Required. One of the implemented functions;
discover
,getstate
. - username: Required. The username for the account that is registered in the Android/iOS App.
- password: Required. The password for the account that is registered in the Android/iOS App.
- country: Optional, default is 31. Your account country code, e.g., 1 for USA, 31 for NL or 86 for China. This is optional as any country code will work, but can be slower due to larger distance to Tuya servers.
- platform: Optional, default is
tuya
. The App where your account is registered.tuya
for Tuya Smart,smart_life
for Smart Life orjinvoo_smart
for Jinvoo Smart. - params: Optional or required, depending on function. See function description below for more details.
node discover --username [email protected] --password xxxxx --country 31 --platform smart_life
This function outputs the Tuya devices that are registered in the official Tuya, Smart Life or other partner platforms.
Run the following command in a terminal.
node discover --username <username> --password <password> [--country <countrycode>] [--platform <platform>]
Discovering Tuya devices...
Login successful.
Discovered devices:
[ { data: { online: true, state: false },
name: 'Switch 5',
icon: 'https://images.tuyaeu.com/smart/icon/socket_new2.png',
id: 'xxxxxxxxxxxxxxx',
dev_type: 'switch',
ha_type: 'switch' },
{ data: { brightness: '89', online: true, state: 'false' },
name: 'Dimmer 1',
icon: 'https://images.tuyaeu.com/smart/icon/15548239257ypxzpm4qgx_0.jpg',
id: 'xxxxxxxxxxxxxxx',
dev_type: 'light',
ha_type: 'light' } ]
This function is to get the state of a specified device.
Run the following command in a terminal.
node getstate --username <username> --password <password> [--country <countrycode>] [--platform <platform>] --id xxxxxxxxxxxxxxx
- id: Required. The id for the device to get state for, use the
id
value specified in the output from functiondiscovery
.
Get Tuya device state...
Login successful.
Device id: xxxxxxxxxxxxxxx
Device state:
{ brightness: '89', online: true, state: 'false' }