1.0.1 • Published 9 years ago

node-rc6 v1.0.1

Weekly downloads
2
License
ISC
Repository
bitbucket
Last release
9 years ago

node-rc6

Super small home automation project, that let my Logitech Harmony One control Amazon Fire TV / Kodi Mediacenter and Philips hue lights. Runs on a Raspberry Pi with a noname RC6 USB IR receiver.

RC6 labeled IR receiver simple convert IR commands into keystrokes and is often used in connection with remote controls for Windows Media Center / Kodi / XBMC.

This package uses thouse IR inputs to control various devices in the local network.

Installation

npm install node-rc6

You also need the Android Debug Bridge (adb) as binary^1.

Usage

You have to create devices, currently Philips hue lights and Android devices (e.g. Amazon Fire TV) are supported. Every RC6 input (even from a normal keyboard) fires an input event. Use the key to send an associated command to a device.

var rc6 = require('node-rc6');

// register devices
var fireTV = rc6.device('adb-shell', '192.168.x.x', './bin/adb');
var hue = rc6.device('hue-api', '192.168.x.x');

// event driven input observation
rc6.on('input', function(key){  
  // key corresponds the key on the keyboard
  if (key === 'enter') {
    // sends a keyevent to the Fire TV
    fireTV.execute('input keyevent KEYCODE_DPAD_CENTER');
  } else if (key === 'k') {
    // try to start Kodi on Fire TV
    fireTV.execute('am start -n org.xbmc.kodi/.Splash');
  } else if (key.match(/[01]/) !== null) {
    // turn hue lights on/off
    hue.on(key === '1');
  }
}).observe();

API

node-rc6 inherits EventEmiter

methodargumentsdescription
devicestring type, string ip, ...create a new device (s. Devices)
observevoidstart the RC6 input observer

Events

eventargumentsdescription
startvoidobservation starts
endvoidobservation ends (ctrl+c)
inputstring keykeystorke, key corresponds the name of a key on normal keyboard
infostring message, object scopeinfo messages like child_process output, scope has information around the event, e.g. the returned json from the hue API
errorstring/Error error, object scopeerror reporting, scope has information around the event, e.g. the returned json from the hue API
debugstring message, object scopedebug messages, scope has information around the event, e.g. the returned json from the hue API

Devices

adb-shell device('adb-shell', ip, path_to_adb);

Used for Android devices which have network debugging enabled.

methodargumentsdescription
executestring commandexecutes a adb shell command

hue device('hue', ip);

Philips hue lights.

methodargumentsdescription
onboolean onturn lights on/off
sceneint numMy hue scene (1..n)
brichar operation, int valuechange brightness by value using '=', '+' or '-' operation
randomboolean sync, mixed duration, int transitionbring the hue bulbs (simultaneously or separately, use sync) to random colors, every milliseconds or random ms values (e.g. duration => [1000,3000]), use optionally transition to have always the same time for the transition effect (otherwise the transition is permanent)

Status

This is the first implementation. The logging is still silly, only two devices with micro API functionality. But it works perfect for me. No further work planed.

My personal config can be found in `captains-table.js.

Links

^1: For my environment I found adb for my Mac in the HOW-TO:Install Kodi on Fire TV (4.1 Setup ADB on Your Host) and for the Raspberry Pi in the xda-developers community.