Skip to content

Commit

Permalink
Remove init
Browse files Browse the repository at this point in the history
Remove and other driver specific methods to let this be handled by the z-wave driver.
  • Loading branch information
Robin van Kekem authored and Robin van Kekem committed Aug 15, 2016
1 parent 8575b91 commit 306e110
Showing 1 changed file with 1 addition and 70 deletions.
71 changes: 1 addition & 70 deletions drivers/alarmsound/driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
const path = require('path');
const ZwaveDriver = require('homey-zwavedriver');

var devices = [];

// http://www.vesternet.com/downloads/dl/file/id/1024/product/2155/z_wave_benext_alarm_sound_manual.pdf

module.exports = new ZwaveDriver( path.basename(__dirname), {
Expand Down Expand Up @@ -55,58 +53,6 @@ module.exports = new ZwaveDriver( path.basename(__dirname), {
}
});

module.exports.init = function( devices_data, callback ) {
Homey.log('');
Homey.log("init method");
Homey.log("devices_data", devices_data);
devices_data.forEach(initDevice);

// let Homey know the driver is ready
callback(true, null);
}

// the `added` method is called is when pairing is done and a device has been added
module.exports.added = function( device_data, callback ) {
Homey.log('');
Homey.log("added method", device_data);
initDevice( device_data );
callback( null, true );
}

// the `delete` method is called when a device has been deleted by a user
module.exports.deleted = function( device_data, callback ) {
Homey.log('');
Homey.log("deleted method");
Homey.log('device_data.id:', device_data.id);
delete devices[ device_data.id ];
callback( null, true );
}

// a helper method to add a device to the devices list
function initDevice( device_data ) {
Homey.log('');
Homey.log('initDevice');
Homey.log('device_data', device_data);

var token = device_data.token;
Homey.log('token:', token);

var node = module.exports.nodes;
Homey.log('node:', node);

devices.push(device_data);
}

// a helper method to get a device from the devices list by it's device_data object
function getDeviceByData( device_data ) {
var device = devices[ device_data.id ];
if( typeof device === 'undefined' ) {
return new Error("invalid_device");
} else {
return device;
}
}

Homey.manager('flow').on('action.sound_alarm', function( callback, args ){
Homey.log('');
Homey.log('on flow action.action.sound_alarm');
Expand Down Expand Up @@ -137,19 +83,4 @@ Homey.manager('flow').on('action.silence_alarm', function( callback, args ){
});

callback( null, true ); // we've fired successfully
});

module.exports.on('initNode', function( token ){
Homey.log('');
Homey.log('initNode');

var node = module.exports.nodes[ token ];
if( node ) {
Homey.log('node:', node);
/*
node.instance.CommandClass['COMMAND_CLASS_BASIC'].on('report', function( command, report ){
Homey.manager('flow').triggerDevice('FGD-212_s2', null, null, node.device_data);
});
*/
}
})
});

0 comments on commit 306e110

Please sign in to comment.