GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - Sternbach-Software/KasaTPLinkAndroidSDK: An Android SDK for interacting with Kasa smart devices and the Kasa API

BranchesTags
Open more actions menu

Latest commit

 

History

19 Commits
19 Commits

Folders and files

NameName
Last commit message
Last commit date
.idea
.idea
 
 
KasaTPLinkSDK
KasaTPLinkSDK
 
 
app
app
 
 
gradle/wrapper
gradle/wrapper
 
 
.gitignore
.gitignore
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
build.gradle
build.gradle
 
 
gradle.properties
gradle.properties
 
 
gradlew
gradlew
 
 
gradlew.bat
gradlew.bat
 
 
settings.gradle
settings.gradle
 
 

Repository files navigation

Kasa TP-Link Android SDK

This is an (unofficial) Android SDK for interacting with Kasa smart devices and the Kasa API.

Dependency

In newer Gradle versions, insert this into settings.gradle:

dependencyResolutionManagement {
    ...
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

And then download the library as usual:

dependencies {
    implementation 'com.github.Sternbach-Software:KasaTPLinkAndroidSDK:-SNAPSHOT'
}

Usage

The entry point to this sdk is the KasaDeviceManager class. Use this class by creating an instance using the empty constructor, calling authenticate, and then using the instance to create KasaDevices by calling withDevice. For example:

val manager = KasaDeviceManager()
manager.authenticate(email, password)
val lamp = manager.withDevice(/* alias = */ "Kitchen lamp")!!

You can also use the KasaDeviceManager to get a list of devices associated with the account.

There are two types of device objects the SDK exposes:

  • the device objects as returned from the Kasa API (which have a lot of meaningless hardware information):
manager.getAllDevices()
  • a more user-friendly object (KasaDevice) that only has the alias (user-assigned name of smart device) and functions for turning on and off the device.
manager.getAllKasaDevices()

The currently available functions of KasaDevice are (I welcome PRs):

lamp.turnOn()
lamp.turnOff()
lamp.toggle() 

lamp.getIsOn()
lamp.setIsOn(true)

The above are all suspending functions, as is authenticate, because they use Retrofit to invoke the official API, wap.tplinkcloud.com.

Unfortunately, the last two functions cannot be condensed into lamp.isOn with a getter and setter because these functions are suspend, and suspending properties are currently not supported.

Credits

This SDK is heavily based on this widget which is under the MIT license.

License

   Copyright [2022] [[email protected]]

   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
   You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.

About

An Android SDK for interacting with Kasa smart devices and the Kasa API

Topics

kasakasa-apikasa-deviceskasa-plugskasa-smartkasa-switchestp-linktp-link-bulbtp-link-hs100tp-link-hs110tp-link-kasatplinktplink-apitplink-kasatplink-manager

Resources

Readme
Apache-2.0 license
Activity

Stars

5 stars

Watchers

2 watching

Forks

2 forks
Report repository

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.