Coder Social home page Coder Social logo

ttlockio's Introduction

ttlock.io

Python wrapper for TTLock API

  1. Register a developer account
https://euopen.ttlock.com/register
  1. Log in
https://euopen.ttlock.com/login
  1. Create application:
https://euopen.ttlock.com/CreateApplication
  • The application needs to be reviewed. After it is reviewed, all the APIs are available.
  1. Create a user for this application and get the access token:
$ pip install ttlockio
$ create_user YOUR_APP_CLIENT_ID YOUR_APP_CLIENT_SECRET USERNAME PASSWORD --token

--token is an optional parameter; create_user -h for usage. if not used the user will be created without an access token. You need pass the PASSWORD with max 32 chars, low case

  • Return:
{'username': 'prefixed_user'}
{'access_token': 'xxx', 'uid': xxx, 'refresh_token': 'xxx', 'openid': xxx, 'scope': 'user,key,room', 'token_type': 'Bearer', 'expires_in': 7776000}

5a. Refresh the access token when required

refresh_access_token YOUR_APP_CLIENT_ID YOUR_APP_CLIENT_SECRET YOUR_REFRESH_TOKEN
  • Return:
{'access_token': 'xxx', 'refresh_token': 'xxx', 'openid': xxx, 'scope': 'user,key,room', 'token_type': 'Bearer', 'expires_in': 7776000}
  1. Test your USER:
  • Download TTLock App at your cellphones app store. Log in with your YOUR_APP_NAME_CONCAT_NEW_NAME_FOR_YOUR_USER and NEW_PASS_FOR_YOUR_USER created on step four.
  • Add your TTLock gateways and locks.
  1. Install and Use
$ pip install ttlockio 
$ python3
>>import ttlockwrapper
>>gateways = list(ttlockwrapper.TTLock(clientId='YOUR_APP_CLIENT_ID',accessToken='YOUR_ACCESS_TOKEN').get_gateway_generator())
>>print('Gateway ID and Gateway Lock quantity: {}, {}'.format(gateways[0].get('gatewayId'),gateways[0].get('lockNum')))
  1. Examples
  • See example dir at this repo.

ttlockio's People

Contributors

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