@caseman72/switchr-api
v1.0.1
Published
Simple SwitchBot API client for smart devices
Downloads
42
Maintainers
Readme
switchr-api
SwitchBot API client for Node.js. Read temperature sensors and control devices.
Setup
- Get API credentials from the SwitchBot app: Profile > Preferences > Developer Options
- Create
.env.localwith your credentials (checked in order, first found is used):.env.local(current directory)~/.config/switchr-api/.env.local~/.switchbot.env.local
SWITCHBOT_TOKEN=your-token-here
SWITCHBOT_SECRET=your-secret-hereUsage
import Switchr from "switchr-api";
const switchr = new Switchr();
// List devices
const { devices } = await switchr.getDevices();
// Get single temperature
const temp = await switchr.getTemperature(deviceId);
console.log(temp.temperature, temp.unit, temp.humidity, temp.battery);
// Get all temperatures
const all = await switchr.getAllTemperatures();
// Get device status
const status = await switchr.getStatus(deviceId);License
MIT
