Skip to content

nomiku/nomiku-js

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nomiku JavaScript SDK

This library provides a simple interface to control your WiFi Nomiku. Currently compatible with node v6.x.x

Installing

Installing is as easy as:

npm install --save nomiku

Example

Some example usage:

var NomikuClient = require("nomiku");

var nomiku = new NomikuClient();

nomiku.on("state", function({ state }) {
  console.log("State: " + JSON.stringify(state));
});

nomiku.connect({
  email: process.env.TENDER_EMAIL,
  password: process.env.TENDER_PASSWORD
});

nomiku.on("connect", function() {
  nomiku.set().on();
  nomiku.set().setpoint(55.0);
});

On connect, the client grabs the login token and the list of devices and starts listening to the default device indicated in Tender. It will return the state whenever it changes.

See longer examples in the examples directory

Getting the state

The state event is documented in the API, but the further details of the state object are:

Name Type Description
recipeID number Recipe ID currently cooking
recipeTitle string Indicates whether the state has been emitted before
setpoint number Set temperature in °C
showF boolean True if temp should be displayed in °F
state number -1: offline, 0: online but not heating/circulating, 1: online and running
temp number Current temperature in °C
timerEnd number Timer end time in UTC seconds (if timer is running)
timerRunning boolean Whether timer is running
timerSecs number Time remaining in seconds (if timer is not running)

Setting the state

The most straightforward way to update the state is to pass a new state object (only changed keys need to be included) to the set function of device id (omit id to use default device):

nomiku.set(id).state(state)

A number of other convenience functions were created on top of nomiku.set(id):

  • .off() turns off the device
  • .on() turns on the device
  • .setpoint(setpoint) changes setpoint to setpoint in °C
  • .timer.start() starts the timer
  • .timer.stop() stops the timer
  • .timer.set(secs) stops the timer and sets it to secs seconds
  • .units(unit) changes displayed units, unit is either the char 'C' or 'F'
  • .recipe(recipe) starts cooking a new recipe, where recipe has properties:
Name Type Description
id number (optional) Recipe ID
title string (optional) Recipe title
temp number Set temperature in °C
time number Number of seconds for the timer

Client API

Client class

Functions

connect(options)

Connects to server for streaming data

auth(options)

Gets API token from tender

loadDevices()

Gets device list from Tender

getDefaultDevice()

Gets default device from Tender

listen(id)

Listens for state on device

set(id)

Set state on device

Client

Kind: global class

new Client(options)

The Nomiku Client controls the connection to the Nomiku. Descends from EventEmitter

Param Type Description
options Object The option object. Can also be passed to connect.
options.email string tender account email (for email, password login)
options.password string tender account password (for email, password login)
options.userID string ID of the user (for token login)
options.apiToken string API token (for token login)

"event:connect"

Successfully connected

Kind: event emitted by Client

"event:close"

Connection is closed

Kind: event emitted by Client

"event:state"

New state

Kind: event emitted by Client
Properties

Name Type Description
id number Tender ID of device
new boolean Indicates whether the state has been emitted before
state object Latest state
provisional object Dict with same keys as state, key is true if it is unconfirmed
valid boolean Indicates whether the state is valid

connect(options)

Connects to server for streaming data

Kind: global function

Param Type Description
options Object The option object Options:
options.email string tender account email (for email, password login)
options.password string tender account password (for email, password login)
options.userID string ID of the user (for token login)
options.apiToken string API token (for token login)
options.defaultDevice string | number (optional) default device to connect to
options.devices array (optional) array of devices, {hwid,id,name}
options.verboseState boolean (optional) will send state event with every message

auth(options)

Gets API token from tender

Kind: global function

Param Type Description
options object Info needed to auth with Tender API (email/password)

loadDevices()

Gets device list from Tender

Kind: global function

getDefaultDevice()

Gets default device from Tender

Kind: global function

listen(id)

Listens for state on device

Kind: global function

Param Type Description
id string | number Tender ID of nomiku to listen to

set(id)

Set state on device

Kind: global function

Param Type Description
id string | number Tender ID of nomiku to set

About

Client library for controlling Nomiku WiFi devices

Resources

License

Stars

Watchers

Forks

Packages

No packages published