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

iotdb-commands

v3.0.12

Published

Apply human-like commands to IOTDB Things

Downloads

54

Readme

iotdb-commands

Apply human-like commands to IOTDB Things

About

This applies "human like" commands to things. For example, "turn up" the "lights". Note that this does not do NLP processing, we assume requests are already structured as so:

{
    "thing": "TV",
    "action": "turn on"
}

This then will look through any transporter you provide to file matching things, based on the their current state, metadata, etc.

Vocabulary

See the folder vocabulary. Everything is written in YAML.

Use

Request Object

We assume there's something doing some parsing beforehand, and we're down to the core data. This doesn't do any clever NLP stuff. That's what your Amazon Echo (etc) are for.

Actions

Input Requests look like this:

{
    "thing": "TV",
    "action": "turn on"
}

A special action is forget, which will delete the Thing from the Transporter. If the Transporter is IOTDB, it will disconnect the Thing.

Query

List all the Things that are on

{
    "thing": "TV",
    "action": "on"
}

A special action is list, which will list everything

Zones

Requests can be specifically restricted to a Zone

{
    "thing": "TV",
    "action": "off",
    "zone": "Second Floor",
}

Code

Here's a basic example to directly manipulate a WeMo Socket. There's a fair bit of setup, but we hope it's worth it.

const iotdb = require("iotdb")
const _ = iotdb._;

const iotdb_commands = require("iotdb-commands")

iotdb.use("homestar-wemo")
iotdb.connect("WeMoSocket")

const iotdb_transport_iotdb = require("iotdb-transport-iotdb")
const iotdb_transporter = iotdb_transport_iotdb.make({}, iotdb.things())

iotdb_commands.match({
    transporter: iotdb_transporter,
    requestd: {
        action: "turn on",   // or try: query: "on"
        thing: "lights",
    }
}, ( error, matches ) => {
    matches.forEach(matchd => iotdb_commands.execute(iotdb_transporter, matchd, error => {
        …
    });
})

Command Line

If you installed Home☆Star youll be able to try it from the command line

$ homestar --thing "tv" --action "turn on"

Note that this assumes you're in an environment set up by homestar-persist, so don't tear your hair out if this doesn't work for you immediately.

Development

Examples

Try it out using

$ node tools/RunSamples samples/tests/action-lights-turn-up.json | bunyan
$ node tools/RunSamples samples/tests/query-tv-channel.json | bunyan

The samples folder is where all the sample data is stored. Eventually we'll have sample results, so RunSamples will work to run test caes

Test Cases

There are numerous test cases in test. These are independent of the samples (next sction).

More Test Cases

The folders samples/tests Have input Requests to test against The folder samples/things are the "Things" to test with