0.2.0 • Published 4 years ago
tydom-api v0.2.0
Node.js Tydom Client
Easily manage Tydom hardware by Delta Dore from Node.js.
Originally built to enable bridging accessories to Apple HomeKit.
Uses node-fetch for the initial HTTP handshake.
Built with TypeScript for static type checking with exported types along the library.
Documentation
Installation
yarn add tydom-client
# or
npm install tydom-client
Examples
Simple example
You can use the provided factory function to quickly get a working client
import {createClient} from 'tydom-client';
const username = '001A25123456';
const password = 'MyPassw0rd!';
const hostname = 'mediation.tydom.com'; // or '192.168.1.xxx'
const client = createClient({username, password, hostname});
(async () => {
console.log(`Connecting to "${hostname}"...`);
const socket = await client.connect();
// Get Tydom info
const info = await client.get('/info');
console.dir({info});
// Turn a light on
await client.put(`/devices/${MY_DEVICE_ID}/endpoints/${MY_DEVICE_ID}/data`, [
{
name: 'level',
value: 100
}
]);
})();
Available scripts
Script | Description |
---|---|
start | alias to spec:watch |
test | Run all tests |
spec | Run unit tests |
spec:coverage | Run unit tests with coverage |
spec:watch | Watch unit tests |
lint | Run eslint static tests |
pretty | Run prettier static tests |
build | Compile the library |
build:watch | Watch compilation |
Authors
Olivier Louvignes
License
The MIT License
Copyright (c) 2019 Olivier Louvignes <olivier@mgcrea.io>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
0.2.0
4 years ago