Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (process.argv.indexOf('--deepAnalyze') !== -1) deepAnalyze = true;
if (process.argv[2] && (process.argv[2].indexOf('influxdb') === 0)) {
influxInstance = process.argv[2];
}
process.argv[2] = "--install";
console.log('Query Data from ' + influxInstance);
if (deepAnalyze) console.log('Do deep analysis to find holes in data');
var earliestDBValue = {};
var earliesValCachefile = __dirname + '/earliestDBValues.json';
var existingData = {};
var existingDataCachefile = __dirname + '/existingDBValues.json';
var existingTypes = {};
var existingTypesCachefile = __dirname + '/existingDBTypes.json';
var adapter = utils.Adapter('history');
var breakIt = false;
var stdin = process.stdin;
// without this, we would only get streams once enter is pressed
stdin.setRawMode( true );
// resume stdin in the parent process (node app won't quit all by itself
// unless an error or process.exit() happens)
stdin.resume();
// i don't want binary, do you?
stdin.setEncoding( 'utf8' );
// on any data into stdin
stdin.on( 'data', function( key ){
// ctrl-c ( end of text )
if ( key === 'x' || key === '\u0003') {
breakIt = true;
adapter.subscribeForeignObjects(adapter.config.socketio);
} else {
socketUrl = adapter.config.socketio;
ownSocket = socketUrl !== 'none';
}
// Read language
adapter.getForeignObject('system.config', (err, data) => {
if (data && data.common) {
lang = data.common.language || 'en';
}
});
}
});
adapter = new utils.Adapter(options);
return adapter;
}
if (!err) adapter.setState(id, state.val, true); // ?
});
}
break;
}
}
},
unload: (callback) => {
callback();
},
ready: () => {
main();
}
});
adapter = new utils.Adapter(options);
return adapter;
}
function startAdapter(options) {
options = options || {};
options.name = adapterName;
adapter = new utils.Adapter(options);
// {"val": state, "ack":false, "ts":1408294295, "from":"admin.0", "lc":1408294295}
// id = sonos.0.192_168_1_55.state
adapter.on('stateChange', (_id, state) => {
if (!state || state.ack) return;
adapter.log.info('try to control id ' + _id + ' with ' + JSON.stringify(state));
// Try to find the object
const id = adapter.idToDCS(_id);
if (id && id.channel && channels[id.channel]) {
if (state.val === 'false') state.val = false;
if (state.val === 'true') state.val = true;
if (parseInt(state.val) == state.val) state.val = parseInt(state.val);
let player = channels[id.channel].player;
if (!player) {
function startAdapter(options) {
const optionsSave = options || {};
Object.assign(optionsSave, { name: 'beckhoff' });
adapter = new utils.Adapter(optionsSave);
// When Adapter is ready then connecting to PLC and Subscribe necessary Handles
adapter.on('ready', () => {
adapter.subscribeStates('*');
plcConnection();
emitter.on('updateObjects', () => {
lib.createObjectsAndHandles(adsClient, adapter);
});
emitter.on('newSyncReq', () => {
lib.plcVarSyncronizing(adsClient, adapter, emitter);
});
});
function startAdapter(options) {
options = options || {};
Object.assign(options, {
name: 'tuya'
});
adapter = new utils.Adapter(options);
adapter.on('unload', function(callback) {
try {
stopAll();
stopProxy();
setConnected(false);
// adapter.log.info('cleaned everything up...');
setTimeout(callback, 3000);
} catch (e) {
callback();
}
});
adapter.on('stateChange', function(id, state) {
// Warning, state can be null if it was deleted
adapter.log.debug('stateChange ' + id + ' ' + JSON.stringify(state));
'use strict';
const events = require('events'),
lib = require('./lib'),
utils = require('@iobroker/adapter-core'),
ads = require('node-ads-api');
const emitter = new events.EventEmitter();
let adsClient = null,
checkPlcStateInterval = null,
oldConnectionState = false,
oldPlcState = false;
// Create new Adapter instance
const adapter = new utils.Adapter({
'name': 'beckhoff',
// When Adapter is ready then connecting to PLC and Subscribe necessary Handles
'ready': () => {
adapter.subscribeStates('*');
plcConnection();
emitter.on('updateObjects', () => {
lib.createObjectsAndHandles(adsClient, adapter, emitter);
});
emitter.on('newSyncReq', () => {
lib.plcVarSyncronizing(adsClient, adapter, emitter);
});
},
// When Adapter would be stopped some last work we have to do
break;
default:
adapter.log.warn('Unknown command in trigger: "' + state.val + '"');
}
}
},
unload: function (callback) {
callback();
},
ready: function () {
main();
}
});
adapter = new utils.Adapter(options);
return adapter;
}
break;
case 'alexaCustomResponse':
alexaCustom && alexaCustom.setResponse(obj.message);
break;
default:
adapter.log.warn('Unknown command: ' + obj.command);
break;
}
}
},
ready: () => main()
});
adapter = new utils.Adapter(options);
return adapter;
}
function sendDataToIFTTT(obj) {
function startAdapter(options) {
options = options || {};
Object.assign(options, {name: adapterName});
adapter = new utils.Adapter(options);
adapter.on('message', obj => {
if (obj) processMessage(obj);
processMessages();
});
adapter.on('ready', main);
adapter.on('unload', callback => {
if (isRunning) {
adapter && adapter.setState && adapter.setState('scanRunning', false, true);
isRunning = false;
isStopping = true;
haltAllMethods();
setTimeout(() => callback && callback(), 1000);
} else if (callback) {