Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including novus-component with all npm packages installed. Try it out:

var novusComponent = require("novus-component")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

novus-component v3.3.2

Component framework for home automation

Novus Home Automation Component

novus-component is a component that adds some handy sugar to MQTT.

Version 3 (the current version) has been rebuilt from the ground up to provide more reliable service.

Included is an example of how to use the component. Further documentation is forthcoming (time permitting).

Install

npm i novus-component --save

Example

import { Component } from 'novus-component';

const component = new Component('my-component-id', {
    url: 'mqtt://broker.hivemq.com'
});

component.route({
    topic: 'just/get/some/topic',
    handler: function(packet) {
        console.log('I got', packet.payload.toString() + '!');
    }
});

component.start()
    .then((connack) => {
        console.log('Component started');

        component.publish('just/get/some/topic', 'YEEHAA')
            .then(() => {
                console.log('Published message');
            })
            .catch((err) => {
                console.error('Error publishing message:');
                console.error(err);
            });
    })
    .catch((err) => {
        console.error('Oops! Got an error:');
        console.error(err);
    });

License

Copyright 2016 Michiel van der Velde.

This software is licensed under the MIT License

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free