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;
/* jshint -W097 */// jshint strict:false
/*jslint node: true */
'use strict';
const cp = require('child_process');
const utils = require('@iobroker/adapter-core'); // Get common adapter utils
const path = require('path');
const dataDir = path.normalize(utils.controllerDir + '/' + require(utils.controllerDir + '/lib/tools').getDefaultDataDir());
const fs = require('fs');
const GetHistory = require('./lib/getHistory.js');
const Aggregate = require('./lib/aggregate.js');
const adapterName = require('./package.json').name.split('.').pop();
const history = {};
const aliasMap = {};
let subscribeAll = false;
let bufferChecker = null;
const tasksStart = [];
let finished = false;
let adapter;
function startAdapter(options) {
options = options || {};
/**
*
* ioBroker email Adapter
*
* (c) 2014-2019 bluefox
*
* MIT License
*
*/
'use strict';
const utils = require('@iobroker/adapter-core'); // Get common adapter utils
const tools = require(utils.controllerDir + '/lib/tools.js');
const adapterName = require('./package.json').name.split('.').pop();
let adapter;
function startAdapter(options) {
options = options || {};
Object.assign(options, {
name: adapterName, // adapter name
});
adapter = new utils.Adapter(options);
adapter.on('unload', cb => {
if (adapter.__stopTimer) {
clearTimeout(adapter.__stopTimer);
adapter.__stopTimer = null;
}
/* jshint -W097 */// jshint strict:false
/*jslint node: true */
'use strict';
const utils = require('@iobroker/adapter-core'); // Get common adapter utils
const SimpleAPI = require('./lib/simpleapi.js');
const LE = require(utils.controllerDir + '/lib/letsencrypt.js');
const adapterName = require('./package.json').name.split('.').pop();
let webServer = null;
let fs = null;
let adapter;
function startAdapter(options) {
options = options || {};
Object.assign(options, {
name: adapterName,
stateChange: (id, state) => webServer && webServer.api && webServer.api.stateChange(id, state),
unload: callback => {
try {
if (webServer && webServer.server) {
adapter.log.info('terminating http' + (webServer.settings.secure ? 's' : '') + ' server on port ' + webServer.settings.port);
webServer.server.close();
var seriesBufferChecker = null;
var seriesBufferCounter = 0;
var seriesBufferFlushPlanned = false;
var seriesBuffer = {};
var conflictingPoints = {};
var errorPoints = {};
var tasksStart = [];
var connected = null;
var finished = false;
var aliasMap = {};
function getAppName() {
const parts = __dirname.replace(/\\/g, '/').split('/');
return parts[parts.length - 1].split('.')[0];
}
utils.appName = getAppName();
var adapter = utils.Adapter('influxdb');
adapter.on('objectChange', function (id, obj) {
var formerAliasId = aliasMap[id] ? aliasMap[id] : id;
if (obj && obj.common &&
(
// todo remove history sometime (2016.08) - Do not forget object selector in io-package.json
(obj.common.history && obj.common.history[adapter.namespace] && obj.common.history[adapter.namespace].enabled) ||
(obj.common.custom && obj.common.custom[adapter.namespace] && obj.common.custom[adapter.namespace].enabled)
)
) {
var realId = id;
var checkForRemove = true;
if (obj.common.custom && obj.common.custom[adapter.namespace] && obj.common.custom[adapter.namespace].aliasId) {
if (obj.common.custom[adapter.namespace].aliasId !== id) {
let lang = 'en';
let extensions = {};
let bruteForce = {};
let socketIoFile = null;
let webPreSettings = {};
let webByVersion = {};
let loginPage = null;
const FORBIDDEN_CHARS = /[\]\[*,;'"`<>\\\s?]/g; // with space
let redirectLink = '';
function getAppName() {
const parts = __dirname.replace(/\\/g, '/').split('/');
return parts[parts.length - 1].split('.')[0];
}
utils.appName = getAppName();
// copied from here: https://github.com/component/escape-html/blob/master/index.js
const matchHtmlRegExp = /["'&<>]/;
function escapeHtml (string) {
const str = '' + string;
const match = matchHtmlRegExp.exec(str);
if (!match) {
return str;
}
let escape;
let html = '';
let index;
let lastIndex = 0;
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);
});
});