Skip to content
Start using craft ai in a Node.JS app using the official client, in a SmartHome context
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
data
src
.eslintignore
.eslintrc
.gitignore
.travis.yml
LICENSE
README.md
package.json

README.md

craft ai JavaScript starter kit

Build License

craft ai AI-as-a-service enables your services to learn every day: provide a personalized experience to each user and automate complex tasks.

This repository hosts a fully working application, in a Smart Home context, integrating craft ai written in Node.js using craft ai official js client.

The end goal: automate the light in a room based on motion sensors and time. Using craft ai, this simple application learns when each household prefers the light to be turned when a motion is detected.

Setup

  • Download or clone the sources from GitHub,
  • Install Node.js on your computer (version 6.9 is recommended),
  • Install dependencies by running npm install in a terminal from the directory where the sources are.
  • Create a new project using this link. You can see that you now have two tokens : the "Read API token" and the "Write API token". Only the latter will be used here. These tokens allow you to authenticate your calls to the craft ai API as explained in the documentation.
  • In the cloned/downloaded repository, create a .env file. Fill it with the line CRAFT_TOKEN= followed by the Write API token of your project. It should look like this:
    CRAFT_TOKEN=paste-your-write-token-here
    

Run

The following will:

  1. create an agent,
  2. add a bunch of context operations from the example dataset,
  3. compute a decision tree and
  4. take a few decisions.
> npm run start

What do next ?

Now that you know how to compute your decision tree, you are able to complete the initial goal: automate the room's light using actual devices.

You can use the devices input to add context operations in real time and compute a decision when the context changes that can be used, in conjuction with its confidence, to turn the light on or off.

About the dataset

This starter kit uses real data extracted from a public dataset.

The dataset "twor.2010" was made available by the CASAS group of Washington State University; the original dataset can be found here. It comes from a house with 2 residents, gathered around 1 year (2009 - 2010) academic year. This house is equipped with sensors like motion, light, temperature, door, etc, in all the rooms.

Data preparation

The pre-treated data are already computed and available for this example.

We only use the movement sensors and the light sensor from one room: the bedroom of one of the residents. From the original data, we selected the desired sensors: one lightbulb and several motion sensors that we merge to a unique indicator counting the number of sensors detecting movements.

If you want to pre-treat by yourself, you could run:

> npm run prepare_data.

The result will be set in data/twor.2010.

This runs src/prepare.js, you can check out this file to see what we've done and make your own preparation.

The craft ai user documentation can be found at https://beta.craft.ai/doc and technical questions can be sent by email at support@craft.ai.

You can’t perform that action at this time.