GithubHelp home page GithubHelp logo

tapop100's Introduction

PyP100

PyP100 is a Python library for controlling many of the TP-Link Tapo devices including the P100, P105, P110 plugs and the L530 and L510E bulbs.

This fork is designed to support the new authentication method and is currently compatible with the P100 version 1.2.1. It also supports the old authentication method.

Most of the code originates from OctoPrint-PSUControl-Tapo.

Installation

PyP100 can be installed using the package manager pip.

pip install git+https://github.com/almottier/TapoP100.git@main

Usage

Plugs - P100, P105 etc.

from PyP100 import PyP100

p100 = PyP100.P100("192.168.X.X", "[email protected]", "Password123")  # Creates a P100 plug object

p100.turnOn()  # Turns the connected plug on
p100.turnOff()  # Turns the connected plug off
p100.toggleState()  # Toggles the state of the connected plug

p100.getDeviceInfo()  # Returns dict with all the device info of the connected plug
p100.getDeviceName()  # Returns the name of the connected plug set in the app

p100.handshake()  # DEPRECATED
p100.login()  # DEPRECATED

Old Authentication Method

The old authentication method is used as a fallback if the new authentication method fails. It can be forced by setting the preferred_protocol parameter to "old" when creating the plug object.

from PyP100 import PyP100

p100 = PyP100.P100("192.168.X.X", "[email protected]", "Password123",
                   preferred_protocol="old")  # Creates a P100 plug object using the old authentication method only

Bulbs - L530, L510E etc.

from PyP100 import PyL530

l530 = PyL530.L530("192.168.X.X", "[email protected]", "Password123")

# All the bulbs have the same basic functions as the plugs and additionally allow for the following functions.
l530.setBrightness(50)  # Sets the brightness of the connected bulb to 50% brightness
l530.setColorTemp(2700)  # Sets the color temperature of the connected bulb to 2700 Kelvin (Warm White)
l530.setColor(30, 80)  # Sets the color of the connected bulb to Hue: 30°, Saturation: 80% (Orange)

Energy Monitoring - P110

from PyP100 import PyP110

p110 = PyP110.P110("192.168.X.X", "[email protected]", "Password123")

# The P110 has all the same basic functions as the plugs and additionally allow for energy monitoring.
p110.getEnergyUsage()  # Returns dict with all of the energy usage of the connected plug
p110.getEnergyData(1706825847, 1708643847, MeasureInterval.DAYS) # Returns power consumption per day since 1st Feb 24

If you call getEnergyData function, power consumption could be collected per HOURS, DAYS or MONTHS interval. The start timestamp is (most probably) rounded to the midnight, the first day of month or the first of January based on interval.

Contributing

Contributions are always welcome!

Please submit a pull request or open an issue for any changes.

License

MIT

tapop100's People

Contributors

fishbigger avatar pnuu avatar almottier avatar shadow00 avatar realzoulou avatar mochipon avatar arrival-spring avatar tking2 avatar sonic74 avatar maresmar avatar gurkein avatar bentasker avatar piffall avatar krasnyd avatar mrx23dot avatar quentinlegay avatar solarctp avatar

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.