Skip to content

An unofficial REST API to remotely control your tapo light strip device

Notifications You must be signed in to change notification settings

pedcapa/tapo-python

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unofficial Tapo REST API with OpenAI GPT-3 integration

This program exposes a REST API with OpenAI GPT-3 integration to change the color of your Tapo devices (light bulbs, strips, etc.) based on the impact of a cybersecurity alert.

It is based on the unofficial Tapo API and the OpenAI GPT-3 API.

Table of Contents

Configuration

  1. Create a Tapo account and add your Tapo devices to it from the phone app.
  2. Create an OpenAI account and get your API key from here.
  3. Open the terminal application on your computer.
  4. Clone the repo
git clone https://github.com/catbox-dev/tapo-python.git
  1. Access to the GitHub directory
cd path/to/tapo-python
  1. Install the tapo-rest program by Clément Nerma
cargo install --git https://github.com/ClementNerma/tapo-rest
  1. Without closing the terminal, modify the configuration file config.json with your Tapo credentials and your OpenAI API key
{
    "account": {
        "username": "<your tapo account's email>",
        "password": "<your tapo account's password>",
        "openai_token": "<your openAI token>"
    },
    "devices": [
        {
            "name": "<name of the device>",
            "device_type": "<model of the device>",
            "ip_addr": "<ip address of the device>",
            "port": "<port of the device>"
        }
    ]
}

We recommend to use the default port 9999 for the Tapo devices (for this README we will use this port, but you can choose any port you like). The ip address of the device can be found in the Tapo app by clicking on the device and then on the settings icon in the top right corner.

e.g.:

{
    "account": {
        "username": "example@email.com",
        "password": "example_password",
        "openai_token": "example_token"
    },
    "devices": [
        {
            "name": "mytapo",
            "device_type": "L900",
            "ip_addr": "123.123.123.123",
            "port": "9999"
        }
    ]
}

The name field can be anything you want.
The device_type field can be any of:

  • L510
  • L530
  • L610
  • L630
  • L900
  • L920
  • L930
  • P100
  • P105
  • P110
  • P115
  1. Run the server (with the default port 9999 but you can choose whatever port you want)
cargo run -- --devices-config-path config.json --port 9999 --auth-password 'potatoes'

This will run the server on 0.0.0.0:9999 (you can chose any port you like).

IMPORTANT: Do not close the terminal, otherwise the server will stop.

Usage

  1. Open the terminal application on your computer, without closing the terminal where you ran the server.
  2. Access to the GitHub directory
cd path/to/tapo-python
  1. Install the openai library
pip3 install openai
  1. Run the python script
python3 main.py

Credits

About

An unofficial REST API to remotely control your tapo light strip device

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 81.2%
  • Python 18.8%