npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

kasa_control

v0.1.2

Published

Use kasa-cloud to hit your TPLink bulbs in nodejs

Downloads

39

Readme

kasa-control

This will let you use kasa-cloud to hit your TPLink bulbs in nodejs.

If you'd like to hit them directly, on your local network, use tplink-lightbulb. This library is for situations where you want to use a username/password (from tplink cloud.) It will allow you to acces them remotely.

installation

npm i kasa_control

example usage

const KasaControl = require('kasa_control')
const kasa = new KasaControl()

const main = async () => {
  await kasa.login('email', 'password')
  const devices = await kasa.getDevices()

  // turn off first device
  await kasa.power(devices[0].deviceId, false)
}
main()

api

send ⇒ Promise

Send a message to a lightbulb (for RAW JS message objects)

Returns: Promise - Resolves with answer

| Param | Type | Description | | --- | --- | --- | | deviceId | string | The deviceId of the device in your kasa app | | msg | Object | Message to send to bulb |

Example

kasa.send('80126E22B048C76F341BEED1A3EA8E77177F3484', {
  'smartlife.iot.smartbulb.lightingservice': {
    'transition_light_state': {
      'on_off': 1,
      'transition_period': 0
    }
})
  .then(response => {
    console.log(response)
  })
  .catch(e => console.error(e))

getDevices ⇒ Promise

Get a list of devices for your Kasa account

Returns: Promise - Resolves to an array of device-objects Example

kasa.getDevices()
  .then(devices => {
    console.log(devices)
  })
  .catch(e => console.error(e))

info ⇒ Promise

Get info about a device

Returns: Promise - Resolves to an info-pbject about your device example

kasa.info('80126E22B048C76F341BEED1A3EA8E77177F3484')
  .then(info => {
    console.log(info)
  })
  .catch(e => console.error(e))

| Param | Type | Description | | --- | --- | --- | | deviceId | string | The deviceId of the device in your kasa app |

power ⇒ Promise

Set power-state of lightbulb

Returns: Promise - Resolves to output of command

| Param | Type | Description | | --- | --- | --- | | deviceId | string | The deviceId of the device in your kasa app | | powerState | Boolean | On or off | | transition | Number | Transition to new state in this time | | options | Object | Object containing mode, hue, saturation, color_temp, brightness |

Example

// turn a light on
kasa.power('80126E22B048C76F341BEED1A3EA8E77177F3484', true)
  .then(status => {
    console.log(status)
  })
  .catch(err => console.error(err))

thanks

Thanks to itnerd for these 3 articles: