SwitchBotAPI for Deno
prepare a setting.json (app → profile → settings → tap app version 10 times! to get token & secret)
{
"token": "xxx...",
"secret": "xxxxxx...",
}
write and save as devices.js
import { SwitchBotAPI } from "https://code4fukui.github.io/SwitchBotAPI-deno/SwitchBotAPI.js";
const setting = JSON.parse(await Deno.readTextFile("setting.json"));
const api = new SwitchBotAPI(setting);
console.log(await api.getDevices());
run to get deviceId
deno run -A devices.js
to turn on
const api = new SwitchBotAPI(setting);
await api.turnOn(deviceId);