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

cherry-core

v1.0.4

Published

Home automation nerve center

Downloads

31

Readme

cherry

# Cherry

An extensible hub for home automation/Internet of Things.

## Overview

Cherry acts as a hub for your house and allows any connected component to communicate with each other. Cherry's power comes from its plugin system. Connected devices can talk to each other. Adding a new component to the system is as simple as writing a few lines of code (Node.js module).

As an example, let's say you have a Philips Hue light and you want to turn it on by pressing a button. You just need a few lines of code:

module.exports = function (cherry) {
  console.log("lightswitch ready to rock");

  cherry.handle({
    pin: function (message) {
      var plugins = cherry.plugins();
      if (message.state === "high") {
        plugins.hue({on: true});
      } else if (message.state === "low") {
        plugins.hue({on: false});
      }
    }
  });
}

See this blog post for more background: https://wit.ai/blog/2014/09/12/office-automation-with-raspberry-pi.

## Using

npm install -g cherry-core
# you may install additional plugins through npm
# npm install -g cherry-wit cherry-spotify cherry-hue
cherry path/to/config.json

config.json looks something like that (cf. config.json.sample):

{
  "port": 4433,
  "witd_url": "http://192.168.1.68:8080",
  "wit_token": "MY_WIT_TOKEN",
  "hipchat_jid": "[email protected]",
  "hipchat_pwd": "mypwd",
  "hipchat_room": "[email protected]/Cherry",
  "hue_host": "http://192.168.1.169",
  "hue_user": "willyblandin",
  "demo_port": 5576,
  "gpio_pins": {
    "22": ["in", "both"]
  },
  "plugins": [
    "cherry-spotify",
    "cherry-hue",
    "cherry-wit",
    "cherry-gpio",
    "cherry.integration.hipchat",
    "./contrib/cambridge.js",
  ]
}

## Using existing plugins

In your config.json file, you specify the list of plugins you want to use.

Each item can either be:

  • the name of a globally or locally installed npm package, e.g. cherry-spotify
  • a path to a Javascript file, e.g. ./examples/lightswitch.js
  • a CoffeeScript file

## Creating a plugin

We've focused on making it really simple and easy to write a plugin for Cherry. You can check the examples directory, cherry-spotify, cherry-hue or below:

mkdir cherry-logger
npm init

cat > index.js <<EOF
module.exports = function (cherry) {
  // listen for chat messages and turn lights on or play next song
  cherry.handle({
    chat: function (msg) {
      var plugins = cherry.plugins();

      if (msg === 'next song') {
        plugins.spop('next');
      } else if (msg === 'lights on') {
        plugins.hue({on: true});
      }
    }
  });
}
EOF

npm publish

Built-in plugins

You can configure plugins through a config.json file.

HipChat

Note: this will be extracted into a cherry-hipchat plugin pretty soon. Produces: "from: chat"

"hipchat_jid": "[email protected]",
"hipchat_pwd": "mypassword",
"hipchat_room": "[email protected]/My Username",

## Dev

cp config.json.sample config.json
lein cljsbuild auto
node dist/cherry.js config.json

## Cambridge

We use cherry everyday at the office and have put together a small script that should get everything up and running from a Raspberry Pi:

curl -s https://raw.githubusercontent.com/wit-ai/cherry/master/cambridge.sh | sudo -E sh

## TODO

  • figure out how to allow CLJS plugins