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

telldus-watchdog

v1.0.5

Published

Node module that can watch changes in the telldus live service and emit a event when the state (anly value) of a device has changed.

Downloads

6

Readme

telldus-watchdog NPM version Dependency Status

Node module that can watch changes in the Telldus live service and emit a event when the state (any value) of a device has changed.

Installation

$ npm install --save telldus-watchdog

Example

var twd = require("telldus-watchdog");

var options = {
  telldusPublicKey: "[public key]",
  telldusPrivateKey: "[private key]",
  telldusToken: "[token]",
  telldusTokenSecret: "[token secret]",
};

watchDog = twd.connect(options);

watchDog.on("deviceChanged", (device) => {
  console.log("Device change detected, device id: " + device.id);
});

process.on("SIGINT", () => {
  watchDog.stop();
});

process.on("SIGHUP", () => {
  watchDog.stop();
});

watchDog.start();

API

twd.connect(options)

Creates a immutable Watchdog object to monitor the telldus live service for changes. The options object is required to contain 4 keys , telldusPublicKey, telldusPrivateKey, telldusToken and telldusTokenSecret, that can be generated on http://api.telldus.com for the account that is to be monitored. The options object can optionally also include the following fields:

  • pollInterval - sets the poll interval in milliseconds, i.e. how often the telldus live service is polled for changes. If not set the default value is 5 000 milliseconds (3 seconds).
  • errorBackOff - sets the time the watchdog will pause polling if a error is received from the telldus live service in milliseconds. If not set the default value is 18 000 milliseconds (3 minutes).

twd.Watchdog#on(event, callback)

Register a event callback for a given event type.

Event 'deviceChanged'

function (device) {}

Emitted for every device where the watchdog detects a change in any property of the device since the last poll (or the watchdog was started). The device object as returned from the telldus live api.

Event 'error'

function (error) {}

Emitted when a error is thrown from the telldus live api. The error object is supplied.

Event `'info'

function (info) {}

Emitted when a relevant information is available, information passed as a string.

twd.Watchdog#start()

Starts the polling. If this is the first time the object is started will prime it state by polling once to get the value of all devices. Any chnages to any values after this point will be emitted as change events. If a new device is added to the service this will also be emitted as a chnage event.

twd.Watchdog#stop()

Stops polling, polling can be started again by calling the start method.

TODO

  • Test coverage is not 100%
  • Monitor changes in telldus sensors (currently only devices)

License

MIT © Jonas Andreasson