An open API service indexing awesome lists of open source software.

https://github.com/lucadiba/switchbot-client

A Node.js client for SwitchBot 1.1 APIs with built-in TypeScript types.
https://github.com/lucadiba/switchbot-client

switchbot switchbot-api

Last synced: about 1 year ago
JSON representation

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

Awesome Lists containing this project

README

          

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:

```sh
npm install @lucadiba/switchbot-client
```

## Usage

### Initialize the client

Import the package in your application.

```typescript
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](https://support.switch-bot.com/hc/en-us/articles/12822710195351-How-to-obtain-a-Token).

```typescript
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.

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

Then, you can interact with the device.

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

### Scene

```typescript
// 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](https://lucadiba.github.io/switchbot-client/modules/SwitchBot.html)

The following devices are currently not supported:

- Battery Circulator Fan
- Virtual infrared remote devices

## Author

👤 **Luca Dibattista**

- Website: https://lucadibattista.it
- Github: [@LucaDiba](https://github.com/LucaDiba)

## 🤝 Contributing

Contributions, issues and feature requests are welcome!

Feel free to check [issues page](https://github.com/LucaDiba/switchbot-client/issues).

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](https://github.com/LucaDiba).

This project is [MIT](https://github.com/LucaDiba/switchbot-client/blob/main/LICENSE) licensed.

---

_This README was generated with ❤️ by [readme-md-generator](https://github.com/kefranabg/readme-md-generator)_