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 t4qjXH8N / ioBroker.google-sharedlocations / main.js View on Github external
const auth = require(__dirname + '/lib/google_auth');

// you have to require the utils module and call adapter function
const utils = require('@iobroker/adapter-core'); // Get common adapter utils

// for communication
const request = require('request');

const min_polling_interval = 30; // minimum polling interval in seconds

const trigger_poll_state = 'trigger_poll';  // state for triggering a poll

// you have to call the adapter function and pass a options object
// name has to be set and has to be equal to adapters folder name and main file name excluding extension
// adapter will be restarted automatically every time as the configuration changed, e.g system.adapter.google-sharedlocations.0
const adapter = new utils.adapter('google-sharedlocations');

let google_polling_interval_id = null;
let google_cookie_header = null;

// triggered when the adapter is installed
adapter.on('install', function () {
  // create connection variable https://github.com/ioBroker/ioBroker/wiki/Adapter-Development-Documentation#infoconnection
});

// is called when the adapter shuts down - callback has to be called under any circumstances!
adapter.on('unload', function (callback) {
  try {
    // logout from google
    auth.logout(function (err) {
      if (err) {
        adapter.log.error('Could not logout from google when unloading the adapter.');
github jens-maus / ioBroker.unifi / main.js View on Github external
* Adapter to communicate with a UniFi-Controller instance
 * dealing with UniFi-WiFi-Devices
 *
 */

/* jshint -W097 */// jshint strict:false
/*jslint node: true */
"use strict";

// you have to require the utils module and call adapter function
var utils = require('@iobroker/adapter-core'); // Get common adapter utils

// you have to call the adapter function and pass a options object
// name has to be set and has to be equal to adapters folder name and main file name excluding extension
// adapter will be restarted automatically every time as the configuration changed, e.g system.adapter.unifi.0
var adapter = utils.adapter('unifi');

// define a timeout variable so that
// we can check the controller in regular intervals
var queryTimeout;

// is called when adapter shuts down - callback has to be called under any circumstances!
adapter.on('unload', function (callback) {
  try {

    // clear the timeout
    if(queryTimeout)
      clearTimeout(queryTimeout);

    adapter.log.info('cleaned everything up...');
    callback();
  } catch (e) {

@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