Skip to content

A Node.js client for SwitchBot 1.1 APIs with built-in TypeScript types.

License

Notifications You must be signed in to change notification settings

LucaDiba/switchbot-client

Repository files navigation

SwitchBot client

⚠️ This package is in beta ⚠️

TypeScript NPM package CI build Code coverage Maintained Documentation License: MIT

A JavaScript client for SwitchBot 1.1 APIs with built-in TypeScript types.
This package supports both ESM and CommonJS.

Installation

Install the package using your preferred package manager:

npm install @lucadiba/switchbot-client

Usage

Initialize the client

Import the package in your application.

import SwitchBot from "@lucadiba/switchbot-client";

Initialize the client with your open token and secret key. You can find these values in the SwitchBot app.

const switchbot = new SwitchBot({
  openToken: "openToken",
  secretKey: "secretKey",
});

Device

To interact with a device, you need to know its ID. You can find it in the SwitchBot app or by calling the devices method.

const devices = await switchbot.devices();
// [{
//   deviceId: "deviceId",
//   ...
// }]

Then, you can interact with the device.

// Press SwitchBot Bot
switchbot.bot("deviceId").press();

Scene

// Execute SwitchBot Scene
switchbot.scene("sceneId").execute();

Support

The following devices are supported:

  • Blind Tilt
  • Bot
  • Ceiling Light
  • Ceiling Light Pro
  • Color Bulb
  • Contact Sensor
  • Curtain
  • Curtain 3
  • Hub
  • Hub 2
  • Hub Plus
  • Hub Mini
  • Humidifier
  • Indoor Cam
  • Keypad
  • Keypad Touch
  • Lock
  • Meter
  • Meter Plus
  • Outdoor meter
  • Motion Sensor
  • Pan/Tilt Cam
  • Pan/Tilt Cam 2K
  • Plug
  • Plug Mini (US)
  • Plug Mini (JP)
  • Remote
  • Robot Vacuum Cleaner S1
  • Robot Vacuum Cleaner S1 Plus
  • Strip Light
  • 📘 Full documentation

The following devices are currently not supported:

  • Battery Circulator Fan
  • Virtual infrared remote devices

Author

👤 Luca Dibattista

🤝 Contributing

Contributions, issues and feature requests are welcome!
Feel free to check issues page.
Please run npx changeset and follow the instructions to create a new changeset before opening a pull request.

Show your support

Give a ⭐️ if this project helped you!

📝 License

Copyright © 2022 Luca Dibattista.
This project is MIT licensed.


This README was generated with ❤️ by readme-md-generator