PyP100 Documentation

repository·main·Indexed 20 days ago

https://github.com/fishbigger/tapop100

A Python library for controlling TP-Link Tapo smart devices. Supports smart plugs (P100, P105, P110) and bulbs (L530, L510E), providing functionality for power control, brightness and color adjustment for bulbs, and energy usage monitoring for P110 plugs.

Tokens
699
Snippets
4
Records
4
Agent score
21%

What's inside PyP100

  1. Control TP-Link Tapo Plugs (P100, P105, etc.)

    main

    Use the PyP100.P100 class to control smart plugs. You must initialize the object with the device's IP address, your TP-Link account email, and password.

    Important Lifecycle Steps:

    1. Call .handshake() to generate the required cookies.
    2. Call .login() to authenticate and establish the AES Key and IV needed for subsequent commands.

    Available Methods:

    • turnOn(): Turns the plug on.
    • turnOff(): Turns the plug off.
    • toggleState(): Toggles the current state.
    • turnOnWithDelay(seconds): Turns the plug on after a specified delay.
    • turnOffWithDelay(seconds): Turns the plug off after a specified delay.
    • getDeviceInfo(): Returns a dictionary containing device information.
    • getDeviceName(): Returns the device name set in the Tapo app.
    from PyP100 import PyP100
    
    p100 = PyP100.P100("192.168.X.X", "email@gmail.com", "Password123")
    
    p100.handshake() # Required
    p100.login()     # Required
    
    p100.turnOn()
    p100.getDeviceInfo()
  2. Control TP-Link Tapo Bulbs (L530, L510E, etc.)

    main

    Use the PyL530.L530 class to control smart bulbs. Like plugs, you must call .handshake() and .login() after initialization to authenticate.

    Additional Bulb Methods:

    • setBrightness(percentage): Sets brightness (e.g., 50 for 50%).
    • setColorTemp(kelvin): Sets color temperature in Kelvin (e.g., 2700 for Warm White).
    • setColor(hue, saturation): Sets color using Hue (0-360°) and Saturation (0-100%).
    from PyP100 import PyL530
    
    l530 = PyL530.L530("192.168.X.X", "email@gmail.com", "Password123")
    
    l530.handshake()
    l530.login()
    
    l530.setBrightness(50)
    l530.setColorTemp(2700)
    l530.setColor(30, 80) # Hue: 30, Saturation: 80
  3. Monitor Energy Usage with P110 Plugs

    main

    The PyP110.P110 class provides all standard plug functionality plus energy monitoring capabilities.

    Energy Methods:

    • getEnergyUsage(): Returns a dictionary containing the energy usage data for the connected P110 plug.
    from PyP100 import PyP110
    
    p110 = PyP110.P110("192.168.X.X", "email@gmail.com", "Password123")
    
    p110.handshake()
    p110.login()
    
    energy_data = p110.getEnergyUsage()