npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

teletask

v0.1.0

Published

Teletask DoIP Client Library

Downloads

65

Readme

Teletask Client Library

A TypeScript/JavaScript library for communicating with TELETASK home automation systems over IP (DoIP).

Features

  • Complete support for all TELETASK functions (relays, dimmers, motors, sensors, etc.)
  • Automatic connection management with reconnection handling
  • Event-based architecture for real-time state updates

Installation

npm install teletask

Quick Start

import { TeletaskClient } from 'teletask';

// Create a new client instance
const client = new TeletaskClient('192.168.1.100', 55957);

// Connect to the TELETASK system
await client.connect();

// Control a relay
await client.setRelay(1, 5, true);  // Turn on relay 5 on central unit 1

// Control a dimmer
await client.setDimmer(1, 3, 75);   // Set dimmer 3 to 75% on central unit 1

// Subscribe to state changes
client.subscribe(FunctionType.RELAY, (change) => {
  console.log(`Relay ${change.number} changed to ${change.value}`);
});

Connection Management

const client = new TeletaskClient('192.168.1.100', 55957, {
  connection: {
    autoReconnect: true,
    reconnectDelay: 5000,
    keepAliveInterval: 240000,
    responseTimeout: 4000,
    maxReconnectAttempts: 10
  }
});

// Event handlers
client.onConnected(() => {
  console.log('Connected to TELETASK system');
});

client.onConnected(() => {
  log('Connected to TELETASK system');
});

client.onDisconnected((error?: Error) => {
  log(`Disconnected from TELETASK system${error ? `: ${error.message}` : ''}`);
});

client.onReconnecting((attempt: number) => {
  log(`Reconnecting to TELETASK system (attempt ${attempt})`);
});

client.onConnectionError((error: Error) => {
  log(`Connection error: ${error.message}`);
});

client.onTimeout(() => {
  console.log('Connection timeout');
});

Controlling Components

Relays

// Query relay state
const state = await client.queryRelay(1, 5);
console.log('Relay is:', state.on ? 'ON' : 'OFF');

// Control relay
await client.setRelay(1, 5, true);   // Turn ON
await client.setRelay(1, 5, false);  // Turn OFF

Dimmers

// Query dimmer state
const state = await client.queryDimmer(1, 3);
console.log('Dimmer level:', state.level);
console.log('Is on:', state.on);

// Control dimmer
await client.setDimmer(1, 3, 100);  // Full brightness
await client.setDimmer(1, 3, 50);   // 50% brightness
await client.setDimmer(1, 3, 0);    // Off

Motors

// Query motor state
const state = await client.queryMotor(1, 2);
console.log('Motor position:', state.position);
console.log('Is moving:', state.moving);
console.log('Direction:', state.direction);

// Control motor
await client.setMotor(1, 2, MotorAction.UP);
await client.setMotor(1, 2, MotorAction.DOWN);
await client.setMotor(1, 2, MotorAction.STOP);

// Move to specific position
await client.setMotorPosition(1, 2, 75);  // Move to 75%

// Sun protection
await client.setMotorSunProtection(1, 2, true);  // Enable
await client.setMotorSunProtection(1, 2, false); // Disable

Audio Control

// Control audio zones
client.setAudio(1, 1, AudioAction.ON);
client.setAudio(1, 1, AudioAction.VOLUME_UP);
client.setAudio(1, 1, AudioAction.VOLUME_DOWN);
client.setAudio(1, 1, AudioAction.MUTE);
client.setAudio(1, 1, AudioAction.OFF);

Moods and Regimes

// Control moods
await client.setLocalMood(1, true);      // Activate local mood
await client.setGeneralMood(1, true);    // Activate general mood

// Control regimes
client.setRegime(RegimeAction.AUTO);     // Set to auto regime
client.setRegime(RegimeAction.WORKDAY);  // Set to workday regime

Event Handling

Subscribe to state changes for real-time updates:

// Subscribe to relay changes
client.subscribe(FunctionType.RELAY, (change) => {
  console.log(`Relay ${change.number} changed to ${change.value}`);
});

// Subscribe to dimmer changes
client.subscribe(FunctionType.DIMMER, (change) => {
  console.log(`Dimmer ${change.number} changed to ${change.value}%`);
});

// Subscribe to motor changes
client.subscribe(FunctionType.MOTOR, (change) => {
  console.log(`Motor ${change.number} state changed:`, change.value);
});

// Unsubscribe from events
client.unsubscribe(FunctionType.RELAY, handlerFunction);

Protocol Support

This library implements the TELETASK DoIP (Domotics over IP) protocol version 3.4. It communicates with TELETASK central units using TCP/IP on port 55957.

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.