Giter VIP home page Giter VIP logo

tuya-bulb-control's Introduction

Tuya Bulb Control

Tuya Bulb Control - API wrapper for you smart bulbs developed by Tuya

PyPi Versions Python versions Code Style


Installation

Install or upgrade tuya-bulb-control:

$ pip install tuya-bulb-control --upgrade

Or install source:

$ git clone https://github.com/Octoober/tuya-bulb-control.git
$ cd tuya-bulb-control
$ python setup.py install

Demo:

from tuya_bulb_control import Bulb

CLIENT_ID = ''
SECRET_KEY = ''
DEVICE_ID = ''
REGION_KEY = 'eu'

bulb = Bulb(
    client_id=CLIENT_ID,
    secret_key=SECRET_KEY,
    device_id=DEVICE_ID,
    region_key=REGION_KEY
)

# Turn on the bulb
bulb.turn_on()

# Change the color to green
bulb.set_colour_v2(rgb=(0, 255, 0))

# Turn off the light bulb after 5 minutes
bulb.set_toggle_timer(value=5)

Getting access to API

Step 1: CLIENT_ID and SECRET_KEY

  • Register or Login on Tuya.
  1. Create a cloud development project Cloud -> Project.
  2. After successful creation, you will receive the Client ID and Secret Key.

Step 2: DEVICE_ID

  1. Install Tuya Smart app or Smart Life app on your mobile phone.
  2. Go to Cloud -> Link Devices page.
  3. Selecting a tab Link Devices by App Account.
  4. Click Add App Account and scan the QR code with Tuya Smart app or Smart Life app.
  5. Now you can go to devices Cloud -> Device List and copy Device ID.
    • Notes: Try to select a your region if devices are not displayed.

Step 3: Request access to API calls

Go to Cloud -> API Group and enable Authorization management, Device Management and Device Control.

Done!

tuya-bulb-control's People

Contributors

octoober avatar orpos avatar prankard avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

tuya-bulb-control's Issues

tuya_bulb_control.exceptions.AuthorizedError: 1004 -> Sign invalid

Hello!

This error happens immediately upon running the example code. Region is set to US, and client ID, client secret and device ID are all OK. PC is also connected to the same network as the bulb, if that is relevant.

Full error log:
Traceback (most recent call last):
File "c:\Users\XXX\Documents\CodingStudies\playground\python\smart-light-piano\main.py", line 9, in
bulb = Bulb(
^^^^^
File "C:\Users\XXX\AppData\Local\Programs\Python\Python311\Lib\site-packages\tuya_bulb_control\bulb.py", line 23, in init
super().init(
File "C:\Users\XXX\AppData\Local\Programs\Python\Python311\Lib\site-packages\tuya_bulb_control_tuya_api.py", line 25, in init
self.__access_token = self.__token()
^^^^^^^^^^^^^^
File "C:\Users\XXX\AppData\Local\Programs\Python\Python311\Lib\site-packages\tuya_bulb_control_tuya_api.py", line 102, in __token
raise AuthorizedError(
tuya_bulb_control.exceptions.AuthorizedError: 1004 -> Sign invalid

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.