Skip to content

Commit

Permalink
Implemented network search functionality
Browse files Browse the repository at this point in the history
If a new neo instance is initialized without a host specified, it will
start scanning the network for matching devices. If no host specified,
the ‘ready’ event will be called on your neo instance to let you know
it is done searching.
  • Loading branch information
RobinBol committed Oct 14, 2015
1 parent e8e9ea7 commit d47fd19
Show file tree
Hide file tree
Showing 7 changed files with 689 additions and 679 deletions.
112 changes: 57 additions & 55 deletions examples/example-neo.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,63 @@
var heatmiser = require("../lib/heatmiser");

var neo = new heatmiser.Neo("192.168.1.112");

neo.on('success', function(data) {
console.log(data);
});
neo.on('error', function(data) {
console.log(data);
});

neo.info();
neo.statistics();

var devices = ['bathroom', 'livingroom'];

neo.setAway(false, devices);
neo.setStandby(false, devices);

var comfortLevels = {
"bathroom": {
"monday": {
"wake": ["07:00", 20],
"leave": ["09:00", 16],
"return": ["24:00", 21],
"sleep": ["24:00", 16]
},
"sunday": {
"wake": ["09:00", 20],
"leave": ["11:00", 16],
"return": ["24:00", 21],
"sleep": ["24:00", 16]
}
},
"livingroom": {
"monday": {
"wake": ["07:00", 19],
"leave": ["08:30", 16],
"return": ["16:30", 19],
"sleep": ["23:00", 16]
var heatmiser = require( "../lib/heatmiser" );

var neo = new heatmiser.Neo();
neo.on( 'ready', function () {

neo.on( 'success', function ( data ) {
console.log( data );
} );
neo.on( 'error', function ( data ) {
console.log( data );
} );

neo.info();
neo.statistics();

var devices = [ 'bathroom', 'livingroom' ];

neo.setAway( false, devices );
neo.setStandby( false, devices );

var comfortLevels = {
"bathroom": {
"monday": {
"wake": [ "07:00", 20 ],
"leave": [ "09:00", 16 ],
"return": [ "24:00", 21 ],
"sleep": [ "24:00", 16 ]
},
"sunday": {
"wake": [ "09:00", 20 ],
"leave": [ "11:00", 16 ],
"return": [ "24:00", 21 ],
"sleep": [ "24:00", 16 ]
}
},
"sunday": {
"wake": ["09:00", 19],
"leave": ["10:00", 16],
"return": ["20:00", 19],
"sleep": ["23:00", 16]
"livingroom": {
"monday": {
"wake": [ "07:00", 19 ],
"leave": [ "08:30", 16 ],
"return": [ "16:30", 19 ],
"sleep": [ "23:00", 16 ]
},
"sunday": {
"wake": [ "09:00", 19 ],
"leave": [ "10:00", 16 ],
"return": [ "20:00", 19 ],
"sleep": [ "23:00", 16 ]
}
}
}
}

var keys = Object.keys(comfortLevels);
for (var i=0; i<keys.length; i++) {
var name = keys[i];
neo.setComfortLevels(comfortLevels[name], [name]);
}
var keys = Object.keys( comfortLevels );
for ( var i = 0; i < keys.length; i++ ) {
var name = keys[ i ];
neo.setComfortLevels( comfortLevels[ name ], [ name ] );
}

var wait = function () {
console.log( "waiting" );
}
setTimeout( wait, 1000 );
} )

var wait = function() {
console.log("waiting");
}
setTimeout(wait, 1000);
40 changes: 20 additions & 20 deletions examples/example-wifi.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
var heatmiser = require("../lib/heatmiser");
var heatmiser = require( "../lib/heatmiser" );

var hm = new heatmiser.Wifi("192.168.1.100", 1234);
var hm = new heatmiser.Wifi( "192.168.1.100", 1234 );

hm.on('success', function(data) {
console.log(data);
});
hm.on('error', function(data) {
console.log(data);
});
hm.on( 'success', function ( data ) {
console.log( data );
} );
hm.on( 'error', function ( data ) {
console.log( data );
} );

hm.read_device();

Expand All @@ -17,27 +17,27 @@ var dcb;

// target before hold!
var dcb1 = {
heating: {
target: 20
}
heating: {
target: 20
}
}
var dcb2 = {
heating: {
hold: 5
}
heating: {
hold: 5
}
}

hm.write_device(dcb1);
hm.write_device(dcb2);
hm.write_device( dcb1 );
hm.write_device( dcb2 );

// // set frost mode
dcb = {
runmode: 'frost'
runmode: 'frost'
}
hm.write_device(dcb);
hm.write_device( dcb );

// // set current date and time
dcb = {
time: new Date()
time: new Date()
}
hm.write_device(dcb);
hm.write_device( dcb );
6 changes: 3 additions & 3 deletions lib/heatmiser.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use strict";

var Wifi = require('./wifi');
var Neo = require('./neo');
var Wifi = require( './wifi' );
var Neo = require( './neo' );

module.exports = {Wifi: Wifi, Neo: Neo};
module.exports = { Wifi: Wifi, Neo: Neo };
Loading

0 comments on commit d47fd19

Please sign in to comment.