How to use the @iobroker/adapter-core.Adapter function in @iobroker/adapter-core

To help you get started, we’ve selected a few @iobroker/adapter-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ioBroker / ioBroker.history / converter / analyzeinflux.js View on Github external
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;
github ioBroker / ioBroker.vis-web-admin / main.js View on Github external
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;
}
github SebastianSchultz / ioBroker.lgtv / lgtv.js View on Github external
if (!err) adapter.setState(id, state.val, true); // ?
                            });
                        }
                        break;
                }
            }
        },
        unload:       (callback) => {
            callback();
        },
        ready:        () => {
            main();
        }
    });

    adapter = new utils.Adapter(options);

    return adapter;
}
github ioBroker / ioBroker.sonos / main.js View on Github external
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) {
github dkleber89 / ioBroker.beckhoff / beckhoff.js View on Github external
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);
    });
  });
github Apollon77 / ioBroker.tuya / main.js View on Github external
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));
github dkleber89 / ioBroker.beckhoff / beckhoff.js View on Github external
'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
github iobroker-community-adapters / ioBroker.ical / main.js View on Github external
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;
}
github ioBroker / ioBroker.iot / main.js View on Github external
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) {
github ioBroker / ioBroker.discovery / main.js View on Github external
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) {

@iobroker/adapter-core

Core module to be used in ioBroker adapters. Acts as the bridge to js-controller.

MIT
Latest version published 1 month ago

Package Health Score

78 / 100
Full package analysis