Skip to content
Marcin Sielski edited this page Feb 15, 2018 · 13 revisions

Hazyair ⇐ EventEmitter

Class implementing the interface to the Hazyair monitoring tool.

Kind: global class
Extends: EventEmitter

new Hazyair(config)

Create a Hazyair instance.

Param Type Description
config Object [ { parameter: ('dust'|'temperature'|'pressure'|'humidity'), model: ..., persistent: (true|false), options: {... } }, ...]

Example

let hazyair = new Hazyair([{
    parameter: 'dust',
    model: 'PMS7003',
    persistent: true,
    options: {
        device: '/dev/serial0'
    }
}]);

hazyair.thingspeak(config)

Send all sensors data to the ThingSpeak™ service once they are available.

Kind: instance method of Hazyair

Param Type Description
config Object { api_key: ..., parameters: { (dust|temperature|pressure|humidity): ({...: 'field1', ...}|('field1'|...)) } } }

Example

hazyair.thingspeak({
    api_key: 'XXXXXXXXXXXXXXXX',
    parameters: {
        dust: {
            concentration_pm10_normal: 'field1'
        }
    }
});

hazyair.dweet(config)

Send all sensors data to the dweet.io service once they are available.

Kind: instance method of Hazyair

Param Type Description
config Object { thing: ..., (key: ...,) parameters: { (dust|temperature|pressure|humidity): ({...: ..., ...}|(...)) } } }

Example

hazyair.dweet({
    thing: 'XXXXXXXXXXXXXXXX',
    parameters: {
        dust: {
            concentration_pm10_normal: 'PM10'
        }
    }
});

hazyair.start()

Start monitoring of the specified parameter(s).

Kind: instance method of Hazyair
Emits: Hazyair#event:dust, Hazyair#event:temperature, Hazyair#event:pressure, Hazyair#event:humidity
Example

hazyair.start()

hazyair.listen(options, [callback]) ⇒ Promise

Start http web service.

Kind: instance method of Hazyair
Returns: Promise - Promise object

Param Type Default Description
options Object passed to the http server
[callback] function function passed to the http server

Example

hazyair.listen({
    port: 8081
}).then(() => {
    // web service started
});

hazyair.close([callback]) ⇒ Promise

Close http web server and access to the databases if required.

Kind: instance method of Hazyair
Returns: Promise - Promise object

Param Type Default Description
[callback] function function executed when action is completed

Example

hazyair.close().then(() => {
    // hazyair closed
});