Giter Club home page Giter Club logo

python-decora_wifi's Introduction

python-decora_wifi

Python Library for Interacting with Leviton Decora Smart WiFi Switches & Dimmers.

The code is reverse engineered from the myLeviton Android app and includes an "API scraper" python script that generates model classes for invoking Leviton Cloud Services REST APIs.

See cli-test.py for a usage example.

Create a session first:

session = DecoraWiFiSession()
session.login(decora_email, decora_pass)

After that, the logged in user is accessible in session.user.

To get the user's residences, go through the ResidentialPermissions model like this:

perms = session.user.get_residential_permissions() # Usually just one of these

for permission in perms:
  acct = ResidentialAccount(session, permission.residentialAccountId)
  residences = acct.get_residences()

Now from each residence, you can get a list of switches:

  for residence in residences:
    switches = residence.get_iot_switches()
    for switch in switches:
      print(switch)

Other useful methods:

  • switch.update_attributes({'power': 'ON', 'brightness': 75}) - Turn switch ON or OFF, change brightness. Print out your switch attributes to see what's available.
  • switch.refresh() - Refresh this model's data from the server.
  • Person.logout(session) - Log out from LCS.

Notes:

  • Create/delete methods are untested. I was only interested in get/update methods for HASS integration. Feel free to submit a pull if something doesn't work.
  • This code uses the HTTPS interface to LCS, I believe there's also a websocket one, but I haven't investigated it.

python-decora_wifi's People

Contributors

rickythefox avatar tlyakhov avatar

Watchers

 avatar  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.