A JavaScript client for SwitchBot 1.1 APIs with built-in TypeScript types.
This package supports both ESM and CommonJS.
Install the package using your preferred package manager:
npm install @lucadiba/switchbot-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",
});
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();
// Execute SwitchBot Scene
switchbot.scene("sceneId").execute();
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
👤 Luca Dibattista
- Website: https://lucadibattista.it
- Github: @LucaDiba
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.
Give a ⭐️ if this project helped you!
Copyright © 2022 Luca Dibattista.
This project is MIT licensed.
This README was generated with ❤️ by readme-md-generator