Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/aetheryx/tuya-api
https://github.com/aetheryx/tuya-api
Last synced: 8 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/aetheryx/tuya-api
- Owner: aetheryx
- License: mit
- Created: 2021-06-25T22:15:17.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-06-29T02:08:02.000Z (over 3 years ago)
- Last Synced: 2024-10-29T21:17:11.539Z (about 2 months ago)
- Language: TypeScript
- Size: 13.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tuya-api
A strongly-typed, high-level API for Tuya devices
```ts
import { Color, LightDevice } from './src/devices';const dev = new LightDevice({
id: 'd93cadd64b9d52d6cddd38cd',
key: '3f92c536b7467b2d41',
ip: '192.168.178.42',
});dev.addEventListener('change', ({ status, color, brightness }) => {
if (status !== undefined) {
console.log('Status changed to', status ? 'on' : 'off');
}if (color !== undefined) {
console.log('Color changed to', color.toColor().rgb().hex());
}if (brightness !== undefined) {
console.log(`Brightness changed to ${brightness}%`);
}
});await dev.init();
await dev.setColor(Color.fromRGB('#CA2D36'));
```work in progress - just a small side project for now :)