Skip to content
This repository has been archived by the owner on Jun 18, 2020. It is now read-only.

basdelfos/tuya-web-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

!! THIS REPOSITORY IS NOT ACTIVELY MAINTAINED ANYMORE, PLEASE FEEL FREE TO CREATE FORK !!

tuya-web-cli

CLI tools for using Tuya Web API

Usage

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.

Installation

To use this tool you need to do the following actions:

  1. Download or clone this repository.
  2. Open folder in a termimal containing the downloaded or cloned repository.
  3. Run npm i to install dependency modules.

Current implemented functions

  • Discover devices
  • Get device state

General command line usage

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 or jinvoo_smart for Jinvoo Smart.
  • params: Optional or required, depending on function. See function description below for more details.
Example

node discover --username [email protected] --password xxxxx --country 31 --platform smart_life

Discover devices

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>]

Sample output
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' } ]

Get device state

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 function discovery.
Sample output
Get Tuya device state...
Login successful.
Device id: xxxxxxxxxxxxxxx
Device state:
{ brightness: '89', online: true, state: 'false' }

About

CLI tools for using Tuya Web API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published