From 306e11028d8c91427101ab6167a571b12c3a67c3 Mon Sep 17 00:00:00 2001 From: Robin van Kekem Date: Mon, 15 Aug 2016 20:40:30 +0200 Subject: [PATCH] Remove init Remove and other driver specific methods to let this be handled by the z-wave driver. --- drivers/alarmsound/driver.js | 71 +----------------------------------- 1 file changed, 1 insertion(+), 70 deletions(-) diff --git a/drivers/alarmsound/driver.js b/drivers/alarmsound/driver.js index 5886d78..0257064 100644 --- a/drivers/alarmsound/driver.js +++ b/drivers/alarmsound/driver.js @@ -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), { @@ -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'); @@ -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); - }); - */ - } -}) \ No newline at end of file +}); \ No newline at end of file