GithubHelp home page GithubHelp logo

bacwolf / node-domoticz-mqtt Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nayrnet/node-domoticz-mqtt

0.0 1.0 0.0 30 KB

NodeJS Domoticz-MQTT Module

License: GNU General Public License v3.0

JavaScript 100.00%

node-domoticz-mqtt's Introduction

node-domoticz-mqtt

GPL-3.0 npm node

NodeJS Module for communication with Domoticz via MQTT Interface.

Example:

#!/usr/bin/nodejs
var	mqtt	= require('node-domoticz-mqtt');

// Options:
var options = {
	idx: 		[ 1, 2, 3, 4 ],
	host: 		'localhost',
	request:	true,
	log: 		false
};

var domoticz = new mqtt.domoticz(options);

// Log anything matching our IDX
domoticz.on('data', function(data) {
	message = JSON.stringify(data)
	console.log(message.toString());
});

// Set IDX #1 to ON after connection and log our connection.
domoticz.on('connect', function() {
	domoticz.switch(1,100);
	domoticz.log('My example app connected.');
});

Functions:

// Callback for any devices from options. Data is json format.
domoticz.on('data', function(data){  });

// Callback on connect
domoticz.on('connect', function(){  });

// Callback on error
domoticz.on('error', function(error){  });

// Publish Switch:  level commands: 0 = Off/255 = On/-1 = Toggle/1-100 = Set Level
domoticz.switch(idx,level);

// Publish Contact Switch Open/Close:
domoticz.switchContact(idx,boolean);

// Publish uDevice: nvalue = int, svalue = string
domoticz.device(idx,nvalue,svalue);

// Publish Scene: cmd is optional, use "Off" for groups.
domoticz.scene(idx,cmd);

// Publish User Variable
domoticz.uservar(idx,value);

// Publish Domoticz Log Status
domoticz.log(message);

// Publish Notification: priority and sound are optional
domoticz.notify(subject,body,priority,sound);

// Request Device Status
domoticz.request(idx);

Options

  • idx - an array of device idx to watch and update on connect. defaults to none.
  • status - MQTT Path for reporting your app is online, optional.
  • host - Host of your MQTT Broker, defaults to localhost.
  • request - booolean to request updates for all IDX on connect, defaults to true.
  • log - boolean to show detailed logs, defaults to false.

More

About:

By: Ryan Hunt

node-domoticz-mqtt's People

Contributors

nayrnet avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.