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

hdhomerun

v0.0.3

Published

low-level control of HDHomeRun TV tuner devices

Downloads

8

Readme

#hdhomerun

Control your SiliconDust HDHomeRun network-attached digital TV tuner from node.js. This module provides a JavaScript interface to discover devices, and to get and set device control variables. While not a complete solution in itself, hdhomerun provides the low-level functionality necessary to build higher level tools and applications (such as DVR). Users of hdhomerun will certainly want to refer to libhdhomerun (the C library provided by the manufacturer) for details on how the low-level get/set API can be used to implement higher-level functionality. See examples/cli.js for a node version of the libhdhomerun 'hdhomerun_config' CLI utility.

##Installation:

npm install hdhomerun

##Usage:

Use the discover() method to find devices on the local network:

var hdhr = require('hdhomerun');

hdhr.discover(function (err, res) {
	console.log(res);
};
> [ { device_id: '1038A145',
device_type: 'tuner',
tuner_count: 2,
device_ip: '192.168.2.123' } ]

Now create a device object:

var device = hdhr.create({device_id: '1038A145',
    device_ip: '192.168.2.123'});

Using the device object, you can get and set named control variables:

device.get('/sys/model', function (err, res) {
	console.log(res);
}
> { name: '/sys/model', value: 'hdhomerun3_atsc' }

Control variables are used to interact with the device. Most importantly, they let you change channels and initiate a video stream:

device.set('/tuner0/channel', 'auto:9', function (err, res) {
	console.log(res);
}
> { name: '/tuner0/channel', value: 'auto:9' }

device.get('/tuner0/streaminfo', ...
> 1: 9.1 KUSA-DT
> 2: 9.2 9News N
> tsid=0x01CF

device.set('/tuner0/program', 1, ...
device.get('/tuner0/status', ...
> value: 'ch=auto:9 lock=8vsb ss=92 snq=77 seq=100 bps=19394080 pps=0'

device.set('/tuner0/target', 'udp://localhost:54321', ...
> // Now MPEG2 data is streaming to the specified host/port

##API:

discover([search_id], callback)

  • search_id {String} Optional device_id of device we wish to discover
  • callback {Function} Callback function
    • err {Error Object} not yet implemented
    • found {Array} Array of discovered device objects The found array contains objects representing discovered devices. Each object contains the following fields:
      • device_id {String}
      • device_type {String} Will always be 'tuner'
      • tuner_count {Number} number of tuners in the device
      • device_ip {String} IP address of the device

When called without a search_id argument, discover() will accept responses from all devices on the local network that respond to it's broadcast request within the timeout period (currently 500ms).

If search_id is specified, only a matching device will respond to the broadcast. Once a matching response is received, callback() is immediately called.

create(conf)

  • conf {Object}
    • device_id {String}
    • device_ip {String}
  • Returns: {Object} new Device object

Class: Device

Device objects maintain a TCP connection with their corresponding physical device. This control socket is used to send get/set messages and receive responses. Device instances initiate the control socket connection immediately and emit connected when the connection is ready.

Device.get(variable, callback)

  • variable {String} named control variable to retrieve
  • callback {Function} called when a response from the device arrives
    • err {Error Object}
    • res {Object} response object with the following members:
      • name {String} the requested control variable
      • value {String} the value of the requested variable

Device.set(variable, value, callback)

  • variable {String} named control variable to set
  • value {String} value to set the control variable
  • callback {Function} called when a response from the device arrives
    • err {Error Object}
    • res {Object} response object with the following members:
      • name {String} the requested control variable
      • value {String} the (updated) value of the requested variable

##Examples:

examples/cli.js implements (roughly) the same functionality as libhdhomerun 'hdhomerun_config'. This toy program demonstrates how one could implement common functionality such as channel scanning and saving video streams (in a node-y way).

##Testing:

Currently, an actual HDHomeRun device is required to execute the tests. Set an environment variable 'MY_HDHR' to the device_id (aka serial #) of your local device before running 'npm test'.

##Supported Devices

  • HDHR3-US (Dual Tuner ATSC)

##TODO:

  • proper tests
  • additional device support
  • more complete and standardized error handling

##License: MIT.