tscontrol4
v2.0.2
Published
TypeScript port of pyControl4
Readme
tsControl4
TypeScript package that mirrors the public API of the Python pyControl4 library.
It also adds one extra utility not present in upstream pyControl4: discover_director_ip.
Documentation
Like pyControl4, this project includes generated API documentation pages.
- Build docs:
npm run docs - Open locally:
npm run docs:servethen visithttp://localhost:8000
Generated files are written to docs/.
Release numbers are matched to the pyControl4 releases.
Status
Implemented modules:
C4AccountC4DirectorC4WebsocketC4EntityC4Light,C4Blind,C4Fan,C4Climate,C4Room,C4RelayC4SecurityPanel,C4ContactSensor- Error hierarchy and response parsing helpers
Usage
import { C4Account, C4Director, C4Light } from "tscontrol4";
const account = new C4Account("username", "password");
const accountToken = await account.get_account_bearer_token();
const controllers = await account.get_account_controllers();
const directorToken = await account.get_director_bearer_token(
controllers.controllerCommonName
);
const director = new C4Director("192.168.1.25", directorToken.token);
const light = new C4Light(director, 253);
await light.rampToLevel(10, 10000);
console.log(await light.getState());